Search in sources :

Example 6 with IResourceChangeListener

use of org.eclipse.core.resources.IResourceChangeListener in project eclipse-cs by checkstyle.

the class AbstractStatsView method createPartControl.

// 
// methods
// 
/**
 * {@inheritDoc}
 *
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createPartControl(Composite parent) {
    mMainComposite = parent;
    // create and register the workspace focus listener
    mFocusListener = new ISelectionListener() {

        @Override
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
            AbstractStatsView.this.focusSelectionChanged(part, selection);
        }
    };
    getSite().getPage().addSelectionListener(mFocusListener);
    focusSelectionChanged(getSite().getPage().getActivePart(), getSite().getPage().getSelection());
    // create and register the listener for resource changes
    mResourceListener = new IResourceChangeListener() {

        @Override
        public void resourceChanged(IResourceChangeEvent event) {
            IMarkerDelta[] markerDeltas = event.findMarkerDeltas(CheckstyleMarker.MARKER_ID, true);
            if (markerDeltas.length > 0) {
                refresh();
            }
        }
    };
    ResourcesPlugin.getWorkspace().addResourceChangeListener(mResourceListener);
    makeActions();
    initActionBars(getViewSite().getActionBars());
}
Also used : IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) ISelectionListener(org.eclipse.ui.ISelectionListener)

Example 7 with IResourceChangeListener

use of org.eclipse.core.resources.IResourceChangeListener in project flux by eclipse.

the class Activator method initCoreService.

private void initCoreService(String userChannel) throws CoreException {
    repository = new Repository(messageConnector, userChannel);
    liveEditCoordinator = new LiveEditCoordinator(messageConnector);
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    resourceListener = new CloudSyncResourceListener(repository);
    workspace.addResourceChangeListener(resourceListener, IResourceChangeEvent.POST_CHANGE);
    metadataListener = new CloudSyncMetadataListener(repository);
    workspace.addResourceChangeListener(metadataListener, IResourceChangeEvent.POST_BUILD);
    this.repositoryListener = new IRepositoryListener() {

        @Override
        public void projectDisconnected(IProject project) {
            removeConnectedProjectPreference(project.getName());
        }

        @Override
        public void projectConnected(IProject project) {
            addConnectedProjectPreference(project.getName());
        }

        @Override
        public void resourceChanged(IResource resource) {
        // nothing
        }
    };
    getRepository().addRepositoryListener(repositoryListener);
    workspaceListener = new IResourceChangeListener() {

        public void resourceChanged(IResourceChangeEvent event) {
            if (event.getResource() instanceof IProject) {
                IResourceDelta delta = event.getDelta();
                if (delta == null) {
                    return;
                }
                if (delta.getKind() == IResourceDelta.REMOVED) {
                    IProject project = (IProject) event.getResource();
                    removeConnectedProjectPreference(project.getName());
                } else if (delta.getKind() == IResourceDelta.CHANGED) {
                // TODO, we aren't handling project renaming yet
                // IProject project = (IProject) event.getResource();
                // String oldName =
                // delta.getMovedFromPath().lastSegment();
                // removeConnectedProjectPreference(oldName);
                // addConnectedProjectPreference(project.getName());
                }
            }
        }
    };
    workspace.addResourceChangeListener(workspaceListener);
    updateProjectConnections();
}
Also used : IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) IWorkspace(org.eclipse.core.resources.IWorkspace) CloudSyncMetadataListener(org.eclipse.flux.core.internal.CloudSyncMetadataListener) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) CloudSyncResourceListener(org.eclipse.flux.core.internal.CloudSyncResourceListener) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 8 with IResourceChangeListener

use of org.eclipse.core.resources.IResourceChangeListener in project eclipse-pmd by acanda.

the class PMDPlugin method initWorkspaceModel.

private void initWorkspaceModel() {
    workspaceModel = new WorkspaceModel();
    final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    final ProjectModelRepository projectModelRepository = new ProjectModelRepository();
    for (final IProject project : projects) {
        final Optional<ProjectModel> model = projectModelRepository.load(project.getName());
        if (model.isPresent()) {
            workspaceModel.add(model.get());
        } else {
            workspaceModel.add(new ProjectModel(project.getName()));
        }
    }
    final IResourceChangeListener workspaceChangeListener = new WorkspaceChangeListener(workspaceModel, projectModelRepository);
    ResourcesPlugin.getWorkspace().addResourceChangeListener(workspaceChangeListener, IResourceChangeEvent.POST_CHANGE);
}
Also used : WorkspaceModel(ch.acanda.eclipse.pmd.domain.WorkspaceModel) ProjectModelRepository(ch.acanda.eclipse.pmd.repository.ProjectModelRepository) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) ProjectModel(ch.acanda.eclipse.pmd.domain.ProjectModel) IProject(org.eclipse.core.resources.IProject)

Example 9 with IResourceChangeListener

use of org.eclipse.core.resources.IResourceChangeListener in project erlide_eclipse by erlang.

the class ErlModel method setupWorkspaceListeners.

public final void setupWorkspaceListeners() {
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IPathVariableManager pvm = workspace.getPathVariableManager();
    pvm.addChangeListener(fPathVariableChangeListener);
    final IResourceChangeListener listener = new ResourceChangeListener();
    workspace.addResourceChangeListener(listener);
}
Also used : IPathVariableManager(org.eclipse.core.resources.IPathVariableManager) IWorkspace(org.eclipse.core.resources.IWorkspace) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener)

Example 10 with IResourceChangeListener

use of org.eclipse.core.resources.IResourceChangeListener in project che by eclipse.

the class RefactoringHistoryService method connect.

/**
	 * {@inheritDoc}
	 */
public void connect() {
    fReferenceCount++;
    if (fReferenceCount == 1) {
        fOperationListener = new IOperationHistoryListener() {

            public void historyNotification(final OperationHistoryEvent event) {
                performHistoryNotification(event);
            }
        };
        OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(fOperationListener);
        fResourceListener = new IResourceChangeListener() {

            public void resourceChanged(final IResourceChangeEvent event) {
                peformResourceChanged(event);
            }
        };
        ResourcesPlugin.getWorkspace().addResourceChangeListener(fResourceListener, IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.POST_CHANGE);
    }
}
Also used : IOperationHistoryListener(org.eclipse.core.commands.operations.IOperationHistoryListener) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) OperationHistoryEvent(org.eclipse.core.commands.operations.OperationHistoryEvent) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener)

Aggregations

IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)19 IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)14 IResource (org.eclipse.core.resources.IResource)9 IProject (org.eclipse.core.resources.IProject)8 IResourceDelta (org.eclipse.core.resources.IResourceDelta)6 IWorkspace (org.eclipse.core.resources.IWorkspace)6 IPath (org.eclipse.core.runtime.IPath)6 CoreException (org.eclipse.core.runtime.CoreException)5 IResourceDeltaVisitor (org.eclipse.core.resources.IResourceDeltaVisitor)3 File (java.io.File)2 IOException (java.io.IOException)2 IFile (org.eclipse.core.resources.IFile)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 IDocumentWrapper (bndtools.editor.model.IDocumentWrapper)1 ProjectModel (ch.acanda.eclipse.pmd.domain.ProjectModel)1 WorkspaceModel (ch.acanda.eclipse.pmd.domain.WorkspaceModel)1 ProjectModelRepository (ch.acanda.eclipse.pmd.repository.ProjectModelRepository)1 ILiferayLegacyProjectUpdater (com.liferay.ide.project.core.upgrade.ILiferayLegacyProjectUpdater)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1