Search in sources :

Example 21 with IResourceDelta

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

the class TestModelProvider method getActualChildren.

private static IResourceDelta[] getActualChildren(IResourceDelta delta, IResourceDelta[] expectedChildren) {
    List result = new ArrayList();
    if (!IS_COPY_TEST) {
        IResourceDelta[] children = delta.getAffectedChildren();
        for (int i = 0; i < children.length; i++) {
            IResourceDelta child = children[i];
            IResource resource = child.getResource();
            if (resource != null && isIgnorable(resource))
                continue;
            result.add(child);
        }
    } else {
        IResourceDelta[] candidates = delta.getAffectedChildren();
        for (int i = 0; i < candidates.length; i++) {
            IResourceDelta candidate = candidates[i];
            IResource resource = candidate.getResource();
            if (resource != null && isIgnorable(resource))
                continue;
            if (contains(expectedChildren, candidate)) {
                result.add(candidate);
            } else {
                assertCopySource(candidate);
            }
        }
    }
    return (IResourceDelta[]) result.toArray(new IResourceDelta[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 22 with IResourceDelta

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

the class TestModelProvider method getExpectedChildren.

private static IResourceDelta[] getExpectedChildren(IResourceDelta delta) {
    List result = new ArrayList();
    IResourceDelta[] children = delta.getAffectedChildren();
    for (int i = 0; i < children.length; i++) {
        IResourceDelta child = children[i];
        IResource resource = child.getResource();
        if (resource != null && isIgnorable(resource))
            continue;
        if (child.getAffectedChildren().length > 0) {
            result.add(child);
        } else {
            int flags = child.getFlags();
            if (flags == 0 || (flags & PRE_DELTA_FLAGS) != 0) {
                result.add(child);
            }
        }
    }
    return (IResourceDelta[]) result.toArray(new IResourceDelta[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 23 with IResourceDelta

use of org.eclipse.core.resources.IResourceDelta in project jop by jop-devel.

the class JOPizer method build.

@Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
    IProject project = getProject();
    if (project == null || !project.isAccessible()) {
        return new IProject[0];
    }
    currentProject = JavaCore.create(project);
    // Determine if the Quartus project has changed
    String pluginQuartusProject = JOPUIPlugin.getDefault().getPreferenceStore().getString(IJOPLaunchConfigurationConstants.ATTR_QUARTUS_PROJECT);
    if (quartusProjectPath == null || !quartusProjectPath.equalsIgnoreCase(pluginQuartusProject)) {
        kind = FULL_BUILD;
        quartusProjectPath = pluginQuartusProject;
    }
    String[] buildTypes = new String[] { "0", "1", "2", "3", "4", "5", "FULL_BUILD", "7", "8", "AUTO_BUILD", "INCREMENTAL_BUILD", "11", "12", "13", "14", "CLEAN_BUILD" };
    System.err.printf("Build kind: %s%n" + "Args: %s%n", buildTypes[kind], args);
    // 
    if (kind == FULL_BUILD) {
        // Build tools-chain
        buildToolChain(monitor);
    }
    Set<IResource> filesToJOPize = new HashSet<IResource>();
    IResourceDelta delta = getDelta(getProject());
    System.err.printf("Delta: '%s'%n", delta);
    if (delta == null) {
        IRegion projectRegion = JavaCore.newRegion();
        projectRegion.add(currentProject);
        filesToJOPize.addAll(Arrays.asList(JavaCore.getGeneratedResources(projectRegion, false)));
    } else {
        System.err.printf("Affected children: '%s'%n", Arrays.toString(delta.getAffectedChildren()));
        IPath outputLocation = currentProject.getOutputLocation();
        IPath binLocation = outputLocation.removeFirstSegments(1);
        IResourceDelta outputDelta = delta.findMember(binLocation);
        // Gather .class files to JOPize
        ClassFileVisitor classFileVisitor = new ClassFileVisitor();
        outputDelta.accept(classFileVisitor);
        Map<Integer, Set<IResource>> updatedClassFiles = classFileVisitor.getClassFiles();
        System.err.printf("All: %s%n", updatedClassFiles);
        System.err.printf("Changed: %s%n", updatedClassFiles.get(IResourceDelta.CHANGED));
        System.err.printf("Added  : %s%n", updatedClassFiles.get(IResourceDelta.ADDED));
        System.err.printf("Removed: %s%n", updatedClassFiles.get(IResourceDelta.REMOVED));
        for (int kindKey : updatedClassFiles.keySet()) {
            if (kindKey != IResourceDelta.REMOVED) {
                filesToJOPize.addAll(updatedClassFiles.get(kindKey));
            }
        }
    }
    if (!filesToJOPize.isEmpty()) {
        Iterator<IResource> it = filesToJOPize.iterator();
        StringBuilder jopizeArgs = new StringBuilder();
        jopizeArgs.append(it.next().getLocation().toOSString());
        while (it.hasNext()) {
            jopizeArgs.append(' ');
            jopizeArgs.append(it.next().getLocation().toOSString());
        }
        IPath outputDir = currentProject.getOutputLocation();
        ILaunchConfiguration jopizeLaunchConfig = createJOPizeLaunchConfiguration("-cp " + getClassesClasspathEntry().getPath().toOSString() + " -o " + "c:\\temp\\test.jop" + " " + jopizeArgs.toString());
        System.err.printf(">> %s%n", jopizeLaunchConfig);
        System.err.printf(">> %s%n", jopizeLaunchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "---"));
        DebugUITools.launch(jopizeLaunchConfig, ILaunchManager.RUN_MODE);
        System.err.println("launch");
        return new IProject[] { getProject() };
    }
    return new IProject[0];
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) HashSet(java.util.HashSet) Set(java.util.Set) IPath(org.eclipse.core.runtime.IPath) IProject(org.eclipse.core.resources.IProject) IRegion(org.eclipse.jdt.core.IRegion) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 24 with IResourceDelta

use of org.eclipse.core.resources.IResourceDelta in project dbeaver by serge-rider.

the class ImageEditorPart method resourceChanged.

@Override
public void resourceChanged(IResourceChangeEvent event) {
    IResourceDelta delta = event.getDelta();
    if (delta == null) {
        return;
    }
    IEditorInput input = getEditorInput();
    IPath localPath = null;
    if (input instanceof IPathEditorInput) {
        localPath = ((IPathEditorInput) input).getPath();
    }
    if (localPath == null) {
        return;
    }
    localPath = ContentUtils.convertPathToWorkspacePath(localPath);
    delta = delta.findMember(localPath);
    if (delta == null) {
        return;
    }
    if (delta.getKind() == IResourceDelta.CHANGED) {
        // Refresh editor
        DBeaverUI.asyncExec(new Runnable() {

            @Override
            public void run() {
                loadImage();
            }
        });
    }
}
Also used : IPathEditorInput(org.eclipse.ui.IPathEditorInput) IPath(org.eclipse.core.runtime.IPath) IEditorInput(org.eclipse.ui.IEditorInput) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 25 with IResourceDelta

use of org.eclipse.core.resources.IResourceDelta in project dbeaver by serge-rider.

the class ContentEditor method resourceChanged.

@Override
public void resourceChanged(IResourceChangeEvent event) {
    if (!partsLoaded || saveInProgress) {
        // No content change before all parts are loaded
        return;
    }
    IResourceDelta delta = event.getDelta();
    if (delta == null) {
        return;
    }
    delta = delta.findMember(ContentUtils.convertPathToWorkspacePath(getEditorInput().getPath()));
    if (delta == null) {
        return;
    }
    if (delta.getKind() == IResourceDelta.CHANGED && (delta.getFlags() & IResourceDelta.CONTENT) != 0) {
        // Content was changed somehow so mark editor as dirty
        dirty = true;
        DBeaverUI.asyncExec(new Runnable() {

            @Override
            public void run() {
                firePropertyChange(PROP_DIRTY);
            }
        });
    }
}
Also used : 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