Java Code Examples for org.eclipse.jdt.internal.ui.JavaPlugin#getWorkspace()

The following examples show how to use org.eclipse.jdt.internal.ui.JavaPlugin#getWorkspace() . 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: JavaReconciler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void uninstall() {

	IWorkbenchPartSite site= fTextEditor.getSite();
	IWorkbenchWindow window= site.getWorkbenchWindow();
	window.getPartService().removePartListener(fPartListener);
	fPartListener= null;

	Shell shell= window.getShell();
	if (shell != null && !shell.isDisposed())
		shell.removeShellListener(fActivationListener);
	fActivationListener= null;

	JavaCore.removeElementChangedListener(fJavaElementChangedListener);
	fJavaElementChangedListener= null;

	IWorkspace workspace= JavaPlugin.getWorkspace();
	workspace.removeResourceChangeListener(fResourceChangeListener);
	fResourceChangeListener= null;

	JavaPlugin.getDefault().getCombinedPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
	fPropertyChangeListener= null;

	super.uninstall();
}
 
Example 2
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("synthetic-access")
@Override
public void update(Observable observable, Object arg) {
	try {
		final IWorkspace workspace = JavaPlugin.getWorkspace();
		final String name = MainProjectWizardPage.this.nameGroup.getName();
		checkProjectName(workspace, name);
		final IProject handle = checkProjectExist(workspace, name);
		final String location = MainProjectWizardPage.this.locationGroup.getLocation().toOSString();
		final IPath projectPath = checkLocationSyntax(location);
		validateLocation(workspace, handle, projectPath);

		setErrorMessage(null);
		setMessage(null);
		setPageComplete(true);

	} catch (ValidationException e) {
		setMessage(e.getMessage());
		setErrorMessage(e.getErrorMessage());
		setPageComplete(false);
	}
}
 
Example 3
Source File: JarOptionsPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the resource for the specified path.
 *
 * @param path	the path for which the resource should be returned
 * @return the resource specified by the path or <code>null</code>
 */
protected IResource findResource(IPath path) {
	IWorkspace workspace= JavaPlugin.getWorkspace();
	IStatus result= workspace.validatePath(
						path.toString(),
						IResource.ROOT | IResource.PROJECT | IResource.FOLDER | IResource.FILE);
	if (result.isOK() && workspace.getRoot().exists(path))
		return workspace.getRoot().findMember(path);
	return null;
}
 
Example 4
Source File: JarManifestWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the resource for the specified path.
 *
 * @param path	the path for which the resource should be returned
 * @return the resource specified by the path or <code>null</code>
 */
protected IResource findResource(IPath path) {
	IWorkspace workspace= JavaPlugin.getWorkspace();
	IStatus result= workspace.validatePath(
						path.toString(),
						IResource.ROOT | IResource.PROJECT | IResource.FOLDER | IResource.FILE);
	if (result.isOK() && workspace.getRoot().exists(path))
		return workspace.getRoot().findMember(path);
	return null;
}
 
Example 5
Source File: JavaReconciler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void install(ITextViewer textViewer) {
	super.install(textViewer);

	fPartListener= new PartListener();
	IWorkbenchPartSite site= fTextEditor.getSite();
	IWorkbenchWindow window= site.getWorkbenchWindow();
	window.getPartService().addPartListener(fPartListener);

	fActivationListener= new ActivationListener(textViewer.getTextWidget());
	Shell shell= window.getShell();
	shell.addShellListener(fActivationListener);

	fJavaElementChangedListener= new ElementChangedListener();
	JavaCore.addElementChangedListener(fJavaElementChangedListener);

	fResourceChangeListener= new ResourceChangeListener();
	IWorkspace workspace= JavaPlugin.getWorkspace();
	workspace.addResourceChangeListener(fResourceChangeListener);

	fPropertyChangeListener= new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			if (SpellingService.PREFERENCE_SPELLING_ENABLED.equals(event.getProperty()) || SpellingService.PREFERENCE_SPELLING_ENGINE.equals(event.getProperty()))
				forceReconciling();
		}
	};
	JavaPlugin.getDefault().getCombinedPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);

	fReconciledElement= EditorUtility.getEditorInputJavaElement(fTextEditor, false);
}