Java Code Examples for org.eclipse.core.resources.IResourceDelta#REMOVED
The following examples show how to use
org.eclipse.core.resources.IResourceDelta#REMOVED .
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: DeltaInfo.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public String toString() { StringBuffer sb = new StringBuffer(); switch (changeKind) { case IResourceDelta.ADDED: sb.append("ADDED"); break; case IResourceDelta.CHANGED: sb.append("CHANGED"); break; case IResourceDelta.REMOVED: sb.append("REMOVED"); break; default: sb.append(" ? ").append(changeKind); break; } sb.append(" marker id ").append(marker.getId()) .append(marker.toString().replace("org.eclipse.core.internal.resources.Marker@", "/")); return sb.toString(); }
Example 2
Source File: PydevGrouperVisitor.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * This will use the internal builders to traverse the delta. Note that the resource is always a valid * python file and is also always located in the pythonpath. */ @Override protected void onVisitDelta(IResourceDelta delta) { //Note: removals happen now, additions and changes happen later (so that renames are //properly treated). switch (delta.getKind()) { case IResourceDelta.ADDED: case IResourceDelta.CHANGED: delayedVisits.add(delta); break; case IResourceDelta.REMOVED: IResource resource = delta.getResource(); memo.put(PyDevBuilderVisitor.DOCUMENT_TIME, System.currentTimeMillis()); visitRemovedResource(resource, null, monitor); break; } }
Example 3
Source File: ProblemMarkerManager.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private boolean isErrorDelta(IResourceDelta delta) { if ((delta.getFlags() & IResourceDelta.MARKERS) != 0) { IMarkerDelta[] markerDeltas = delta.getMarkerDeltas(); for (int i = 0; i < markerDeltas.length; i++) { IMarkerDelta iMarkerDelta = markerDeltas[i]; if (iMarkerDelta.isSubtypeOf(IMarker.PROBLEM)) { int kind = iMarkerDelta.getKind(); if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) { return true; } int severity = iMarkerDelta.getAttribute(IMarker.SEVERITY, -1); int newSeverity = iMarkerDelta.getMarker().getAttribute(IMarker.SEVERITY, -1); if (newSeverity != severity) { return true; } } } } return false; }
Example 4
Source File: Builder.java From cppcheclipse with Apache License 2.0 | 6 votes |
public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); // ignore all parent elements (projects, folders) if (resource instanceof IFile) { switch (delta.getKind()) { case IResourceDelta.ADDED: // handle added resource processResource(resource, new SubProgressMonitor(monitor, 1)); break; case IResourceDelta.REMOVED: // resources are not available any more and therefore the // markers were automatically removed break; case IResourceDelta.CHANGED: // handle changed resource processResource(resource, new SubProgressMonitor(monitor, 1)); break; } } // return true to continue visiting children. return true; }
Example 5
Source File: HierarchicalDataWorkspaceModelFactory.java From dawnsci with Eclipse Public License 1.0 | 6 votes |
public boolean visit(IResourceDelta delta) { boolean clear = false; IResource resource = delta.getResource(); if (resource instanceof IFile) { switch (delta.getKind()) { case IResourceDelta.ADDED: case IResourceDelta.REMOVED: clear = true; break; case IResourceDelta.CHANGED: int flags = delta.getFlags(); if ((flags & (IResourceDelta.CONTENT | IResourceDelta.LOCAL_CHANGED)) != 0) { clear = true; } default: break; } if (clear) { model.clearFileCache((IFile) resource); } } return true; }
Example 6
Source File: AbstractEditor.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void resourceChanged(IResourceChangeEvent e) { IResourceDelta delta = e.getDelta(); final FileEditorInput fInput = (FileEditorInput) getEditorInput(); final IFile file = fInput.getFile(); if (delta != null) { delta = delta.findMember(file.getFullPath()); } if (delta != null) { final int flags = delta.getFlags(); if (delta.getKind() == IResourceDelta.REMOVED && (IResourceDelta.MOVED_TO & flags) != 0) { updateEditorInput( new FileEditorInput(file.getWorkspace().getRoot().getFile(delta.getMovedToPath()))); } else if (delta.getKind() == IResourceDelta.CHANGED) { if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.REPLACED) != 0) { if (!resourceChangeEventSkip) { FileEditorInput newEditorInput = new FileEditorInput(delta.getResource().getAdapter(IFile.class)); Display.getDefault().asyncExec(() -> updateEditorInput(newEditorInput)); } } } } }
Example 7
Source File: ProblemMarkerManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void checkInvalidate(IResourceDelta delta, IResource resource) { int kind = delta.getKind(); if (kind == IResourceDelta.REMOVED || kind == IResourceDelta.ADDED || (kind == IResourceDelta.CHANGED && isErrorDelta(delta))) { // invalidate the resource and all parents while (resource.getType() != IResource.ROOT && fChangedElements.add(resource)) { resource = resource.getParent(); } } }
Example 8
Source File: PyDevDeltaCounter.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Overridden so that we don't load the document on this visitor (there is no need for that). */ @Override protected void onVisitDelta(IResourceDelta delta) { switch (delta.getKind()) { case IResourceDelta.ADDED: visitAddedResource(null, null, monitor); break; case IResourceDelta.CHANGED: visitChangedResource(null, null, monitor); break; case IResourceDelta.REMOVED: visitRemovedResource(null, null, monitor); break; } }
Example 9
Source File: ExtLibDesignElementLookup.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public void resourceChanged(IResourceChangeEvent event) { // @TODO: need to filter resource events! try { IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() { boolean keepVisiting = true; public boolean visit(IResourceDelta delta) { if (!keepVisiting || null == designerProject) return false; int k = delta.getKind(); if ( ! (IResourceDelta.ADDED == k || IResourceDelta.REMOVED == k || IResourceDelta.CHANGED == k) ) // an update could be a name change return true; // if ((delta.getFlags() ...? IResource resource = delta.getResource(); if (resource.getType() == IResource.FILE && resource.getProject().equals(designerProject.getProject())) { String resExt = resource.getFileExtension(); String typeExt = extForType(); if (typeExt.length() > 0 && resExt.length() > 0 && typeExt.equalsIgnoreCase(resExt)) { keepVisiting = false; updateDesignElements(); } } return keepVisiting; } }; event.getDelta().accept(visitor); } catch(Exception e) { ExtLibToolingLogger.EXT_LIB_TOOLING_LOGGER.error(e, e.toString()); } }
Example 10
Source File: ClientBundleResourceChangeListener.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private static boolean isPossibleClientBundleResourceDelta( IResourceDelta delta) { IResource resource = delta.getResource(); if (resource.isDerived()) { return false; } if (resource.getType() != IResource.FILE) { return false; } // We only care about additions/deletions. If the contents of a // resource file change, it doesn't affect our validation. if (delta.getKind() != IResourceDelta.ADDED && delta.getKind() != IResourceDelta.REMOVED) { return false; } // Ignore Java source changes, since we're only interested in resource files if ("java".equals(resource.getFileExtension())) { return false; } if (!GWTNature.isGWTProject(resource.getProject())) { return false; } IJavaProject javaProject = JavaCore.create(resource.getProject()); if (!javaProject.isOnClasspath(resource)) { return false; } // All checks passed; it looks like a change we care about return true; }
Example 11
Source File: MarkerManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * removeMarker * * @param resource * @param id * @throws CoreException */ public void removeMarker(IUniformResource resource, long id) throws CoreException { MarkerInfo marker = findMarkerInfo(resource, id); if (marker == null) { return; } ResourceInfo info = getResourceInfo(resource); MarkerSet markers = info.getMarkers(true); if (markers != null) { int size = markers.size(); markers.remove(marker); info.setMarkers(markers.size() == 0 ? null : markers); if (markers.size() != size) { /* TODO: store persistent marker state */ IMarkerSetElement[] changes = new IMarkerSetElement[] { new MarkerDelta(IResourceDelta.REMOVED, resource, marker) }; changedMarkers(resource, changes); } } else { IdeLog.logInfo(CorePlugin.getDefault(), MessageFormat.format( "Could not remove the marker with the id {0}. The resource-info returned a null marker-set.", id)); //$NON-NLS-1$ } }
Example 12
Source File: DeltaProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void checkSourceAttachmentChange(IResourceDelta delta, IResource res) { IPath rootPath = (IPath)this.state.sourceAttachments.get(externalPath(res)); if (rootPath != null) { RootInfo rootInfo = rootInfo(rootPath, delta.getKind()); if (rootInfo != null) { IJavaProject projectOfRoot = rootInfo.project; IPackageFragmentRoot root = null; try { // close the root so that source attachment cache is flushed root = projectOfRoot.findPackageFragmentRoot(rootPath); if (root != null) { root.close(); } } catch (JavaModelException e) { // root doesn't exist: ignore } if (root == null) return; switch (delta.getKind()) { case IResourceDelta.ADDED: currentDelta().sourceAttached(root); break; case IResourceDelta.CHANGED: currentDelta().sourceDetached(root); currentDelta().sourceAttached(root); break; case IResourceDelta.REMOVED: currentDelta().sourceDetached(root); break; } } } }
Example 13
Source File: ResourceUtils.java From goclipse with Eclipse Public License 1.0 | 5 votes |
protected static String deltaKindToString(IResourceDelta delta) { switch (delta.getKind()) { case IResourceDelta.ADDED: return "+"; case IResourceDelta.REMOVED: return "-"; case IResourceDelta.CHANGED: return "*"; case IResourceDelta.ADDED_PHANTOM: return "%+%"; case IResourceDelta.REMOVED_PHANTOM: return "%-%"; default: throw assertFail(); } }
Example 14
Source File: TmfEventsEditor.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void resourceChanged(final IResourceChangeEvent event) { final Set<@NonNull IMarker> added = new HashSet<>(); final Set<@NonNull IMarker> removed = new HashSet<>(); boolean deltaFound = false; for (final IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) { if (delta.getResource().equals(fFile)) { if (delta.getKind() == IResourceDelta.REMOVED) { removed.add(delta.getMarker()); } else if (delta.getKind() == IResourceDelta.ADDED) { added.add(delta.getMarker()); } /* this also covers IResourceDelta.CHANGED */ deltaFound = true; } } if (!deltaFound) { return; } Display.getDefault().asyncExec(() -> { if (removed.isEmpty() && added.isEmpty()) { fEventsTable.getTable().refresh(); } else { if (!removed.isEmpty()) { fEventsTable.removeBookmark(Iterables.toArray(removed, IMarker.class)); } if (!added.isEmpty()) { fEventsTable.addBookmark(Iterables.toArray(added, IMarker.class)); } } }); }
Example 15
Source File: N4JSAllContainersState.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Handles the given {@link IResourceDelta} and updates the project state (cache of available projects and project * descriptions) accordingly. * * If so, invalidates the {@link EclipseBasedN4JSWorkspace} cache of project descriptions for the updated projects. */ private boolean updateProjectState(IResourceDelta delta) { if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.REMOVED) { if (IN4JSProject.PACKAGE_JSON.equals(delta.getFullPath().lastSegment())) { return true; } if (delta.getResource() instanceof IProject) { return true; } if (delta.getResource() instanceof IFolder) { if (isSourceContainerModification(delta)) { return true; } } return false; } else if (delta.getKind() == IResourceDelta.CHANGED) { if (delta.getResource() instanceof IProject) { if ((delta.getFlags() & IResourceDelta.OPEN) != 0) { return true; } return false; } if (delta.getResource() instanceof IFolder) { if (N4JSGlobals.NODE_MODULES.equals(delta.getFullPath().lastSegment())) { return true; } return false; } } if (packageJSONFileHasBeenChanged(delta)) { return true; } return false; }
Example 16
Source File: DeltaProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private RootInfo rootInfo(IPath path, int kind) { if (kind == IResourceDelta.REMOVED) { return (RootInfo)this.state.oldRoots.get(path); } return (RootInfo)this.state.roots.get(path); }
Example 17
Source File: JavaElementDelta.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Returns a string representation of this delta's * structure suitable for debug purposes. * * @see #toString() */ public String toDebugString(int depth) { StringBuffer buffer = new StringBuffer(); for (int i= 0; i < depth; i++) { buffer.append('\t'); } buffer.append(((JavaElement)getElement()).toDebugString()); toDebugString(buffer); IJavaElementDelta[] children = getAffectedChildren(); if (children != null) { for (int i = 0; i < children.length; ++i) { buffer.append("\n"); //$NON-NLS-1$ buffer.append(((JavaElementDelta) children[i]).toDebugString(depth + 1)); } } for (int i = 0; i < this.resourceDeltasCounter; i++) { buffer.append("\n");//$NON-NLS-1$ for (int j = 0; j < depth+1; j++) { buffer.append('\t'); } IResourceDelta resourceDelta = this.resourceDeltas[i]; buffer.append(resourceDelta.toString()); buffer.append("["); //$NON-NLS-1$ switch (resourceDelta.getKind()) { case IResourceDelta.ADDED : buffer.append('+'); break; case IResourceDelta.REMOVED : buffer.append('-'); break; case IResourceDelta.CHANGED : buffer.append('*'); break; default : buffer.append('?'); break; } buffer.append("]"); //$NON-NLS-1$ } IJavaElementDelta[] annotations = getAnnotationDeltas(); if (annotations != null) { for (int i = 0; i < annotations.length; ++i) { buffer.append("\n"); //$NON-NLS-1$ buffer.append(((JavaElementDelta) annotations[i]).toDebugString(depth + 1)); } } return buffer.toString(); }
Example 18
Source File: DeltaInfo.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
public boolean isRemoved() { return changeKind == IResourceDelta.REMOVED; }
Example 19
Source File: UIResourceChangeRegistry.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
private boolean hasExistsChanged(final IResourceDelta delta) { return ((delta.getKind() == IResourceDelta.ADDED) || (delta.getKind() == IResourceDelta.REMOVED)); }
Example 20
Source File: DeltaProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private ArrayList otherRootsInfo(IPath path, int kind) { if (kind == IResourceDelta.REMOVED) { return (ArrayList)this.state.oldOtherRoots.get(path); } return (ArrayList)this.state.otherRoots.get(path); }