Java Code Examples for org.eclipse.core.resources.IResourceDelta#MOVED_TO
The following examples show how to use
org.eclipse.core.resources.IResourceDelta#MOVED_TO .
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: ConfigEditor.java From thym with Eclipse Public License 1.0 | 6 votes |
public boolean visit(IResourceDelta delta) { if (delta == null || !delta.getResource().equals( ((FileEditorInput) getEditorInput()).getFile())){ return true; } if (delta.getKind() == IResourceDelta.REMOVED) { if ((IResourceDelta.MOVED_TO & delta.getFlags()) == 0) { if (!isDirty()) closeEditor(); } else { final IFile newFile = ResourcesPlugin.getWorkspace() .getRoot().getFile(delta.getMovedToPath()); Display display = getSite().getShell().getDisplay(); display.asyncExec(new Runnable() { public void run() { editorPart.setInput(new FileEditorInput(newFile)); } }); } } return false; }
Example 2
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 3
Source File: JavaWorkingSetUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void processResourceDelta(WorkingSetDelta result, IResourceDelta delta) { IResource resource= delta.getResource(); int type= resource.getType(); int index= result.indexOf(resource); int kind= delta.getKind(); int flags= delta.getFlags(); if (kind == IResourceDelta.CHANGED && type == IResource.PROJECT && index != -1) { if ((flags & IResourceDelta.OPEN) != 0) { result.set(index, resource); } } if (index != -1 && kind == IResourceDelta.REMOVED) { if ((flags & IResourceDelta.MOVED_TO) != 0) { result.set(index, ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath())); } else { result.remove(index); } } // Don't dive into closed or opened projects if (projectGotClosedOrOpened(resource, kind, flags)) return; IResourceDelta[] children= delta.getAffectedChildren(); for (int i= 0; i < children.length; i++) { processResourceDelta(result, children[i]); } }
Example 4
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 5
Source File: DeltaProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void elementRemoved(Openable element, IResourceDelta delta, RootInfo rootInfo) { int elementType = element.getElementType(); if (delta == null || (delta.getFlags() & IResourceDelta.MOVED_TO) == 0) { // regular element removal if (isPrimaryWorkingCopy(element, elementType) ) { // filter out changes to primary compilation unit in working copy mode // just report a change to the resource (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59500) currentDelta().changed(element, IJavaElementDelta.F_PRIMARY_RESOURCE); } else { close(element); removeFromParentInfo(element); currentDelta().removed(element); } } else { // element is moved close(element); removeFromParentInfo(element); IPath movedToPath = delta.getMovedToPath(); IResource res = delta.getResource(); IResource movedToRes; switch (res.getType()) { case IResource.PROJECT: movedToRes = res.getWorkspace().getRoot().getProject(movedToPath.lastSegment()); break; case IResource.FOLDER: movedToRes = res.getWorkspace().getRoot().getFolder(movedToPath); break; case IResource.FILE: movedToRes = res.getWorkspace().getRoot().getFile(movedToPath); break; default: return; } // find the element type of the moved from element IPath rootPath = externalPath(movedToRes); RootInfo movedToInfo = enclosingRootInfo(rootPath, IResourceDelta.ADDED); int movedToType = elementType( movedToRes, IResourceDelta.ADDED, element.getParent().getElementType(), movedToInfo); // reset current element as it might be inside a nested root (popUntilPrefixOf() may use the outer root) this.currentElement = null; // create the moved To element Openable movedToElement = elementType != IJavaElement.JAVA_PROJECT && movedToType == IJavaElement.JAVA_PROJECT ? null : // outside classpath createElement(movedToRes, movedToType, movedToInfo); if (movedToElement == null) { // moved outside classpath currentDelta().removed(element); } else { currentDelta().movedFrom(element, movedToElement); } } switch (elementType) { case IJavaElement.JAVA_MODEL : this.manager.indexManager.reset(); break; case IJavaElement.JAVA_PROJECT : this.state.updateRoots(element.getPath(), delta, this); // remember that the project's cache must be reset this.projectCachesToReset.add(element); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT : JavaProject project = (JavaProject) element.getJavaProject(); // remember that the project's cache must be reset this.projectCachesToReset.add(project); break; case IJavaElement.PACKAGE_FRAGMENT : // reset package fragment cache project = (JavaProject) element.getJavaProject(); this.projectCachesToReset.add(project); break; } }
Example 6
Source File: ProjectDeltaVisitor.java From saros with GNU General Public License v2.0 | 4 votes |
private static boolean isMovedTo(IResourceDelta delta) { return ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0); }
Example 7
Source File: ResourceDeltaVisitor.java From saros with GNU General Public License v2.0 | 4 votes |
@Override public boolean visit(final IResourceDelta delta) throws CoreException { final IResource resource = delta.getResource(); if (resource.getType() == IResource.ROOT) return true; if (!session.isShared(ResourceAdapterFactory.create(resource))) return true; if (resource.getType() != IResource.PROJECT) { isModifyingResources = true; return false; } if (delta.getKind() == IResourceDelta.REMOVED) { if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) isMovingProject = true; else isDeletingProject = true; return false; } return true; }