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

The following examples show how to use org.eclipse.jdt.core.JavaCore#addElementChangedListener() . 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: EventManager.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public void enableListeners() {

		JavaCore.addElementChangedListener(new ClasspathChangeListener(), ElementChangedEvent.POST_CHANGE);

		subscribeResourceListener();
		subscribeWindowListener();
		subscribeEclipseCloseListener();
		subscribeLaunchListener();
	}
 
Example 3
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 4
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 5
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 6
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);
}
 
Example 7
Source File: JavaOutlinePage.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) {
	boolean isCU= (newInput instanceof ICompilationUnit);

	if (isCU && fListener == null) {
		fListener= new ElementChangedListener();
		JavaCore.addElementChangedListener(fListener);
	} else if (!isCU && fListener != null) {
		JavaCore.removeElementChangedListener(fListener);
		fListener= null;
	}
}
 
Example 8
Source File: AbstractJavaProjectsState.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void registerAsListener() {
	super.registerAsListener();
	JavaCore.addElementChangedListener(this);
}
 
Example 9
Source File: JavaCoreListenerRegistrar.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
	JavaCore.addElementChangedListener(classpathChangeListener);
	storage2UriMapperJavaImpl.asyncInitializeCache();
	JavaCore.addElementChangedListener(storage2UriMapperJavaImpl);
}
 
Example 10
Source File: ClasspathUpdateHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public void addElementChangeListener() {
	JavaCore.addElementChangedListener(this);
}
 
Example 11
Source File: Storage2UriMapperJavaImplTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  this.storage2UriMapperJava = this.createFreshStorage2UriMapper();
  JavaCore.addElementChangedListener(this.storage2UriMapperJava);
}
 
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: Activator.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void start(BundleContext context) {
  JavaCore.addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE);
}
 
Example 14
Source File: ElementChangeListener.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Starts tracking element changes.
 */
void start() {
  JavaCore.addElementChangedListener(this, ElementChangedEvent.POST_CHANGE);
}
 
Example 15
Source File: CloneRefactoringAction.java    From JDeodorant with MIT License 4 votes vote down vote up
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
	this.part = targetPart;
	JavaCore.addElementChangedListener(ElementChangedListener.getInstance());
}
 
Example 16
Source File: JavaBrowsingContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public JavaBrowsingContentProvider(boolean provideMembers, JavaBrowsingPart browsingPart) {
	super(provideMembers);
	fBrowsingPart= browsingPart;
	fViewer= fBrowsingPart.getViewer();
	JavaCore.addElementChangedListener(this);
}
 
Example 17
Source File: SliceProfileAction.java    From JDeodorant with MIT License 4 votes vote down vote up
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
	this.part = targetPart;
	JavaCore.addElementChangedListener(ElementChangedListener.getInstance());
}
 
Example 18
Source File: JavaStructureDiffViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public JavaStructureDiffViewer(Composite parent, CompareConfiguration configuration) {
	super(parent, configuration);
	fStructureCreator= new JavaStructureCreator();
	setStructureCreator(fStructureCreator);
	JavaCore.addElementChangedListener(this);
}
 
Example 19
Source File: SearchResultUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public SearchResultUpdater(JavaSearchResult result) {
	fResult= result;
	NewSearchUI.addQueryListener(this);
	JavaCore.addElementChangedListener(this);
	// TODO make this work with resources
}
 
Example 20
Source File: ClassFileDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Installs the synchronizer.
 */
public void install() {
	JavaCore.addElementChangedListener(this);
}