List of usage examples for org.eclipse.jdt.core JavaCore addElementChangedListener
public static void addElementChangedListener(IElementChangedListener listener)
From source file:com.blackducksoftware.integration.eclipseplugin.startup.Activator.java
License:Apache License
@Override public void start(final BundleContext context) throws Exception { super.start(context); System.out.println("STARTING HUB ECLIPSE PLUGIN"); plugin = this; final FilePathGavExtractor extractor = new FilePathGavExtractor(); final DependencyInformationService depService = new DependencyInformationService(); final ProjectInformationService projService = new ProjectInformationService(depService, extractor); final WorkspaceInformationService workspaceService = new WorkspaceInformationService(projService); securePrefService = new SecurePreferencesService(SecurePreferenceNodes.BLACK_DUCK, SecurePreferencesFactory.getDefault()); connectionService = new HubRestConnectionService(getInitialHubConnection()); componentCache = new ComponentCache(COMPONENT_CACHE_CAPACITY, depService); information = new ProjectDependencyInformation(projService, workspaceService, componentCache); final PreferencesService defaultPrefService = new PreferencesService(getPlugin().getPreferenceStore()); newJavaProjectListener = new NewJavaProjectListener(defaultPrefService, information); defaultPrefChangeListener = new DefaultPreferenceChangeListener(defaultPrefService, workspaceService); depsChangedListener = new ProjectDependenciesChangedListener(information, extractor, depService); javaProjectDeletedListener = new JavaProjectDeletedListener(information); ResourcesPlugin.getWorkspace().addResourceChangeListener(newJavaProjectListener); ResourcesPlugin.getWorkspace().addResourceChangeListener(javaProjectDeletedListener, IResourceChangeEvent.PRE_DELETE); getPreferenceStore().addPropertyChangeListener(defaultPrefChangeListener); JavaCore.addElementChangedListener(depsChangedListener); defaultPrefService.setDefaultConfig(); information.inspectAllProjects();/*from w ww . j av a 2 s. com*/ }
From source file:com.cisco.yangide.core.model.YangModelManager.java
License:Open Source License
public void startup() throws CoreException { try {/*w ww . ja va2 s . c o m*/ // initialize Yang model cache, 5000 is default value for JDT openable cache this.cache = new OpenableElementCache(5000); this.indexManager = new IndexManager(); this.deltaProcessor = new DeltaProcessor(this); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); workspace.addResourceChangeListener(deltaProcessor, /* * update spec in JavaCore#addPreProcessingResourceChangedListener(...) if adding more * event types */ IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.POST_BUILD | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_REFRESH); // Register for JDT Class path changes. JavaCore.addElementChangedListener(deltaProcessor); // start indexing if (this.indexManager != null) { this.indexManager.reset(); } // init projects yangModel.getYangProjects(); Job processSavedState = new Job("Processing Yang changes since last activation") { @Override protected IStatus run(IProgressMonitor monitor) { try { workspace.run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor progress) throws CoreException { ISavedState savedState = workspace.addSaveParticipant(YangCorePlugin.PLUGIN_ID, YangModelManager.this); if (savedState != null) { // the event type coming from the saved state is always // POST_AUTO_BUILD // force it to be POST_CHANGE so that the delta processor can // handle it YangModelManager.this.deltaProcessor.overridenEventType = IResourceChangeEvent.POST_CHANGE; savedState.processResourceChangeEvents(YangModelManager.this.deltaProcessor); } } }, monitor); } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; } }; processSavedState.setSystem(true); processSavedState.setPriority(Job.SHORT); // process asap processSavedState.schedule(); } catch (RuntimeException e) { e.printStackTrace(); shutdown(); throw e; } }
From source file:com.github.elucash.lambda4jdt.FoldingStructureProvider.java
License:Open Source License
/** * Called whenever projection is enabled, for example when the viewer issues a * {@link IProjectionListener#projectionEnabled() projectionEnabled} message. When the provider * is already enabled when this method is called, it is first {@link #handleProjectionDisabled() * disabled}./* ww w .j a v a 2 s.c om*/ * <p> * Subclasses may extend. * </p> */ protected void handleProjectionEnabled() { // http://home.ott.oti.com/teams/wswb/anon/out/vms/index.html // projectionEnabled messages are not always paired with projectionDisabled // i.e. multiple enabled messages may be sent out. // we have to make sure that we disable first when getting an enable // message. handleProjectionDisabled(); if (isInstalled()) { initialize(); fElementListener = new ElementChangedListener(); JavaCore.addElementChangedListener(fElementListener); } }
From source file:com.google.gdt.eclipse.core.ClasspathUtilities.java
License:Open Source License
/** * Waits indefinitely until the given classpath entries are on the given * project's raw classpath.// www . j av a 2 s. c o m * * @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); } } }
From source file:com.google.gdt.eclipse.core.sdk.WebInfFolderUpdater.java
License:Open Source License
/** * Starts listening for changes to update the WEB-INF/lib folder. */ public void start() { JavaCore.addElementChangedListener(classpathChangedListener); }
From source file:com.google.gdt.eclipse.managedapis.impl.ManagedApiProjectImpl.java
License:Open Source License
private void startListeningForManagedApiChanges() { synchronized (this) { if (listener == null) { listener = new ManagedApiChangeListener() { @Override// w w w . ja v a2s .co m public void managedApiProjectClosed() { } @Override public void managedApiProjectRemoved() { stopListeningForManagedApiChanges(); } @Override public void managedApiRemoved(ManagedApiImpl[] removedManagedApis) { try { notifyUninstalled(removedManagedApis, new NullProgressMonitor()); } catch (ExecutionException e) { ManagedApiLogger.warn(e, "Error removing APIs"); } } }; listener.setManagedApiProject(this); JavaCore.addElementChangedListener(listener); } } }
From source file:com.ifedorenko.m2e.sourcelookup.internal.JavaProjectSources.java
License:Open Source License
public void initialize() throws CoreException { JavaCore.addElementChangedListener(this); final IJavaModel javaModel = JavaCore.create(root); final IJavaProject[] javaProjects = javaModel.getJavaProjects(); synchronized (lock) { // not sure if synchronized is a good idea here // on one hand, this is the easiest way to guarantee async change events won't corrupt cache // but it can result in deadlocks if java model and change event delivery is synchronized internally. // note to self: if deadlocks, change events should be processed by background thread for (IJavaProject project : javaProjects) { addJavaProject(project);/* w w w . j a v a2s. com*/ } } }
From source file:com.iw.plugins.spindle.editors.actions.JumpToJavaAction.java
License:Mozilla Public License
public JumpToJavaAction() { super(); JavaCore.addElementChangedListener(this); }
From source file:com.javadude.dependencies.editparts.WorkspaceRootEditPart.java
License:Open Source License
public WorkspaceRootEditPart() { JavaCore.addElementChangedListener(new IElementChangedListener() { public void elementChanged(final ElementChangedEvent event) { Display.getDefault().asyncExec(new Runnable() { public void run() { //get the workspace changes from the ElementChangedEvent IJavaElementDelta[] changedChildren = event.getDelta().getAffectedChildren(); boolean refreshProjects = false; for (int i = 0; i < changedChildren.length; i++) { IJavaElementDelta delta = changedChildren[i]; //If the changed element is a java project if (delta.getElement() instanceof IJavaProject) { refreshProjects = true; }/*from w w w . j a v a 2 s. co m*/ } refresh(); if (refreshProjects) { for (@SuppressWarnings("rawtypes") Iterator iter = getChildren().iterator(); iter.hasNext();) { AbstractGraphicalEditPart editPart = (AbstractGraphicalEditPart) iter.next(); editPart.refresh(); } } } }); } }); }
From source file:com.mountainminds.eclemma.internal.core.EclEmmaCorePlugin.java
License:Open Source License
public void start(BundleContext context) throws Exception { super.start(context); sessionManager = new SessionManager(); coverageLoader = new JavaCoverageLoader(sessionManager); stateFiles = new StateFiles(getStateLocation()); stateFiles.deleteTemporaryFiles();//from w w w . ja v a 2 s . co m DebugPlugin.getDefault().getLaunchManager().addLaunchListener(launchListener); DebugPlugin.getDefault().addDebugEventListener(debugListener); JavaCore.addElementChangedListener(elementListener); instance = this; }