Java Code Examples for org.eclipse.ui.preferences.IWorkbenchPreferenceContainer#registerUpdateJob()

The following examples show how to use org.eclipse.ui.preferences.IWorkbenchPreferenceContainer#registerUpdateJob() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: N4JSBuilderPreferencePage.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This method has been copied from org.eclipse.xtext.builder.preferences.BuilderPreferencePage.
 */
private void scheduleCleanerJob(IPreferencePageContainer preferencePageContainer, String folderNameToClean) {
	DerivedResourceCleanerJob derivedResourceCleanerJob = cleanerProvider.get();
	derivedResourceCleanerJob.setUser(true);
	derivedResourceCleanerJob.initialize(getProject(), folderNameToClean);
	if (preferencePageContainer != null) {
		IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
		container.registerUpdateJob(derivedResourceCleanerJob);
	} else {
		derivedResourceCleanerJob.schedule();
	}
}
 
Example 2
Source File: N4JSBuilderPreferencePage.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This method has been copied and adapted from org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock.
 */
@Override
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
	boolean needsBuild = !getPreferenceChanges().isEmpty() | projectSpecificChanged;
	boolean doBuild = false;
	if (needsBuild) {
		int count = getRebuildCount();
		if (count > rebuildCount) {
			needsBuild = false;
			rebuildCount = count;
		}
	}
	if (needsBuild) {
		String[] strings = getFullBuildDialogStrings(project == null);
		if (strings != null) {
			MessageDialog dialog = new MessageDialog(this.getShell(), strings[0], null, strings[1],
					MessageDialog.QUESTION,
					new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
							IDialogConstants.CANCEL_LABEL },
					2);
			int res = dialog.open();
			if (res == 0) {
				doBuild = true;
			} else if (res != 1) {
				return false;
			}
		}
	}
	if (container != null) {
		if (doBuild) {
			incrementRebuildCount();
			container.registerUpdateJob(getBuildJob(getProject()));
		}
	} else {
		if (doBuild) {
			getBuildJob(getProject()).schedule();
		}
	}
	return true;
}
 
Example 3
Source File: OptionsConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
	boolean needsBuild = buildPreferenceEvaluator.isAffectingBuild(getPreferenceChanges());
	boolean doBuild = false;
	if (needsBuild) {
		int count = getRebuildCount();
		if (count > rebuildCount) {
			needsBuild = false;
			rebuildCount = count;
		}
	}
	if (needsBuild) {
		String[] strings = getFullBuildDialogStrings(project == null);
		if (strings != null) {
			MessageDialog dialog = new MessageDialog(shell, strings[0], null, strings[1], MessageDialog.QUESTION,
					new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
							IDialogConstants.CANCEL_LABEL }, 2);
			int res = dialog.open();
			if (res == 0) {
				doBuild = true;
			} else if (res != 1) {
				return false;
			}
		}
	}
	savePreferences();
	if (container != null) {
		if (doBuild) {
			incrementRebuildCount();
			container.registerUpdateJob(getBuildJob(getProject()));
		}
	} else {
		if (doBuild) {
			getBuildJob(getProject()).schedule();
		}
	}
	captureOriginalSettings(keys);
	return true;
}
 
Example 4
Source File: BuilderPreferencePage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void scheduleCleanerJob(IPreferencePageContainer preferencePageContainer, String folderNameToClean) {
	DerivedResourceCleanerJob derivedResourceCleanerJob = cleanerProvider.get();
	derivedResourceCleanerJob.setUser(true);
	derivedResourceCleanerJob.initialize(getProject(), folderNameToClean);
	if (preferencePageContainer != null) {
		IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
		container.registerUpdateJob(derivedResourceCleanerJob);
	} else {
		derivedResourceCleanerJob.schedule();
	}
}
 
Example 5
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
	IScopeContext currContext= fLookupOrder[0];


	List<Key> changedOptions= new ArrayList<Key>();
	boolean needsBuild= getChanges(currContext, changedOptions);
	if (changedOptions.isEmpty()) {
		return true;
	}
	if (needsBuild) {
		int count= getRebuildCount();
		if (count > fRebuildCount) {
			needsBuild= false; // build already requested
			fRebuildCount= count;
		}
	}

	boolean doBuild= false;
	if (needsBuild) {
		String[] strings= getFullBuildDialogStrings(fProject == null);
		if (strings != null) {
			if (ResourcesPlugin.getWorkspace().getRoot().getProjects().length == 0) {
				doBuild= true; // don't bother the user
			} else {
				MessageDialog dialog= new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
				int res= dialog.open();
				if (res == 0) {
					doBuild= true;
				} else if (res != 1) {
					return false; // cancel pressed
				}
			}
		}
	}
	if (container != null) {
		// no need to apply the changes to the original store: will be done by the page container
		if (doBuild) { // post build
			incrementRebuildCount();
			container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
		}
	} else {
		// apply changes right away
		try {
			fManager.applyChanges();
		} catch (BackingStoreException e) {
			JavaPlugin.log(e);
			return false;
		}
		if (doBuild) {
			CoreUtility.getBuildJob(fProject).schedule();
		}

	}
	return true;
}