本文整理匯總了Java中org.eclipse.core.runtime.SubMonitor.newChild方法的典型用法代碼示例。如果您正苦於以下問題:Java SubMonitor.newChild方法的具體用法?Java SubMonitor.newChild怎麽用?Java SubMonitor.newChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.runtime.SubMonitor
的用法示例。
在下文中一共展示了SubMonitor.newChild方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureResourceSet
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
private static void configureResourceSet(ResourceSet rs, URI modelURI, HashMap<String, String> nsURIMapping,
SubMonitor subMonitor) {
subMonitor.subTask("Configuring ResourceSet");
subMonitor.newChild(1);
final String fileExtension = modelURI.fileExtension();
// indicates which melange query should be added to the xml uri handler
// for a given extension
// use to resolve cross ref URI during XMI parsing
final XMLURIHandler handler = new XMLURIHandler(modelURI.query(), fileExtension);
handler.setResourceSet(rs);
rs.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, handler);
final MelangeURIConverter converter = new MelangeURIConverter(nsURIMapping);
rs.setURIConverter(converter);
// fix sirius to prevent non intentional model savings
converter.getURIHandlers().add(0, new DebugURIHandler(converter.getURIHandlers()));
}
示例2: resolveLibraryFiles
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
private LibraryClasspathContainer resolveLibraryFiles(IJavaProject javaProject,
IPath containerPath, Library library, List<Job> sourceAttacherJobs, IProgressMonitor monitor)
throws CoreException {
List<LibraryFile> libraryFiles = library.getAllDependencies();
SubMonitor subMonitor = SubMonitor.convert(monitor, libraryFiles.size());
subMonitor.subTask(Messages.getString("TaskResolveArtifacts", getLibraryDescription(library)));
SubMonitor child = subMonitor.newChild(libraryFiles.size());
List<IClasspathEntry> entries = new ArrayList<>();
for (LibraryFile libraryFile : libraryFiles) {
IClasspathEntry newLibraryEntry = resolveLibraryFileAttachSourceAsync(javaProject,
containerPath, libraryFile, sourceAttacherJobs, monitor);
entries.add(newLibraryEntry);
child.worked(1);
}
monitor.done();
LibraryClasspathContainer container = new LibraryClasspathContainer(
containerPath, getLibraryDescription(library), entries, libraryFiles);
return container;
}
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:23,代碼來源:LibraryClasspathContainerResolverService.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);
}
}
}
}
示例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);
}
}
}
}
示例5: 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);
}
}
}
示例6: applyDiff
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
protected void applyDiff ( final IProgressMonitor parentMonitor ) throws InterruptedException, ExecutionException
{
final SubMonitor monitor = SubMonitor.convert ( parentMonitor, 100 );
monitor.setTaskName ( Messages.ImportWizard_TaskName );
final Collection<DiffEntry> result = this.mergeController.merge ( wrap ( monitor.newChild ( 10 ) ) );
if ( result.isEmpty () )
{
monitor.done ();
return;
}
final Iterable<List<DiffEntry>> splitted = Iterables.partition ( result, Activator.getDefault ().getPreferenceStore ().getInt ( PreferenceConstants.P_DEFAULT_CHUNK_SIZE ) );
final SubMonitor sub = monitor.newChild ( 90 );
try
{
final int size = Iterables.size ( splitted );
sub.beginTask ( Messages.ImportWizard_TaskName, size );
int pos = 0;
for ( final Iterable<DiffEntry> i : splitted )
{
sub.subTask ( String.format ( Messages.ImportWizard_SubTaskName, pos, size ) );
final List<DiffEntry> entries = new LinkedList<DiffEntry> ();
Iterables.addAll ( entries, i );
final NotifyFuture<Void> future = this.connection.getConnection ().applyDiff ( entries, null, new DisplayCallbackHandler ( getShell (), "Apply diff", "Confirmation for applying diff is required" ) );
future.get ();
pos++;
sub.worked ( 1 );
}
}
finally
{
sub.done ();
}
}
示例7: run
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
SubMonitor pm = SubMonitor.convert(monitor,
Messages.diffPresentationPane_getting_changes_for_diff, 100); // 0
SubMonitor jobMonitor = pm.newChild(80); // 80
DbSourceJob srcJob = new DbSourceJob(dbSource, jobMonitor);
DbSourceJob tgtJob = new DbSourceJob(dbTarget, jobMonitor);
srcJob.schedule();
tgtJob.schedule();
IStatus srcResult, tgtResult;
do {
Thread.sleep(JOB_CHECK_MS);
srcResult = srcJob.getResult();
tgtResult = tgtJob.getResult();
} while (srcResult == null && tgtResult == null);
if (srcResult != null) {
finishJobs(srcJob, tgtJob);
} else {
finishJobs(tgtJob, srcJob);
}
Log.log(Log.LOG_INFO, "Generating diff tree between src: " + dbSource.getOrigin() //$NON-NLS-1$
+ " tgt: " + dbTarget.getOrigin()); //$NON-NLS-1$
pm.newChild(15).subTask(Messages.treeDiffer_building_diff_tree); // 95
diffTree = DiffTree.create(dbSource.getDbObject(), dbTarget.getDbObject(), pm);
if (needTwoWay){
Log.log(Log.LOG_INFO, "Generating diff tree between src: " + dbTarget.getOrigin() //$NON-NLS-1$
+ " tgt: " + dbSource.getOrigin()); //$NON-NLS-1$
pm.newChild(3).subTask(Messages.TreeDiffer_reverting_tree); // 98
diffTreeRevert = diffTree.getRevertedCopy();
}
PgDiffUtils.checkCancelled(pm);
monitor.done();
}
示例8: initRepoFromSource
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
* clean repository, generate new file structure, preserve and fix repo
* metadata, repo rm/add, commit new revision
*/
private void initRepoFromSource(SubMonitor pm) throws InterruptedException,
CoreException, IOException {
SubMonitor taskpm = pm.newChild(25); // 50
PgDatabase db = src.get(taskpm);
pm.newChild(25).subTask(Messages.initProjectFromSource_exporting_db_model); // 75
new ProjectUpdater(db, null, null, proj).updateFull();
}
示例9: finalLaunchCheck
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode,
IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 40);
if (!super.finalLaunchCheck(configuration, mode, progress.newChild(20))) {
return false;
}
// If we're auto-publishing before launch, check if there may be stale
// resources not yet published. See
// https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1832
if (ServerCore.isAutoPublishing() && ResourcesPlugin.getWorkspace().isAutoBuilding()) {
// Must wait for any current autobuild to complete so resource changes are triggered
// and WTP will kick off ResourceChangeJobs. Note that there may be builds
// pending that are unrelated to our resource changes, so simply checking
// <code>JobManager.find(FAMILY_AUTO_BUILD).length > 0</code> produces too many
// false positives.
try {
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, progress.newChild(20));
} catch (InterruptedException ex) {
/* ignore */
}
IServer server = ServerUtil.getServer(configuration);
if (server.shouldPublish() || hasPendingChangesToPublish()) {
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
if (prompter != null) {
Object continueLaunch = prompter
.handleStatus(StaleResourcesStatusHandler.CONTINUE_LAUNCH_REQUEST, configuration);
if (!(Boolean) continueLaunch) {
// cancel the launch so Server.StartJob won't raise an error dialog, since the
// server won't have been started
monitor.setCanceled(true);
return false;
}
return true;
}
}
}
return true;
}
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:41,代碼來源:LocalAppEngineServerLaunchConfigurationDelegate.java
示例10: convert
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
protected void convert(MultiStatus status, IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, 100);
// Updating project before installing App Engine facet to avoid
// https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1155.
try {
GpeMigrator.removeObsoleteGpeRemnants(facetedProject, progress.newChild(20));
super.convert(status, progress.newChild(20));
} catch (CoreException ex) {
status.add(StatusUtil.error(this, "Unable to remove GPE remains", ex));
}
}
示例11: run
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
* Runs the operation in a blocking fashion.
*
* @param helper
* the build helper to get the injected services.
* @param project
* the project to clean/build.
* @param monitor
* monitor for the operation.
*/
private void run(final ExternalLibraryBuilderHelper helper, IProject project, IProgressMonitor monitor) {
checkArgument(project instanceof ExternalProject, "Expected external project: " + project);
final SubMonitor subMonitor = SubMonitor.convert(monitor, 2);
final ToBeBuiltComputer computer = helper.builtComputer;
final IProgressMonitor computeMonitor = subMonitor.newChild(1, SUPPRESS_BEGINTASK);
monitor.setTaskName("Collecting resource for '" + project.getName() + "'...");
final ToBeBuilt toBeBuilt = getToBeBuilt(computer, project, computeMonitor);
if (toBeBuilt.getToBeDeleted().isEmpty() && toBeBuilt.getToBeUpdated().isEmpty()) {
subMonitor.newChild(1, SUPPRESS_NONE).worked(1);
return;
}
try {
final IN4JSCore core = helper.core;
final QueuedBuildData queuedBuildData = helper.queuedBuildData;
final IBuilderState builderState = helper.builderState;
final ExternalProject externalProject = (ExternalProject) project;
final String path = externalProject.getExternalResource().getAbsolutePath();
final URI uri = URI.createFileURI(path);
final IN4JSProject n4Project = core.findProject(uri).orNull();
ResourceSet resourceSet = null;
try {
resourceSet = core.createResourceSet(Optional.of(n4Project));
if (!resourceSet.getLoadOptions().isEmpty()) {
resourceSet.getLoadOptions().clear();
}
resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
if (resourceSet instanceof ResourceSetImpl) {
((ResourceSetImpl) resourceSet).setURIResourceMap(newHashMap());
}
final BuildData buildData = new BuildData(
project.getName(),
resourceSet,
toBeBuilt,
queuedBuildData,
true /* indexingOnly */);
monitor.setTaskName("Building '" + project.getName() + "'...");
final IProgressMonitor buildMonitor = subMonitor.newChild(1, SUPPRESS_BEGINTASK);
builderState.update(buildData, buildMonitor);
} finally {
if (null != resourceSet) {
resourceSet.getResources().clear();
resourceSet.eAdapters().clear();
}
}
} catch (Exception e) {
final String message = "Error occurred while " + toString().toLowerCase() + "ing external library "
+ project.getName() + ".";
LOGGER.error(message, e);
throw new RuntimeException(message, e);
}
}
示例12: internal_configureProject
import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
public static void internal_configureProject(IProject project, SubMonitor subMonitor) throws Exception {
ClasspathManager.addGW4EClassPathContainer(project);
SubMonitor sm2 = subMonitor.newChild(10);
ResourceManager.ensureFolder(project, Constant.SOURCE_MAIN_JAVA, sm2);
ClasspathManager.ensureFolderInClasspath(project, Constant.SOURCE_MAIN_JAVA, sm2);
SubMonitor sm3 = subMonitor.newChild(10);
ResourceManager.ensureFolder(project, Constant.SOURCE_MAIN_RESOURCES, sm3);
ClasspathManager.ensureFolderInClasspath(project, Constant.SOURCE_MAIN_RESOURCES, sm3);
SubMonitor sm4 = subMonitor.newChild(10);
ResourceManager.ensureFolder(project, Constant.SOURCE_TEST_JAVA, sm4);
ClasspathManager.ensureFolderInClasspath(project, Constant.SOURCE_TEST_JAVA, sm4);
SubMonitor sm5 = subMonitor.newChild(10);
ResourceManager.ensureFolder(project, Constant.SOURCE_TEST_RESOURCES, sm5);
ClasspathManager.ensureFolderInClasspath(project, Constant.SOURCE_TEST_RESOURCES, sm5);
SubMonitor sm6 = subMonitor.newChild(10);
PreferenceManager.setDefaultPreference(project.getName());
// Graphs in src/main/resources will generate interfaces in
// target/generated-sources/
String targetMainFolderForInterface = getTargetFolderForTestInterface(project.getName(), true);
IPath targetMainFolderForInterfacePath = JDTManager.guessPackageRootFragment(project, true);
if (targetMainFolderForInterfacePath!=null) {
targetMainFolderForInterface= targetMainFolderForInterfacePath.makeRelativeTo(project.getFullPath()).toString();
}
//IResource resourceMain = ClasspathManager.childrenExistInClasspath(project, targetMainFolderForInterface, sm6);
//if (resourceMain == null) {
ResourceManager.ensureFolder(project, targetMainFolderForInterface, sm6);
ClasspathManager.ensureFolderInClasspath(project, targetMainFolderForInterface, sm6);
//}
// Graphs in src/test/resources will generate interfaces in
// target/generated-test-sources
String targetTestFolderForInterface = getTargetFolderForTestInterface(project.getName(), false);
IPath targetTestFolderForInterfacePath = JDTManager.guessPackageRootFragment(project, false);
if (targetTestFolderForInterfacePath!=null) {
targetTestFolderForInterface = targetTestFolderForInterfacePath.makeRelativeTo(project.getFullPath()).toString();
}
// IResource resourceTest = ClasspathManager.childrenExistInClasspath(project, targetTestFolderForInterface, sm6);
// if (resourceTest == null) {
ResourceManager.ensureFolder(project, targetTestFolderForInterface, sm6);
ClasspathManager.ensureFolderInClasspath(project, targetTestFolderForInterface, sm6);
// }
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
Arrays.sort(entries, new Comparator<IClasspathEntry>() {
@Override
public int compare(IClasspathEntry e1, IClasspathEntry e2) {
if (e1.getEntryKind() > e2.getEntryKind())
return 1;
if (e1.getEntryKind() < e2.getEntryKind())
return -1;
return e1.getPath().toString().compareTo(e2.getPath().toString());
}
});
javaProject.setRawClasspath(entries, null);
//
SubMonitor sm8 = subMonitor.newChild(10);
ClasspathManager.setBuilder(project, sm8);
//
if (targetMainFolderForInterfacePath != null) {
setTargetFolderForTestInterface(ResourceManager.getResource(targetMainFolderForInterfacePath.toString()), true);
}
if (targetTestFolderForInterfacePath != null) {
setTargetFolderForTestInterface(ResourceManager.getResource(targetTestFolderForInterfacePath.toString()), false);
}
ICompilationUnit[] interfaces = JDTManager.getOrCreateGeneratedTestInterfaces(project);
for (int i = 0; i < interfaces.length; i++) {
new TestConvertor(interfaces[i]).apply();
}
}