Java Code Examples for org.eclipse.core.resources.IProject#accept()
The following examples show how to use
org.eclipse.core.resources.IProject#accept() .
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: ProjectBuilder.java From neoscada with Eclipse Public License 1.0 | 6 votes |
protected void validateAll ( final IProject project, final ComposedAdapterFactory adapterFactory, final Set<String> extensions, final IProgressMonitor monitor ) { logger.debug ( "Validating all resources of {}", project ); try { project.accept ( new IResourceVisitor () { @Override public boolean visit ( final IResource resource ) throws CoreException { return handleResource ( null, resource, adapterFactory, extensions, monitor ); } } ); } catch ( final CoreException e ) { StatusManager.getManager ().handle ( e.getStatus () ); } }
Example 2
Source File: SymbolModelManager.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
@Override protected void handleProjectRemoved(IResourceDelta delta, IProject affectedProject, boolean isPreDeleteEvent) { try { affectedProject.accept(new IResourceVisitor() { @Override public boolean visit(IResource r) throws CoreException { if (isCompilationUnitFile(r)) { SymbolModelManager.instance().scheduleRemove(Arrays.asList((IFile)r)); } return true; } }); } catch (CoreException e) { LogHelper.logError(e); } super.handleProjectRemoved(delta, affectedProject, isPreDeleteEvent); }
Example 3
Source File: ResourceUtils.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * Gets all resources (see {@link IResource}) matches specified {@link filter} * * @param project * @param filter - filter to match, if null - matches everything * @return all resources (see {@link IResource}) matches specified filter */ public static <T extends IResource> List<T> getProjectResources(IProject project, final Predicate<IResource> filter) { final List<T> resources = new ArrayList<T>(); try { project.accept(new IResourceVisitor() { @Override @SuppressWarnings("unchecked") public boolean visit(IResource r) throws CoreException { if (filter == null || filter.apply(r)) { resources.add((T)r); } return true; } }); } catch (CoreException e) { LogHelper.logError(e); } return resources; }
Example 4
Source File: DecoratorUtils.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
public static void refreshXdsDecorators(IProject project, String decoratorId){ IDecoratorManager decoratorManager = WorkbenchUtils.getWorkbench().getDecoratorManager(); if (decoratorManager != null && decoratorManager.getEnabled(decoratorId)) { final IXdsDecorator decorator = (IXdsDecorator)decoratorManager.getBaseLabelProvider(decoratorId); if (decorator != null && project.exists()) { try { project.accept(new IResourceVisitor() { @Override public boolean visit(IResource resource) throws CoreException { decorator.refresh(new IResource[]{resource}); return true; } }); } catch (CoreException e) { LogHelper.logError(e); } } } }
Example 5
Source File: DiagramPartitioningBreadcrumbViewer.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected Set<IFile> getProjectStatechartInput(Diagram diagram) { final IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); final IProject project = file.getProject(); final Set<IFile> result = new HashSet<IFile>(); try { project.accept(new IResourceVisitor() { public boolean visit(IResource resource) throws CoreException { // TODO check for package explorer filters here if (resource.isHidden()) { return false; } if (resource instanceof IFile) { if (file.getFileExtension().equals(resource.getFileExtension())) result.add((IFile) resource); } return true; } }); } catch (CoreException e) { e.printStackTrace(); } return result; }
Example 6
Source File: UnifiedBuilder.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * For a full build, we grab all files inside the project and then call build on each file. * * @param monitor * @throws CoreException */ private void fullBuild(List<IBuildParticipant> participants, IProgressMonitor monitor) throws CoreException { SubMonitor sub = SubMonitor.convert(monitor, 100); indexProjectBuildPaths(sub.newChild(50)); // Index files contributed... // TODO Remove these special "contributed" files? IProject project = getProjectHandle(); URI uri = project.getLocationURI(); Set<IFileStore> contributedFiles = getContributedFiles(uri); sub.worked(2); buildContributedFiles(participants, contributedFiles, sub.newChild(6)); // Now index the actual files in the project CollectingResourceVisitor visitor = new CollectingResourceVisitor(); project.accept(visitor); visitor.files.trimToSize(); // shrink it down to size when we're done sub.worked(2); buildFiles(participants, visitor.files, sub.newChild(40)); sub.done(); }
Example 7
Source File: SVNTeamProvider.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void configureTeamPrivateResource(IProject project) { try { project.accept( new IResourceVisitor() { public boolean visit(IResource resource) throws CoreException { if ((resource.getType() == IResource.FOLDER) && (resource.getName().equals(SVNProviderPlugin.getPlugin().getAdminDirectoryName())) && (!resource.isTeamPrivateMember())) { resource.setTeamPrivateMember(true); return false; } else { return true; } } }, IResource.DEPTH_INFINITE, IContainer.INCLUDE_PHANTOMS | IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS); } catch (CoreException e) { SVNProviderPlugin.log(SVNException.wrapException(e)); } }
Example 8
Source File: ToBeBuiltComputer.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Full build was triggered. Update all information that is available for the given project. * All contained resources are processed by {@link #updateStorage(IProgressMonitor, ToBeBuilt, IStorage)}. * * @see #updateStorage(IProgressMonitor, ToBeBuilt, IStorage) * @see #isHandled(IFolder) * @see IToBeBuiltComputerContribution#updateProject(ToBeBuilt, IProject, IProgressMonitor) */ public ToBeBuilt updateProject(IProject project, IProgressMonitor monitor) throws CoreException, OperationCanceledException { final SubMonitor progress = SubMonitor.convert(monitor, Messages.ToBeBuiltComputer_CollectingResources, 10); progress.subTask(Messages.ToBeBuiltComputer_CollectingResources); final ToBeBuilt toBeBuilt = doRemoveProject(project, progress.split(8)); if (!project.isAccessible()) return toBeBuilt; if (progress.isCanceled()) throw new OperationCanceledException(); final SubMonitor childMonitor = progress.split(1); project.accept(new IResourceVisitor() { @Override public boolean visit(IResource resource) throws CoreException { if (progress.isCanceled()) throw new OperationCanceledException(); if (resource instanceof IStorage) { return updateStorage(childMonitor, toBeBuilt, (IStorage) resource); } if (resource instanceof IFolder) { return isHandled((IFolder) resource); } return true; } }); if (progress.isCanceled()) throw new OperationCanceledException(); contribution.updateProject(toBeBuilt, project, progress.split(1)); return toBeBuilt; }
Example 9
Source File: ModelsFinder.java From gama with GNU General Public License v3.0 | 5 votes |
public static List<IFile> getAllGamaFilesInProject(final IProject project) { final ArrayList<IFile> allGamaFiles = new ArrayList<>(); try { if (project != null) project.accept(iR -> { if (GamlFileExtension.isAny(iR.getName())) allGamaFiles.add((IFile) iR.requestResource()); return true; }, IResource.FILE); } catch (final CoreException e) {} return allGamaFiles; }
Example 10
Source File: ModelsFinder.java From gama with GNU General Public License v3.0 | 5 votes |
public static List<URI> getAllGamaURIsInProject(final IProject project) { final ArrayList<URI> allGamaFiles = new ArrayList<>(); try { if (project != null) project.accept(iR -> { if (GamlFileExtension.isAny(iR.getName())) { final URI uri = URI.createPlatformResourceURI(iR.requestFullPath().toString(), true); allGamaFiles.add(uri); } return true; }, IResource.FILE); } catch (final CoreException e) {} return allGamaFiles; }
Example 11
Source File: SVNLightweightDecorator.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void refresh(IProject project) { final List resources = new ArrayList(); try { project.accept(new IResourceVisitor() { public boolean visit(IResource resource) { resources.add(resource); return true; } }); postLabelEvent(new LabelProviderChangedEvent(this, resources.toArray())); } catch (CoreException e) { SVNProviderPlugin.log(e.getStatus()); } }
Example 12
Source File: WebUtils.java From developer-studio with Apache License 2.0 | 4 votes |
public static IFile getWEBXmlLocation(IProject project) throws CoreException { FileNameResourceVisitor fileNameResourceVisitor = new FileNameResourceVisitor("web.xml",IResource.FILE); project.accept(fileNameResourceVisitor); List<IResource> resources = fileNameResourceVisitor.getResourceList(); return resources.size()==0? null: (IFile)resources.get(0); }