Java Code Examples for org.eclipse.core.resources.IResourceDelta#CONTENT
The following examples show how to use
org.eclipse.core.resources.IResourceDelta#CONTENT .
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: 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 2
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 3
Source File: UnifiedBuilder.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if (resource instanceof IFile) { if (delta.getKind() == IResourceDelta.ADDED || (delta.getKind() == IResourceDelta.CHANGED && ((delta.getFlags() & (IResourceDelta.CONTENT | IResourceDelta.ENCODING)) != 0))) { updatedFiles.add((IFile) resource); } else if (delta.getKind() == IResourceDelta.REMOVED) { removedFiles.add((IFile) resource); } } return true; }
Example 4
Source File: ResourceUtils.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Given a resource delta, indicate whether or the delta contains a type of * resource change that GWT generally cares about. */ public static boolean isRelevantResourceChange(IResourceDelta delta) { if (delta == null) { return false; } int relevantChanges = IResourceDelta.CONTENT | IResourceDelta.DESCRIPTION | IRESOURCEDELTA_LOCAL_CHANGED | IResourceDelta.OPEN | IResourceDelta.REPLACED | IResourceDelta.TYPE; // Either added or removed (through != CHANGED), or changed in some // relevant way (through (.. & relevantChanges) != 0) if (delta.getKind() != IResourceDelta.CHANGED || (delta.getFlags() & relevantChanges) != 0) { return true; } return false; }
Example 5
Source File: ImageViewer.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void resourceChanged(final IResourceChangeEvent event) { final IResourceDelta delta = event.getDelta().findMember(imageFile.getFullPath()); if (delta != null) { // file deleted -- close the editor if (delta.getKind() == IResourceDelta.REMOVED) { final Runnable r = () -> getSite().getPage().closeEditor(ImageViewer.this, false); getSite().getShell().getDisplay().asyncExec(r); } // file changed -- reload image else if (delta.getKind() == IResourceDelta.CHANGED) { final int flags = delta.getFlags(); if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.LOCAL_CHANGED) != 0) { startImageLoad(); } } } }
Example 6
Source File: MultiPageCSVEditor.java From gama with GNU General Public License v3.0 | 5 votes |
/** * Closes all project files on project close. * * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) */ @Override public void resourceChanged(final IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE) { WorkbenchHelper.asyncRun(() -> { final IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); for (final IWorkbenchPage page : pages) { if (((FileEditorInput) editor.getEditorInput()).getFile().getProject() .equals(event.getResource())) { final IEditorPart editorPart = page.findEditor(editor.getEditorInput()); page.closeEditor(editorPart, true); } } }); } else { final IResourceDelta delta = event.getDelta().findMember(getFileFor(getEditorInput()).getFullPath()); if (delta != null) { // file deleted -- close the editor if (delta.getKind() == IResourceDelta.REMOVED) { final Runnable r = () -> getSite().getPage().closeEditor(MultiPageCSVEditor.this, false); getSite().getShell().getDisplay().asyncExec(r); } // file changed -- reload else if (delta.getKind() == IResourceDelta.CHANGED) { final int flags = delta.getFlags(); if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.LOCAL_CHANGED) != 0) { WorkbenchHelper.asyncRun(() -> MultiPageCSVEditor.this.updateTableFromTextEditor()); } } } } }
Example 7
Source File: BundleMonitor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public boolean visit(IResourceDelta delta) throws CoreException { // process project bundle files, but ignore user bundles since file watcher will take care of those if (isProjectBundleFile(delta)) { this.processFile(delta); } else { if (delta.getKind() == IResourceDelta.CHANGED && (delta.getFlags() & IResourceDelta.CONTENT) != 0) { IResource resource = delta.getResource(); if (resource != null) { IPath location = resource.getLocation(); if (location != null) { File file = location.toFile(); if (file != null) { this.reloadDependentScripts(file); } } } } } return true; }
Example 8
Source File: ResourceChangeReporter.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public boolean visit(final IResourceDelta delta) { if (!DEBUG.IS_ON()) { return false; } final IResource res = delta.getResource(); switch (delta.getKind()) { case IResourceDelta.ADDED: DEBUG.OUT("Resource " + res.getFullPath() + " was added."); break; case IResourceDelta.REMOVED: DEBUG.OUT("Resource " + res.getFullPath() + " was removed."); break; case IResourceDelta.CHANGED: DEBUG.OUT("Resource " + delta.getFullPath() + " has changed."); final int flags = delta.getFlags(); if ((flags & IResourceDelta.CONTENT) != 0) { DEBUG.OUT("--> Content Change"); } if ((flags & IResourceDelta.REPLACED) != 0) { DEBUG.OUT("--> Content Replaced"); } if ((flags & IResourceDelta.MARKERS) != 0) { DEBUG.OUT("--> Marker Change"); // final IMarkerDelta[] markers = delta.getMarkerDeltas(); // if interested in markers, check these deltas } break; } return true; // visit the children }
Example 9
Source File: SCTHotModelReplacementManager.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if ((delta.getFlags() & IResourceDelta.CONTENT) != 0) { if (resource.getType() == IResource.FILE) { IFile file = (IFile) resource; changedFiles.add(file); } } return true; }
Example 10
Source File: CodewindResourceChangeListener.java From codewind-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if (resource == null) { return false; } // Exclude parent folder or project if (delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() == 0) { return true; } ChangeEntryEventType ceet = null; switch (delta.getKind()) { case IResourceDelta.ADDED: ceet = ChangeEntryEventType.CREATE; break; case IResourceDelta.REMOVED: ceet = ChangeEntryEventType.DELETE; break; case IResourceDelta.CHANGED: ceet = ChangeEntryEventType.MODIFY; break; default: break; } if (ceet == null) { // Ignore and return for any unrecognized types. return true; } if (ceet == ChangeEntryEventType.MODIFY && ((delta.getFlags() & IResourceDelta.CONTENT) == 0 && (delta.getFlags() & IResourceDelta.REPLACED) == 0)) { // Some workbench operations, such as adding/removing a debug breakpoint, will // trigger a resource delta, even though the actual file contents is the same. // We ignore those, and return here. // However, these non-file-changed resources will always have the // IResourceDelta.CHANGED kind, so we only filter out events of this kind. return true; } // We have already checked that the resource is not null above, but some of the // underlying file system resources may still not (or no longer) have a backing // object, for example on project deletion events, so we check them here. IPath path = resource.getLocation(); if (path == null) { return true; } File resourceFile = path.toFile(); if (resourceFile == null) { return true; } IProject project = resource.getProject(); if (project == null) { return true; } FileChangeEntryEclipse fcee = new FileChangeEntryEclipse(resourceFile, ceet, resource.getType() == IResource.FOLDER, project); result.add(fcee); return true; }
Example 11
Source File: ResourceManager.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public boolean visit(final IResourceDelta delta) { final IResource res = delta.getResource(); boolean update = false; switch (delta.getKind()) { case IResourceDelta.OPEN: if (res.isAccessible()) { update = projectOpened((IProject) res); } else { update = projectClosed((IProject) res); } break; case IResourceDelta.ADDED: update = processAddition(res); break; case IResourceDelta.REMOVED: update = processRemoval(res); break; case IResourceDelta.CHANGED: final int flags = delta.getFlags(); if ((flags & IResourceDelta.MARKERS) != 0) { update = processMarkersChanged(res); } if ((flags & IResourceDelta.TYPE) != 0) { if (DEBUG.IS_ON()) { DEBUG.OUT("Resource type changed: " + res); } } if ((flags & IResourceDelta.CONTENT) != 0) { if (DEBUG.IS_ON()) { DEBUG.OUT("Resource contents changed: " + res); } } if ((flags & IResourceDelta.SYNC) != 0) { if (DEBUG.IS_ON()) { DEBUG.OUT("Resource sync info changed: " + res); } } if ((flags & IResourceDelta.LOCAL_CHANGED) != 0) { if (DEBUG.IS_ON()) { DEBUG.OUT("Linked resource target info changed: " + res); } update = processLinkedTargerChanged(res); } break; } if (update) { updateResource(res); } return true; // visit the children }
Example 12
Source File: XdsResourceChangeListener.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
protected boolean isContentChanged(IResourceDelta delta) { return (delta.getFlags() & IResourceDelta.CONTENT) != 0; }
Example 13
Source File: BundleMonitor.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * processFile * * @param delta */ private void processFile(IResourceDelta delta) { IResource resource = delta.getResource(); if (resource != null && resource.getLocation() != null) { BundleManager manager = getBundleManager(); File file = resource.getLocation().toFile(); String fullProjectPath = delta.getFullPath().toString(); BundlePrecedence scope = manager.getBundlePrecedence(file); // don't process user bundles that are projects since file watcher will handle those if (scope != BundlePrecedence.USER) { switch (delta.getKind()) { case IResourceDelta.ADDED: this.showResourceEvent("Added: " + file); //$NON-NLS-1$ if (BUNDLE_PATTERN_DEPRECATED.matcher(fullProjectPath).matches() || BUNDLE_PATTERN.matcher(fullProjectPath).matches()) { manager.loadBundle(file.getParentFile()); } else { manager.loadScript(file); } break; case IResourceDelta.REMOVED: this.showResourceEvent("Removed: " + file); //$NON-NLS-1$ if (BUNDLE_PATTERN_DEPRECATED.matcher(fullProjectPath).matches() || BUNDLE_PATTERN.matcher(fullProjectPath).matches()) { // NOTE: we have to both unload all scripts associated with this bundle // and the bundle file itself. Technically, the bundle file doesn't // exist any more so it won't get unloaded manager.unloadBundle(file.getParentFile()); } manager.unloadScript(file); break; case IResourceDelta.CHANGED: if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) { IPath movedFromPath = delta.getMovedFromPath(); IResource movedFrom = ResourcesPlugin.getWorkspace().getRoot() .getFileForLocation(movedFromPath); if (movedFrom != null && movedFrom instanceof IFile) { this.showResourceEvent(MessageFormat.format("Added: {0}=>{1}", movedFrom.getLocation() //$NON-NLS-1$ .toFile(), file)); manager.unloadScript(movedFrom.getLocation().toFile()); manager.loadScript(file); } } else if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) { IPath movedToPath = delta.getMovedToPath(); IResource movedTo = ResourcesPlugin.getWorkspace().getRoot() .getFileForLocation(movedToPath); if (movedTo != null && movedTo instanceof IFile) { this.showResourceEvent(MessageFormat.format("Added: {0}=>{1}", file, movedTo //$NON-NLS-1$ .getLocation().toFile())); manager.unloadScript(file); manager.loadScript(movedTo.getLocation().toFile()); } } else if ((delta.getFlags() & IResourceDelta.REPLACED) != 0) { this.showResourceEvent("Reload: " + file); //$NON-NLS-1$ manager.reloadScript(file); } else if ((delta.getFlags() & IResourceDelta.CONTENT) != 0) { this.showResourceEvent("Reload: " + file); //$NON-NLS-1$ manager.reloadScript(file); } break; } } } }
Example 14
Source File: JavaHotCodeReplaceProvider.java From java-debug with Eclipse Public License 1.0 | 4 votes |
/** * Answers whether children should be visited. * <p> * If the associated resource is a class file which has been changed, record it. * </p> */ @Override public boolean visit(IResourceDelta delta) { if (delta == null || 0 == (delta.getKind() & IResourceDelta.CHANGED)) { return false; } IResource resource = delta.getResource(); if (resource != null) { switch (resource.getType()) { case IResource.FILE: if (0 == (delta.getFlags() & IResourceDelta.CONTENT)) { return false; } if (CLASS_FILE_EXTENSION.equals(resource.getFullPath().getFileExtension())) { IPath localLocation = resource.getLocation(); if (localLocation != null) { String path = localLocation.toOSString(); IClassFileReader reader = ToolFactory.createDefaultClassFileReader(path, IClassFileReader.CLASSFILE_ATTRIBUTES); if (reader != null) { // this name is slash-delimited String qualifiedName = new String(reader.getClassName()); boolean hasBlockingErrors = false; try { // If the user doesn't want to replace // classfiles containing // compilation errors, get the source // file associated with // the class file and query it for // compilation errors IJavaProject pro = JavaCore.create(resource.getProject()); ISourceAttribute sourceAttribute = reader.getSourceFileAttribute(); String sourceName = null; if (sourceAttribute != null) { sourceName = new String(sourceAttribute.getSourceFileName()); } IResource sourceFile = getSourceFile(pro, qualifiedName, sourceName); if (sourceFile != null) { IMarker[] problemMarkers = null; problemMarkers = sourceFile.findMarkers( IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); for (IMarker problemMarker : problemMarkers) { if (problemMarker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) { hasBlockingErrors = true; break; } } } } catch (CoreException e) { logger.log(Level.SEVERE, "Failed to visit classes: " + e.getMessage(), e); } if (!hasBlockingErrors) { changedFiles.add(resource); // dot-delimit the name fullyQualifiedNames.add(qualifiedName.replace('/', '.')); } } } } return false; default: return true; } } return true; }
Example 15
Source File: ProjectDeltaVisitor.java From saros with GNU General Public License v2.0 | 4 votes |
private static boolean isContentChange(IResourceDelta delta) { return ((delta.getFlags() & IResourceDelta.CONTENT) != 0); }
Example 16
Source File: FlutterLibChangeListener.java From dartboard with Eclipse Public License 2.0 | 2 votes |
/** * Determines whether an {@link IResourceDelta} indicates that a * {@link IResource}'s content was changed. * * @param delta - The {@link IResourceDelta} to be checked * @return <code>true</code> if the {@link IResource}'s content was changed, * false otherwise. */ private boolean isContentChanged(IResourceDelta delta) { return delta.getKind() == IResourceDelta.CHANGED && (delta.getFlags() & IResourceDelta.CONTENT) != 0; }
Example 17
Source File: PubspecChangeListener.java From dartboard with Eclipse Public License 2.0 | 2 votes |
/** * Determines whether an {@link IResourceDelta} indicates that a * {@link IResource}'s content was changed. * * @param delta - The {@link IResourceDelta} to be checked * @return <code>true</code> if the {@link IResource}'s content was changed, * false otherwise. */ private boolean isContentChanged(IResourceDelta delta) { return delta.getKind() == IResourceDelta.CHANGED && (delta.getFlags() & IResourceDelta.CONTENT) != 0; }