Search in sources :

Example 31 with IResourceDelta

use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.

the class BundleCalculatedImportsPart method resourceChanged.

@Override
public void resourceChanged(IResourceChangeEvent event) {
    IFile file = getEditorFile();
    if (file != null) {
        IResourceDelta delta = event.getDelta();
        delta = delta.findMember(file.getFullPath());
        if (delta != null) {
            IFormPage page = (IFormPage) getManagedForm().getContainer();
            if (page.isActive())
                refresh();
            else
                markStale();
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 32 with IResourceDelta

use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.

the class PackageInfoEditor method resourceChanged.

public void resourceChanged(IResourceChangeEvent event) {
    IResource resource = ResourceUtil.getResource(getEditorInput());
    IResourceDelta delta = event.getDelta();
    if (delta == null)
        return;
    IPath path = resource.getFullPath();
    delta = delta.findMember(path);
    if (delta == null)
        return;
    if ((delta.getFlags() & IResourceDelta.MARKERS) != 0)
        SWTConcurrencyUtil.execForControl(getEditorSite().getShell(), true, new Runnable() {

            public void run() {
                updateTitleIcon();
            }
        });
}
Also used : IPath(org.eclipse.core.runtime.IPath) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 33 with IResourceDelta

use of org.eclipse.core.resources.IResourceDelta in project bndtools by bndtools.

the class CnfWatcher method processEvent.

private void processEvent(IResourceChangeEvent event) {
    try {
        final Workspace workspace = Central.getWorkspaceIfPresent();
        if (workspace == null) {
            // this can happen during first project creation in an empty workspace
            logger.logInfo("Unable to get workspace", null);
            return;
        }
        final IProject cnfProject = WorkspaceUtils.findCnfProject(ResourcesPlugin.getWorkspace().getRoot(), workspace);
        if (cnfProject == null)
            return;
        IResourceDelta delta = event.getDelta();
        if (delta.findMember(cnfProject.getFullPath()) == null)
            return;
        Collection<Project> allProjects = workspace.getAllProjects();
        if (allProjects.isEmpty())
            return;
        Project p = allProjects.iterator().next();
        DeltaWrapper dw = new DeltaWrapper(p, delta, new BuildLogger(0));
        if (dw.hasCnfChanged()) {
            workspace.clear();
            workspace.forceRefresh();
            workspace.getPlugins();
            BndtoolsBuilder.dirty.addAll(allProjects);
            WorkspaceJob j = new WorkspaceJob("Update errors on workspace") {

                @Override
                public IStatus runInWorkspace(IProgressMonitor arg0) throws CoreException {
                    try {
                        MarkerSupport ms = new MarkerSupport(cnfProject);
                        ms.deleteMarkers("*");
                        ms.setMarkers(workspace, BndtoolsConstants.MARKER_BND_WORKSPACE_PROBLEM);
                        return Status.OK_STATUS;
                    } catch (Exception e) {
                        return new Status(IStatus.ERROR, BndtoolsBuilder.PLUGIN_ID, "updating errors for workspace", e);
                    }
                }
            };
            j.schedule();
        }
    } catch (Exception e) {
        logger.logError("Detecting changes in cnf failed, ignoring", e);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) Project(aQute.bnd.build.Project) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) Workspace(aQute.bnd.build.Workspace) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Aggregations

IResourceDelta (org.eclipse.core.resources.IResourceDelta)33 IResource (org.eclipse.core.resources.IResource)21 IPath (org.eclipse.core.runtime.IPath)12 IProject (org.eclipse.core.resources.IProject)10 CoreException (org.eclipse.core.runtime.CoreException)9 IResourceDeltaVisitor (org.eclipse.core.resources.IResourceDeltaVisitor)8 ArrayList (java.util.ArrayList)7 IFile (org.eclipse.core.resources.IFile)5 HashSet (java.util.HashSet)4 List (java.util.List)4 Iterator (java.util.Iterator)3 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)3 Project (aQute.bnd.build.Project)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 IFolder (org.eclipse.core.resources.IFolder)2 IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)2 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2