當前位置: 首頁>>代碼示例>>Java>>正文


Java SubMonitor.isCanceled方法代碼示例

本文整理匯總了Java中org.eclipse.core.runtime.SubMonitor.isCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java SubMonitor.isCanceled方法的具體用法?Java SubMonitor.isCanceled怎麽用?Java SubMonitor.isCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.runtime.SubMonitor的用法示例。


在下文中一共展示了SubMonitor.isCanceled方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException {
	SubMonitor progress = SubMonitor.convert(monitor);
	if (!prefs.isCompilerEnabled()) {
		return;
	}
	final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context);
	if (deltas.isEmpty()) {
		return;
	}
	if (progress.isCanceled()) {
		throw new OperationCanceledException();
	}
	progress.beginTask("Compiling solidity...", deltas.size());

	List<URI> uris = deltas.stream().map(delta -> delta.getUri()).collect(Collectors.toList());
	compiler.compile(uris, progress);
	context.getBuiltProject().refreshLocal(IProject.DEPTH_INFINITE, progress);
	progress.done();

}
 
開發者ID:Yakindu,項目名稱:solidity-ide,代碼行數:22,代碼來源:SolidityBuilderParticipant.java

示例2: removeObsoleteGpeRemnants

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * Removes various GPE-related remnants: classpath entries, nature, runtime, and facets. Any error
 * during operation is logged but ignored.
 *
 * @return true if this was a GPE project
 * @throws CoreException if the project is unusable (e.g., not open, doesn't exist, out of sync)
 */
public static boolean removeObsoleteGpeRemnants(
    final IFacetedProject facetedProject, IProgressMonitor monitor) throws CoreException {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 40);
  IProject project = facetedProject.getProject();
  boolean wasGpeProject = false;

  wasGpeProject |= removeGpeClasspathEntries(project, subMonitor.newChild(10));
  if (subMonitor.isCanceled()) {
    return wasGpeProject;
  }

  wasGpeProject |= removeGpeNature(project, subMonitor.newChild(10));
  if (subMonitor.isCanceled()) {
    return wasGpeProject;
  }

  wasGpeProject |= removeGpeRuntimeAndFacets(facetedProject);
  subMonitor.worked(20);

  return wasGpeProject;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:29,代碼來源:GpeMigrator.java

示例3: findReferences

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public void findReferences(
		TargetURIs targetURIs,
		Set<URI> candidates,
		IResourceAccess resourceAccess,
		IResourceDescriptions descriptions,
		Acceptor acceptor,
		IProgressMonitor monitor) {
	if (!targetURIs.isEmpty() && !candidates.isEmpty()) {
		SubMonitor subMonitor = SubMonitor.convert(monitor, targetURIs.size() / MONITOR_CHUNK_SIZE + 1);
		IProgressMonitor useMe = subMonitor.newChild(1);
		int i = 0;
		for (URI candidate : candidates) {
			if (subMonitor.isCanceled())
				throw new OperationCanceledException();
			IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(candidate);
			doFindReferencesWith(languageSpecific, targetURIs, candidate, resourceAccess, descriptions, acceptor, useMe);
			i++;
			if (i % MONITOR_CHUNK_SIZE == 0) {
				useMe = subMonitor.newChild(1);
			}
		}
	}
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:25,代碼來源:ReferenceFinder.java

示例4: findAllReferences

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public void findAllReferences(TargetURIs targetURIs, IResourceAccess resourceAccess,
		IResourceDescriptions indexData, Acceptor acceptor, IProgressMonitor monitor) {
	if (!targetURIs.isEmpty()) {
		Iterable<IResourceDescription> allResourceDescriptions = indexData.getAllResourceDescriptions();
		SubMonitor subMonitor = SubMonitor.convert(monitor, size(allResourceDescriptions) / MONITOR_CHUNK_SIZE + 1);
		IProgressMonitor useMe = subMonitor.newChild(1);
		int i = 0;
		for (IResourceDescription resourceDescription : allResourceDescriptions) {
			if (subMonitor.isCanceled())
				throw new OperationCanceledException();
			IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(resourceDescription.getURI());
			languageSpecific.findReferences(targetURIs, resourceDescription, resourceAccess, acceptor, useMe);
			i++;
			if (i % MONITOR_CHUNK_SIZE == 0) {
				useMe = subMonitor.newChild(1);
			}
		}
	}
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:21,代碼來源:ReferenceFinder.java

示例5: buildOtherParticipants

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * Builds all other registered (non-language specific) {@link IXtextBuilderParticipant}s.
 *
 * @param buildContext
 *          the {@link IBuildContext}, must not be {@code null}
 * @param monitor
 *          the {@link IProgressMonitor}, must not be {@code null}
 * @throws CoreException
 *           caused by an {@link IXtextBuilderParticipant}
 */
protected void buildOtherParticipants(final IBuildContext buildContext, final IProgressMonitor monitor) throws CoreException {
  ImmutableList<IXtextBuilderParticipant> otherBuilderParticipants = getParticipants();
  if (otherBuilderParticipants.isEmpty()) {
    return;
  }
  SubMonitor progress = SubMonitor.convert(monitor, otherBuilderParticipants.size());
  progress.subTask(Messages.RegistryBuilderParticipant_InvokingBuildParticipants);
  for (final IXtextBuilderParticipant participant : otherBuilderParticipants) {
    if (progress.isCanceled()) {
      throw new OperationCanceledException();
    }
    try {
      if (initializeParticipant(participant)) {
        participant.build(buildContext, progress.newChild(1));
      }
      // CHECKSTYLE:CHECK-OFF IllegalCatchCheck we need to recover from any exception and continue the build
    } catch (Throwable throwable) {
      // CHECKSTYLE:CHECK-ON IllegalCatchCheck
      LOG.error("Error occurred during build of builder participant: " //$NON-NLS-1$
          + participant.getClass().getName(), throwable);
    }
  }
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:34,代碼來源:RegistryBuilderParticipant.java

示例6: createOrganizingRunnable

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/** Creates {@link IRunnableWithProgress} that will be organize imports in the provided files. */
private IRunnableWithProgress createOrganizingRunnable(List<IFile> collectedFiles) {
	IRunnableWithProgress op = new IRunnableWithProgress() {
		@Override
		public void run(IProgressMonitor mon) throws InvocationTargetException, InterruptedException {
			int totalWork = collectedFiles.size();
			SubMonitor subMon = SubMonitor.convert(mon, "Organize imports.", totalWork);
			for (int i = 0; !subMon.isCanceled() && i < totalWork; i++) {
				IFile currentFile = collectedFiles.get(i);
				subMon.setTaskName("Organize imports." + " - File (" + (i + 1) + " of " + totalWork + ")");
				try {
					OrganizeImportsService.organizeImportsInFile(currentFile, Interaction.breakBuild, subMon);

				} catch (CoreException | RuntimeException e) {
					String msg = "Exception in file " + currentFile.getFullPath().toString() + ".";
					LOGGER.error(msg, e);
					boolean errorDialogShowed = ErrorDialogWithStackTraceUtil.showErrorDialogWithStackTrace(
							msg + " Hit OK to continue.", e);
					if (!errorDialogShowed) {
						throw new InvocationTargetException(e);
					}
				}
			}
			if (subMon.isCanceled()) {
				throw new InterruptedException();
			}
		}

	};
	return op;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:32,代碼來源:N4JSOrganizeImportsHandler.java

示例7: unzip

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/** Unzip the contents into the specified destination directory. */
public static IStatus unzip(File zip, File destination, IProgressMonitor monitor) {
  SubMonitor progress = SubMonitor.convert(monitor);
  if (!destination.exists()) {
    if (!destination.mkdirs()) {
      return StatusUtil.error(ZipUtil.class, "Unable to create destination: " + destination);
    }
  } else if (!destination.isDirectory()) {
    return StatusUtil.error(ZipUtil.class, "Destination is not a directory: " + destination);
  }
  try (ZipFile zipFile = new ZipFile(zip)) {
    progress.setWorkRemaining(zipFile.size());
    for (Enumeration<? extends ZipEntry> entries = zipFile.entries(); entries.hasMoreElements()
        && !progress.isCanceled();) {
      ZipEntry entry = entries.nextElement();
      File entryLocation = new File(destination, entry.getName());
      if (entry.isDirectory()) {
        if (!entryLocation.exists()) {
          if (!entryLocation.mkdirs()) {
            return StatusUtil.error(ZipUtil.class,
                "Unable to create destination: " + entryLocation);
          }
        } else if (!entryLocation.isDirectory()) {
          return StatusUtil.error(ZipUtil.class,
              "Destination is not a directory: " + entryLocation);
        }
      } else {
        try (InputStream input = zipFile.getInputStream(entry);
            FileOutputStream output = new FileOutputStream(entryLocation)) {
          ByteStreams.copy(input, output);
        }
      }
      progress.worked(1);
    }
    return Status.OK_STATUS;
  } catch (IOException ex) {
    return StatusUtil.error(ZipUtil.class, "Unable to extract zip file: " + zip, ex);
  }
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:40,代碼來源:ZipUtil.java

示例8: checkTsv

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
void checkTsv(final Collection<IFile> files, IProgressMonitor monitor) throws CoreException {
	final SubMonitor subMonitor = SubMonitor.convert(monitor, files.size() * 5);
	final ItemsXmlValidator validator = getValidator();
	for (final IFile file : files) {
		if (subMonitor.isCanceled()) {
			throw new OperationCanceledException("TSV Check cancelled");
		}
		subMonitor.subTask("Checking typesystem: " + file.getFullPath());
		
		processResults(file, validator.analyze(file, subMonitor.newChild(4)), subMonitor.newChild(1));
		
	}
}
 
開發者ID:SAP,項目名稱:hybris-commerce-eclipse-plugin,代碼行數:14,代碼來源:TsvBuilder.java

示例9: findAllIndexedReferences

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * Uses IResourceDescriptions2 to find all indexed references.
 *
 * @param targetURIs
 *          the URIs to find references to, must not be {@code null}
 * @param indexData
 *          index to use when finding references, must not be {@code null}
 * @param referenceAcceptor
 *          the reference acceptor, must not be {@code null}
 * @param subMonitor
 *          the progress monitor, can be {@code null}
 */
protected void findAllIndexedReferences(final TargetURIs targetURIs, final IResourceDescriptions indexData, final Acceptor referenceAcceptor, final SubMonitor subMonitor) {
  IResourceDescriptions2 idx = (IResourceDescriptions2) indexData;
  List<IReferenceDescription> refs = uniqueReferences(Lists.newArrayList(idx.findReferencesToObjects(targetURIs.asSet())));
  final SubMonitor monitor = SubMonitor.convert(subMonitor, Messages.ReferenceQuery_monitor, refs.size());
  for (IReferenceDescription desc : refs) {
    if (monitor.isCanceled()) {
      return;
    }
    referenceAcceptor.accept(desc);
    monitor.worked(1);
  }
  monitor.done();
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:26,代碼來源:ReferenceFinder2.java


注:本文中的org.eclipse.core.runtime.SubMonitor.isCanceled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。