Java Code Examples for org.eclipse.jdt.core.JavaCore#removeElementChangedListener()

The following examples show how to use org.eclipse.jdt.core.JavaCore#removeElementChangedListener() . 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: TypeHierarchyLifeCycle.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void doHierarchyRefresh(IJavaElement[] elements, IProgressMonitor pm) throws JavaModelException {
	boolean hierachyCreationNeeded= (fHierarchy == null || !Arrays.equals(elements, fInputElements));
	// to ensure the order of the two listeners always remove / add listeners on operations
	// on type hierarchies
	if (fHierarchy != null) {
		fHierarchy.removeTypeHierarchyChangedListener(this);
		JavaCore.removeElementChangedListener(this);
	}
	if (hierachyCreationNeeded) {
		fHierarchy= createTypeHierarchy(elements, pm);
		if (pm != null && pm.isCanceled()) {
			throw new OperationCanceledException();
		}
		fInputElements= elements;
	} else {
		fHierarchy.refresh(pm);
		if (pm != null && pm.isCanceled())
			throw new OperationCanceledException();
	}
	fHierarchy.addTypeHierarchyChangedListener(this);
	JavaCore.addElementChangedListener(this);
	fHierarchyRefreshNeeded= false;
}
 
Example 2
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 3
Source File: JavaEditorExtension.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public String waitForElementChangedEvent(final int eventMask, final Procedure0 producer) {
  String _xblockexpression = null;
  {
    if ((JavaEditorExtension.VERBOSE).booleanValue()) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("start waiting for an element changed event: ");
      _builder.append(eventMask);
      InputOutput.<String>println(_builder.toString());
    }
    final ArrayList<Boolean> changed = CollectionLiterals.<Boolean>newArrayList(Boolean.valueOf(false));
    final IElementChangedListener _function = new IElementChangedListener() {
      @Override
      public void elementChanged(final ElementChangedEvent it) {
        JavaCore.removeElementChangedListener(this);
        Boolean _head = IterableExtensions.<Boolean>head(changed);
        boolean _not = (!(_head).booleanValue());
        if (_not) {
          changed.set(0, Boolean.valueOf(true));
          if ((JavaEditorExtension.VERBOSE).booleanValue()) {
            InputOutput.<ElementChangedEvent>println(it);
          }
        }
      }
    };
    JavaCore.addElementChangedListener(_function, eventMask);
    producer.apply();
    while ((!(IterableExtensions.<Boolean>head(changed)).booleanValue())) {
    }
    String _xifexpression = null;
    if ((JavaEditorExtension.VERBOSE).booleanValue()) {
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("end waiting for an element changed event: ");
      _builder_1.append(eventMask);
      _xifexpression = InputOutput.<String>println(_builder_1.toString());
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
Example 4
Source File: PackageExplorerContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
	super.inputChanged(viewer, oldInput, newInput);
	fViewer= (TreeViewer)viewer;
	if (oldInput == null && newInput != null) {
		JavaCore.addElementChangedListener(this);
	} else if (oldInput != null && newInput == null) {
		JavaCore.removeElementChangedListener(this);
	}
	fInput= newInput;
}
 
Example 5
Source File: JavaWorkingSetUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void dispose() {
	synchronized(fWorkingSets) {
		fWorkingSets.clear();
	}
	JavaCore.removeElementChangedListener(this);
}
 
Example 6
Source File: LogicalPackagesProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
	if (newInput != null) {
		JavaCore.addElementChangedListener(this);
	} else {
		JavaCore.removeElementChangedListener(this);
	}
	fInputIsProject= (newInput instanceof IJavaProject);

	if(viewer instanceof StructuredViewer)
		fViewer= (StructuredViewer)viewer;
}
 
Example 7
Source File: ListenerRegistrar.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void discard() {
	JavaCore.removeElementChangedListener(javaChangeQueueFiller);

	JavaCore.removeElementChangedListener(typeResourceUnloader);
	typeResourceUnloader.removeListener(eventBroker);
}
 
Example 8
Source File: PlatformHolder.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 4 votes vote down vote up
void clear() {
	JavaCore.removeElementChangedListener(classpathChagedListener);
	currentPlatform = null;
	addResourceChangeListenerToWorkspace();
}
 
Example 9
Source File: ClasspathUpdateHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public void removeElementChangeListener() {
	JavaCore.removeElementChangedListener(this);
}
 
Example 10
Source File: AbstractJavaProjectsState.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void unregisterAsListener() {
	JavaCore.removeElementChangedListener(this);
	super.unregisterAsListener();
}
 
Example 11
Source File: JavaBrowsingContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void dispose() {
	super.dispose();
	JavaCore.removeElementChangedListener(this);
}
 
Example 12
Source File: ClasspathUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Waits indefinitely until the given classpath entries are on the given
 * project's raw classpath.
 *
 * @throws JavaModelException
 * @throws InterruptedException
 */
public static void waitUntilEntriesAreOnClasspath(
    final IJavaProject javaProject,
    final List<IClasspathEntry> classpathEntries) throws JavaModelException,
    InterruptedException {

  // Used to notify when we are finished -- either all entries are on the
  // classpath or the anon class had an exception
  final Object finished = new Object();
  final JavaModelException[] anonClassException = new JavaModelException[1];

  ClasspathChangedListener listener = new ClasspathChangedListener() {
    @Override
    protected void classpathChanged(IJavaProject curJavaProject) {
      synchronized (finished) {
        try {
          if (curJavaProject.equals(javaProject)
              && areEntriesOnClasspath(javaProject, classpathEntries)) {
            finished.notifyAll();
          }
        } catch (JavaModelException e) {
          anonClassException[0] = e;
          finished.notifyAll();
        }
      }
    }
  };

  synchronized (finished) {
    JavaCore.addElementChangedListener(listener);

    try {
      // We're in a state where either the entries already exist on the
      // classpath, or we have a callback queued up (because of the
      // synchronization on finished) that will notify us when they are added.
      while (!areEntriesOnClasspath(javaProject, classpathEntries)) {
        finished.wait();
      }

      if (anonClassException[0] != null) {
        throw anonClassException[0];
      }
    } finally {
      JavaCore.removeElementChangedListener(listener);
    }
  }
}
 
Example 13
Source File: WebInfFolderUpdater.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Stops listening for changes.
 */
public void stop() {
  JavaCore.removeElementChangedListener(classpathChangedListener);
}
 
Example 14
Source File: ElementChangeListener.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Stops tracking element changes.
 */
void stop() {
  JavaCore.removeElementChangedListener(this);
}
 
Example 15
Source File: OpenTypeHistory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void doShutdown() {
	JavaCore.removeElementChangedListener(fDeltaListener);
	save();
}
 
Example 16
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void dispose() {
	if (fListener != null) {
		JavaCore.removeElementChangedListener(fListener);
		fListener= null;
	}
}
 
Example 17
Source File: DuplicatedCode.java    From JDeodorant with MIT License 4 votes vote down vote up
public void dispose() {
	super.dispose();
	getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(selectionListener);
	JavaCore.removeElementChangedListener(elementChangedListener);
}
 
Example 18
Source File: ClassFileDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Uninstalls the synchronizer.
 */
public void uninstall() {
	JavaCore.removeElementChangedListener(this);
}
 
Example 19
Source File: PackageExplorerContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void dispose() {
	super.dispose();
	JavaCore.removeElementChangedListener(this);
	JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
}
 
Example 20
Source File: Activator.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void stop(BundleContext context) {
  JavaCore.removeElementChangedListener(listener);
}