Java Code Examples for org.eclipse.core.resources.IResourceDelta#getAffectedChildren()
The following examples show how to use
org.eclipse.core.resources.IResourceDelta#getAffectedChildren() .
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: StartupHandler.java From CogniCrypt with Eclipse Public License 2.0 | 6 votes |
@Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); IResourceDelta[] affectedChildren = delta.getAffectedChildren(); if (affectedChildren.length == 0) { return; } IResource deltaResource = affectedChildren[0].getResource(); if (event.getType() == IResourceChangeEvent.POST_CHANGE && deltaResource instanceof IProject && (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED)) { try { IProject project = (IProject) deltaResource; if (!CrySLBuilderUtils.hasCrySLBuilder(project) && CrySLBuilderUtils.hasCrySLFiles(project)) { CrySLBuilderUtils.addCrySLBuilderToProject(project); } } catch (CoreException e) {} } }
Example 2
Source File: PluginContentProvider.java From thym with Eclipse Public License 1.0 | 6 votes |
@Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (viewer == null || delta == null) return; IResourceDelta[] deltas = delta.getAffectedChildren(); for (int i = 0; i < deltas.length; i++) { if (deltas[i].findMember(new Path(PlatformConstants.DIR_PLUGINS)) != null) { viewer.getControl().getDisplay().asyncExec(new Runnable() { @Override public void run() { viewer.refresh(); } }); return; } } }
Example 3
Source File: OthersWorkingSetUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void resourceChanged(IResourceChangeEvent event) { if (fWorkingSet == null) return; // not yet initialized IResourceDelta delta= event.getDelta(); IResourceDelta[] affectedChildren= delta.getAffectedChildren(IResourceDelta.ADDED | IResourceDelta.REMOVED, IResource.PROJECT); if (affectedChildren.length > 0) { updateElements(); } else { affectedChildren= delta.getAffectedChildren(IResourceDelta.CHANGED, IResource.PROJECT); for (int i= 0; i < affectedChildren.length; i++) { IResourceDelta projectDelta= affectedChildren[i]; if ((projectDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) { updateElements(); // one is enough return; } } } }
Example 4
Source File: OpenResourceAction.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Handles a resource changed event by updating the enablement if one of the selected projects is opened or closed. */ @Override public void resourceChanged(final IResourceChangeEvent event) { // Warning: code duplicated in CloseResourceAction final List<?> sel = getSelectedResources(); // don't bother looking at delta if selection not applicable if (selectionIsOfType(IResource.PROJECT)) { final IResourceDelta delta = event.getDelta(); if (delta != null) { final IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED); for (final IResourceDelta projDelta : projDeltas) { if ((projDelta.getFlags() & IResourceDelta.OPEN) != 0) { if (sel.contains(projDelta.getResource())) { selectionChanged(getStructuredSelection()); return; } } } } } }
Example 5
Source File: UIResourceChangeRegistry.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private boolean hasChildrenChanged(final IResourceDelta delta) { IResource _resource = delta.getResource(); if ((_resource instanceof IFolder)) { IResourceDelta[] _affectedChildren = delta.getAffectedChildren(); for (final IResourceDelta c : _affectedChildren) { boolean _hasExistsChanged = this.hasExistsChanged(c); if (_hasExistsChanged) { return true; } } } return false; }
Example 6
Source File: BundleManifestResourceListener.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@Override protected void processProjectDelta(IResourceDelta projectDelta) { IProject project = (IProject) projectDelta.getResource(); Object existingProjectInfo = getProjectInfo(project); if(projectDelta.getKind() == IResourceDelta.REMOVED || !isValidLangProject(project)) { // New bundle model status = removed. if(existingProjectInfo == null) { return; // Nothing to update, wasn't a bundle model project to start with. } bundleProjectRemoved(project); return; } if(projectDelta.getKind() == IResourceDelta.ADDED) { tentativeAddBundleProject(project); } else if (projectDelta.getKind() == IResourceDelta.CHANGED) { // It might be the case that project wasn't eligible to have an info, but now is eligible, // purely due to a change in DESCRIPTION (such as a nature add) if(existingProjectInfo == null) { // Then it's true, project has become bundle model project. tentativeAddBundleProject(project); return; } IResourceDelta[] resourceDeltas = projectDelta.getAffectedChildren(); if(resourceDeltas == null) return; for (IResourceDelta resourceDelta : resourceDeltas) { if(resourceDeltaIsBundleManifestChange(resourceDelta)) { bundleManifestChanged(project); } } } }
Example 7
Source File: XdsResourceChangeListener.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * TODO : use this method to improve performance of the resource change listening. * @param delta * @return */ @SuppressWarnings("unused") private boolean hasModula2Projects(IResourceDelta delta) { IResourceDelta[] affectedProjects = delta.getAffectedChildren(); return Arrays.stream(affectedProjects) .map(rd -> rd.getResource().getProject()) .filter(p -> NatureUtils.hasModula2Nature(p)) .findAny().isPresent(); }
Example 8
Source File: ResourceUtils.java From goclipse with Eclipse Public License 1.0 | 5 votes |
protected static void doPrintDelta(IResourceDelta delta, String indent, StringBuilder sb) { sb.append(indent); sb.append(delta); sb.append(" " + deltaKindToString(delta) + "\n"); for (IResourceDelta childDelta : delta.getAffectedChildren()) { doPrintDelta(childDelta, indent + " ", sb); } }
Example 9
Source File: CheckoutUsingProjectWizardAction.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent) */ public void resourceChanged(IResourceChangeEvent event) { IResourceDelta root = event.getDelta(); IResourceDelta[] projectDeltas = root.getAffectedChildren(); for (int i = 0; i < projectDeltas.length; i++) { IResourceDelta delta = projectDeltas[i]; IResource resource = delta.getResource(); if (delta.getKind() == IResourceDelta.ADDED) { newProject = (IProject)resource; } } }
Example 10
Source File: OpenProjectAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta != null) { IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED); for (int i = 0; i < projDeltas.length; ++i) { IResourceDelta projDelta = projDeltas[i]; if ((projDelta.getFlags() & IResourceDelta.OPEN) != 0) { setEnabled(hasClosedProjectsInWorkspace()); return; } } } }
Example 11
Source File: JavaElementContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void processResourceDelta(IResourceDelta delta, Object parent) { int status= delta.getKind(); IResource resource= delta.getResource(); // filter out changes affecting the output folder if (resource == null) return; // this could be optimized by handling all the added children in the parent if ((status & IResourceDelta.REMOVED) != 0) { if (parent instanceof IPackageFragment) // refresh one level above to deal with empty package filtering properly postRefresh(internalGetParent(parent)); else postRemove(resource); } if ((status & IResourceDelta.ADDED) != 0) { if (parent instanceof IPackageFragment) // refresh one level above to deal with empty package filtering properly postRefresh(internalGetParent(parent)); else postAdd(parent, resource); } IResourceDelta[] affectedChildren= delta.getAffectedChildren(); if (affectedChildren.length > 1) { // more than one child changed, refresh from here downwards postRefresh(resource); return; } for (int i= 0; i < affectedChildren.length; i++) processResourceDelta(affectedChildren[i], resource); }
Example 12
Source File: SearchResultUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void collectRemovals(Set<IAdaptable> removals, IResourceDelta delta) { if (delta.getKind() == IResourceDelta.REMOVED) removals.add(delta.getResource()); else { IResourceDelta[] children= delta.getAffectedChildren(); for (int i= 0; i < children.length; i++) { collectRemovals(removals, children[i]); } } }
Example 13
Source File: FilterUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void resourceChanged(IResourceChangeEvent event) { if (fViewer.getInput() == null) { return; } IResourceDelta delta= event.getDelta(); if (delta == null) return; IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED); for (int i= 0; i < projDeltas.length; i++) { IResourceDelta pDelta= projDeltas[i]; if ((pDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) { IProject project= (IProject) pDelta.getResource(); if (needsRefiltering(project)) { final Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { // async is needed due to bug 33783 ctrl.getDisplay().asyncExec(new Runnable() { public void run() { if (!ctrl.isDisposed()) fViewer.refresh(false); } }); } return; // one refresh is good enough } } } }
Example 14
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 15
Source File: EclipseJDTClassProvider.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
@Override public void resourceChanged(IResourceChangeEvent event) { if (event != null) { final IResourceDelta delta = event.getDelta(); for (IResourceDelta child : delta.getAffectedChildren()) { final IResource resource = child.getResource(); if (resource != null) { final IProject project = resource.getProject(); if (project != null) { classLoaders.remove(project.getName()); } } } } }
Example 16
Source File: DeltaProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void updateRootIndex(PackageFragmentRoot root, String[] pkgName, IResourceDelta delta) { Openable pkg = root.getPackageFragment(pkgName); updateIndex(pkg, delta); IResourceDelta[] children = delta.getAffectedChildren(); for (int i = 0, length = children.length; i < length; i++) { IResourceDelta child = children[i]; IResource resource = child.getResource(); if (resource instanceof IFolder) { String[] subpkgName = Util.arrayConcat(pkgName, resource.getName()); updateRootIndex(root, subpkgName, child); } } }
Example 17
Source File: UIResourceChangeRegistryTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public static String toReadableString(final IResourceDelta delta) { StringConcatenation _builder = new StringConcatenation(); IPath _fullPath = delta.getFullPath(); _builder.append(_fullPath); _builder.append(" "); String _switchResult = null; int _kind = delta.getKind(); switch (_kind) { case IResourceDelta.ADDED: _switchResult = "ADDED"; break; case IResourceDelta.REMOVED: _switchResult = "REMOVED"; break; case IResourceDelta.CHANGED: _switchResult = "CHANGED"; break; } _builder.append(_switchResult); _builder.append(" "); Pair<Integer, String> _mappedTo = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.CONTENT), "CONTENT"); Pair<Integer, String> _mappedTo_1 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.DERIVED_CHANGED), "DERIVED_CHANGED"); Pair<Integer, String> _mappedTo_2 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.DESCRIPTION), "DESCRIPTION"); Pair<Integer, String> _mappedTo_3 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.ENCODING), "ENCODING"); Pair<Integer, String> _mappedTo_4 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.LOCAL_CHANGED), "LOCAL_CHANGED"); Pair<Integer, String> _mappedTo_5 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.OPEN), "OPEN"); Pair<Integer, String> _mappedTo_6 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.MOVED_TO), "MOVED_TO"); Pair<Integer, String> _mappedTo_7 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.MOVED_FROM), "MOVED_FROM"); Pair<Integer, String> _mappedTo_8 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.COPIED_FROM), "COPIED_FROM"); Pair<Integer, String> _mappedTo_9 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.TYPE), "TYPE"); Pair<Integer, String> _mappedTo_10 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.SYNC), "SYNC"); Pair<Integer, String> _mappedTo_11 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.MARKERS), "MARKERS"); Pair<Integer, String> _mappedTo_12 = Pair.<Integer, String>of(Integer.valueOf(IResourceDelta.REPLACED), "REPLACED"); final Function1<Pair<Integer, String>, String> _function = (Pair<Integer, String> it) -> { String _xifexpression = null; if (((delta.getFlags() & (it.getKey()).intValue()) != 0)) { _xifexpression = it.getValue(); } else { _xifexpression = null; } return _xifexpression; }; String _join = IterableExtensions.join(IterableExtensions.<String>filterNull(ListExtensions.<Pair<Integer, String>, String>map(Collections.<Pair<Integer, String>>unmodifiableList(CollectionLiterals.<Pair<Integer, String>>newArrayList(_mappedTo, _mappedTo_1, _mappedTo_2, _mappedTo_3, _mappedTo_4, _mappedTo_5, _mappedTo_6, _mappedTo_7, _mappedTo_8, _mappedTo_9, _mappedTo_10, _mappedTo_11, _mappedTo_12)), _function)), ","); _builder.append(_join); _builder.append(" {"); _builder.newLineIfNotEmpty(); { IResourceDelta[] _affectedChildren = delta.getAffectedChildren(); for(final IResourceDelta child : _affectedChildren) { _builder.append("\t"); String _readableString = UIResourceChangeRegistryTest.TestUiResourceChangeRegistry.toReadableString(child); _builder.append(_readableString, "\t"); _builder.newLineIfNotEmpty(); } } _builder.append("}"); _builder.newLine(); return _builder.toString(); }
Example 18
Source File: PackageExplorerContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Process a resource delta. * * @param delta the delta to process * @param parent the parent * @param runnables the resulting view changes as runnables (type {@link Runnable}) * @return true if the parent got refreshed */ private boolean processResourceDelta(IResourceDelta delta, Object parent, Collection<Runnable> runnables) { int status= delta.getKind(); int flags= delta.getFlags(); IResource resource= delta.getResource(); // filter out changes affecting the output folder if (resource == null) return false; // this could be optimized by handling all the added children in the parent if ((status & IResourceDelta.REMOVED) != 0) { if (parent instanceof IPackageFragment) { // refresh one level above to deal with empty package filtering properly postRefresh(internalGetParent(parent), PARENT, parent, runnables); return true; } else { postRemove(resource, runnables); return false; } } if ((status & IResourceDelta.ADDED) != 0) { if (parent instanceof IPackageFragment) { // refresh one level above to deal with empty package filtering properly postRefresh(internalGetParent(parent), PARENT, parent, runnables); return true; } else { postAdd(parent, resource, runnables); return false; } } if ((status & IResourceDelta.CHANGED) != 0) { if ((flags & IResourceDelta.TYPE) != 0) { postRefresh(parent, PARENT, resource, runnables); return true; } } // open/close state change of a project if ((flags & IResourceDelta.OPEN) != 0) { postProjectStateChanged(internalGetParent(parent), runnables); return true; } IResourceDelta[] resourceDeltas= delta.getAffectedChildren(); int count= 0; for (int i= 0; i < resourceDeltas.length; i++) { int kind= resourceDeltas[i].getKind(); if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) { count++; if (count > 1) { postRefresh(parent, PARENT, resource, runnables); return true; } } } for (int i= 0; i < resourceDeltas.length; i++) { if (processResourceDelta(resourceDeltas[i], resource, runnables)) { return false; // early return, element got refreshed } } return false; }
Example 19
Source File: DefaultProjectResourceListener.java From goclipse with Eclipse Public License 1.0 | 4 votes |
protected void processWorkspaceDelta(IResourceDelta workspaceDelta) { for (IResourceDelta projectDelta : workspaceDelta.getAffectedChildren()) { processProjectDelta(projectDelta); } }
Example 20
Source File: CheckstyleBuilder.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
/** * Get the files for the build by analyzing the resource delta. * * @param delta * the delta of changes * @param filters * filters to exclude elements from the check * @return collection of files to build * @throws CoreException * an unexpected error occurred */ private Collection<IResource> getResources(final IResourceDelta delta, final IFilter[] filters) throws CoreException { List<IResource> resources = new ArrayList<>(); IResourceDelta[] affectedChildren = delta.getAffectedChildren(); for (int i = 0; i < affectedChildren.length; i++) { IResourceDelta childDelta = affectedChildren[i]; // check if a resource has changed int deltaKind = childDelta.getKind(); if ((deltaKind == IResourceDelta.ADDED) || (deltaKind == IResourceDelta.CHANGED)) { IResource child = childDelta.getResource(); // filter resources boolean goesThrough = true; for (int j = 0; j < filters.length; j++) { if (filters[j].isEnabled() && !filters[j].accept(child)) { goesThrough = false; break; } } // the child has made it through the filters if (goesThrough) { // add to the resources to check resources.add(child); } // recurse over containers if (child instanceof IContainer) { resources.addAll(getResources(childDelta, filters)); } } } return resources; }