本文整理匯總了Java中org.eclipse.core.runtime.SubMonitor.convert方法的典型用法代碼示例。如果您正苦於以下問題:Java SubMonitor.convert方法的具體用法?Java SubMonitor.convert怎麽用?Java SubMonitor.convert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.runtime.SubMonitor
的用法示例。
在下文中一共展示了SubMonitor.convert方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
protected IStatus run(IProgressMonitor monitor) {
SubMonitor pm = SubMonitor.convert(
monitor, Messages.commitPartDescr_commiting, 2);
Log.log(Log.LOG_INFO, "Applying diff tree to db"); //$NON-NLS-1$
pm.newChild(1).subTask(Messages.commitPartDescr_modifying_db_model); // 1
pm.newChild(1).subTask(Messages.commitPartDescr_exporting_db_model); // 2
try {
Collection<TreeElement> checked = new TreeFlattener()
.onlySelected()
.onlyEdits(dbProject.getDbObject(), dbRemote.getDbObject())
.flatten(tree);
new ProjectUpdater(dbRemote.getDbObject(), dbProject.getDbObject(),
checked, proj).updatePartial();
monitor.done();
} catch (IOException | CoreException e) {
return new Status(Status.ERROR, PLUGIN_ID.THIS,
Messages.ProjectEditorDiffer_commit_error, e);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
示例2: loadInternal
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
protected PgDatabase loadInternal(SubMonitor monitor)
throws IOException, InterruptedException {
SubMonitor pm = SubMonitor.convert(monitor, 2);
try (TempFile tf = new TempFile("tmp_dump_", ".sql")) { //$NON-NLS-1$ //$NON-NLS-2$
File dump = tf.get().toFile();
pm.newChild(1).subTask(Messages.dbSource_executing_pg_dump);
new PgDumper(exePgdump, customParams,
host, port, user, pass, dbname, encoding, timezone,
dump.getAbsolutePath()).pgDump();
pm.newChild(1).subTask(Messages.dbSource_loading_dump);
try (PgDumpLoader loader = new PgDumpLoader(dump,
getPgDiffArgs(encoding, forceUnixNewlines),
monitor)) {
return loader.load();
}
}
}
示例3: createFileDeleteIfExists
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
* Create a file in a folder with the specified name and content
*
* @param fullpath
* @param filename
* @param content
* @throws CoreException
* @throws InterruptedException
*/
public static IFile createFileDeleteIfExists(String fullpath, String filename, String content,
IProgressMonitor monitor) throws CoreException, InterruptedException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
subMonitor.setTaskName("Create file delete if it exists " + fullpath);
IFile newFile;
try {
IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
IContainer container = (IContainer) wroot.findMember(new Path(fullpath));
newFile = container.getFile(new Path(filename));
if (newFile.exists()) {
JDTManager.rename(newFile, new NullProgressMonitor());
newFile.delete(true, new NullProgressMonitor());
}
subMonitor.split(30);
byte[] source = content.getBytes(Charset.forName("UTF-8"));
newFile.create(new ByteArrayInputStream(source), true, new NullProgressMonitor());
subMonitor.split(70);
} finally {
subMonitor.done();
}
return newFile;
}
示例4: createJob
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
* @param jobname
* @param tasks
* @return
*/
public static Job createJob(String jobname, List<UITask.Task> tasks) {
Job job = new Job(jobname) {
@Override
protected IStatus run(IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, tasks.size());
for (UITask.Task task : tasks) {
try {
subMonitor.setTaskName(task.getSummary());
workOnTask(task, subMonitor.split(1));
} catch (Exception e) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
return job;
}
示例5: createConfigFiles
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
* Creates an appengine-web.xml file in the WEB-INF folder if it doesn't exist.
*/
@VisibleForTesting
void createConfigFiles(IProject project, IProgressMonitor monitor)
throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 10);
IFile appEngineWebXml = WebProjectUtil.findInWebInf(project, new Path(APPENGINE_WEB_XML));
if (appEngineWebXml != null && appEngineWebXml.exists()) {
return;
}
// Use the virtual component model decide where to create the appengine-web.xml
appEngineWebXml = WebProjectUtil.createFileInWebInf(project, new Path(APPENGINE_WEB_XML),
new ByteArrayInputStream(new byte[0]), progress.newChild(2));
String configFileLocation = appEngineWebXml.getLocation().toString();
Map<String, String> parameters = new HashMap<>();
parameters.put("runtime", "java8");
Templates.createFileContent(configFileLocation, Templates.APPENGINE_WEB_XML_TEMPLATE,
parameters);
progress.worked(4);
appEngineWebXml.refreshLocal(IFile.DEPTH_ZERO, progress.newChild(1));
}
示例6: execute
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
SubMonitor subMonitor = SubMonitor.convert(monitor, "create new Catalog:" + getProjectInfo().getCatalogName(), 2);
IFolder outputFolder = (IFolder) getProjectInfo().getPackageFragment().getResource();
IProject project = outputFolder.getProject();
IPath path = project.getLocation().makeAbsolute();
try {
generatorUtil.generateCheckFile(path, getProjectInfo());
generatorUtil.generateDefaultQuickfixProvider(path, getProjectInfo());
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} finally {
setResult(outputFolder.getFile(getProjectInfo().getCatalogName() + '.' + CheckConstants.FILE_EXTENSION));
subMonitor.done();
}
}
示例7: resolveAll
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public IStatus resolveAll(IJavaProject javaProject, IProgressMonitor monitor) {
try {
MultiStatus status = StatusUtil.multi(this, Messages.getString("TaskResolveLibrariesError")); //$NON-NLS-1$
IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
SubMonitor subMonitor = SubMonitor.convert(monitor,
Messages.getString("TaskResolveLibraries"), //$NON-NLS-1$
getTotalWork(rawClasspath));
for (IClasspathEntry classpathEntry : rawClasspath) {
if (classpathEntry.getPath().segment(0)
.equals(LibraryClasspathContainer.CONTAINER_PATH_PREFIX)) {
IStatus resolveContainerStatus =
resolveContainer(javaProject, classpathEntry.getPath(), subMonitor.newChild(1));
status.add(resolveContainerStatus);
}
}
// rewrite if OK as otherwise Progress View shows the resolving error message
return StatusUtil.filter(status);
} catch (CoreException ex) {
return StatusUtil.error(this,
Messages.getString("TaskResolveLibrariesError"), ex); //$NON-NLS-1$
}
}
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:24,代碼來源:LibraryClasspathContainerResolverService.java
示例8: stageFlexible
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
* @param appEngineDirectory directory containing {@code app.yaml}
* @param deployArtifact project to be deploy (such as WAR or JAR)
* @param stagingDirectory where the result of the staging operation will be written
* @throws AppEngineException when staging fails
* @throws OperationCanceledException when user cancels the operation
*/
public static void stageFlexible(IPath appEngineDirectory, IPath deployArtifact,
IPath stagingDirectory, IProgressMonitor monitor) {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
SubMonitor progress = SubMonitor.convert(monitor, 1);
progress.setTaskName(Messages.getString("task.name.stage.project")); //$NON-NLS-1$
DefaultStageFlexibleConfiguration stagingConfig = new DefaultStageFlexibleConfiguration();
stagingConfig.setAppEngineDirectory(appEngineDirectory.toFile());
stagingConfig.setArtifact(deployArtifact.toFile());
stagingConfig.setStagingDirectory(stagingDirectory.toFile());
CloudSdkAppEngineFlexibleStaging staging = new CloudSdkAppEngineFlexibleStaging();
staging.stageFlexible(stagingConfig);
progress.worked(1);
}
示例9: gotoBookmark
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
public void gotoBookmark(BookmarkId bookmarkId, IProgressMonitor monitor) throws BookmarksException {
SubMonitor subMonitor = SubMonitor.convert(monitor, "Goto bookmark", 100);
Bookmark bookmark = bookmarkDatabase.getBookmarksTree().getBookmark(bookmarkId);
IBookmarkLocation bookmarkLocation = bookmarkLocationProvider.getBookmarkLocation(bookmark,
subMonitor.newChild(100));
if (bookmarkLocation == null) {
addGotoBookmarkProblem(bookmarkId);
checkBookmarkPropertiesProblem(bookmarkId);
throw new BookmarksException("Could not find bookmark");
}
Display.getDefault().asyncExec(() -> {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (gotoBookmark.gotoBookmark(workbenchWindow, bookmark, bookmarkLocation)) {
removeGotoBookmarkProblem(bookmarkId);
refreshMarker(bookmark);
postBookmarkVisited(bookmarkId);
WorkbenchPartSelection workbenchPartSelection = getWorkbenchPartSelection();
checkBookmarkPropertiesProblem(bookmarkId, workbenchPartSelection);
} else {
addGotoBookmarkProblem(bookmarkId);
checkBookmarkPropertiesProblem(bookmarkId);
}
});
}
示例10: runInUIThread
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
List<ReferenceSearchViewTreeNode> nodes;
synchronized (batchAddNodes) {
nodes = Lists.newArrayList(batchAddNodes);
batchAddNodes.clear();
}
SubMonitor progress = SubMonitor.convert(monitor, nodes.size());
for (ReferenceSearchViewTreeNode node : nodes) {
viewer.add(viewer.getInput(), node);
progress.worked(1);
}
viewer.refresh();
if (!batchAddNodes.isEmpty()) {
schedule(JOB_RESCHEDULE_DELAY);
} else {
isUIUpdateScheduled = false;
}
return Status.OK_STATUS;
}
示例11: 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);
}
}
}
示例12: addBookmarkProperties
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public void addBookmarkProperties(Map<String, String> bookmarkProperties, IWorkbenchPart part, ISelection selection,
IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
Object selected = getFirstElement(selection);
if (!(selected instanceof URL)) {
return;
}
URL url = (URL) selected;
putIfAbsent(bookmarkProperties, PROP_URL, url.toString());
if (!isPresent(bookmarkProperties, PROPERTY_NAME) || !isPresent(bookmarkProperties, PROP_ICON)) {
Optional<Document> document = parse(url, subMonitor.newChild(50));
if (document.isPresent()) {
getTitle(document.get()).ifPresent(title -> putIfAbsent(bookmarkProperties, PROPERTY_NAME, title));
getFavIconAsBase64(url, document.get(), subMonitor.newChild(50))
.ifPresent(favIcon -> putIfAbsent(bookmarkProperties, PROP_ICON, favIcon));
} else {
getFavIconUrl(url).flatMap(u -> getFavIconAsBase64(u, subMonitor.newChild(50)))
.ifPresent(favIcon -> putIfAbsent(bookmarkProperties, PROP_ICON, favIcon));
}
}
putIfAbsent(bookmarkProperties, PROPERTY_NAME, url.toString());
}
示例13: stage
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public IStatus stage(IPath stagingDirectory, IPath safeWorkDirectory,
MessageConsoleStream stdoutOutputStream, MessageConsoleStream stderrOutputStream,
IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
boolean result = stagingDirectory.toFile().mkdirs();
if (!result) {
return StatusUtil.error(this, "Could not create staging directory " + stagingDirectory);
}
try {
IPath deployArtifact = getDeployArtifact(safeWorkDirectory, subMonitor.newChild(40));
CloudSdkStagingHelper.stageFlexible(appEngineDirectory, deployArtifact, stagingDirectory,
subMonitor.newChild(60));
return Status.OK_STATUS;
} catch (AppEngineException | CoreException ex) {
return StatusUtil.error(this, Messages.getString("deploy.job.staging.failed"), ex);
} finally {
subMonitor.done();
}
}
示例14: 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;
}
示例15: refreshOutputFolders
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
* @see #refreshOutputFolders(org.eclipse.xtext.builder.IXtextBuilderParticipant.IBuildContext, Map,
* IProgressMonitor)
*/
protected void refreshOutputFolders(IProject project, Map<String, OutputConfiguration> outputConfigurations,
IProgressMonitor monitor) throws CoreException {
SubMonitor subMonitor = SubMonitor.convert(monitor, outputConfigurations.size());
for (OutputConfiguration config : outputConfigurations.values()) {
SubMonitor child = subMonitor.newChild(1);
IContainer container = getContainer(project, config.getOutputDirectory());
if (null != container) {
container.refreshLocal(IResource.DEPTH_INFINITE, child);
}
}
}