/** * Returns the selected resources. * * @return the selected resources */ protected IResource[] getSelectedResources() { ArrayList resourceArray = new ArrayList(); IResource[] resources = (IResource[])getSelectedResources(IResource.class); for (int i = 0; i < resources.length; i++) resourceArray.add(resources[i]); ResourceMapping[] resourceMappings = (ResourceMapping[])getSelectedAdaptables(selection, ResourceMapping.class); for (int i = 0; i < resourceMappings.length; i++) { ResourceMapping resourceMapping = (ResourceMapping)resourceMappings[i]; try { ResourceTraversal[] traversals = resourceMapping.getTraversals(null, null); for (int j = 0; j < traversals.length; j++) { IResource[] traversalResources = traversals[j].getResources(); for (int k = 0; k < traversalResources.length; k++) { if (!resourceArray.contains(traversalResources[k])) resourceArray.add(traversalResources[k]); } } } catch (CoreException e) { SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e); } } IResource[] selectedResources = new IResource[resourceArray.size()]; resourceArray.toArray(selectedResources); return selectedResources; }
private static ResourceTraversal[] getPackageFragmentTraversals(IPackageFragment pack) throws CoreException { ArrayList<ResourceTraversal> res = new ArrayList<ResourceTraversal>(); IContainer container = (IContainer) pack.getResource(); if (container != null) { res.add(new ResourceTraversal(new IResource[] {container}, IResource.DEPTH_ONE, 0)); if (pack.exists()) { // folder may not exist any more, see // https://bugs.eclipse.org/bugs/show_bug.cgi?id=269167 Object[] nonJavaResources = pack.getNonJavaResources(); for (int i = 0; i < nonJavaResources.length; i++) { Object resource = nonJavaResources[i]; if (resource instanceof IFolder) { res.add( new ResourceTraversal( new IResource[] {(IResource) resource}, IResource.DEPTH_INFINITE, 0)); } } } } return res.toArray(new ResourceTraversal[res.size()]); }
private static ResourceTraversal[] getRemotePackageFragmentTraversals( IPackageFragment pack, RemoteResourceMappingContext context, IProgressMonitor monitor) throws CoreException { ArrayList<ResourceTraversal> res = new ArrayList<ResourceTraversal>(); IContainer container = (IContainer) pack.getResource(); if (container != null) { res.add(new ResourceTraversal(new IResource[] {container}, IResource.DEPTH_ONE, 0)); IResource[] remoteMembers = context.fetchRemoteMembers(container, monitor); if (remoteMembers == null) { remoteMembers = context.fetchMembers(container, monitor); } if (remoteMembers != null) { for (int i = 0; i < remoteMembers.length; i++) { IResource member = remoteMembers[i]; if (member instanceof IFolder && JavaConventionsUtil.validatePackageName(member.getName(), pack).getSeverity() == IStatus.ERROR) { res.add(new ResourceTraversal(new IResource[] {member}, IResource.DEPTH_INFINITE, 0)); } } } } return res.toArray(new ResourceTraversal[res.size()]); }
@Override public ResourceTraversal[] getTraversals( ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { List<ResourceTraversal> result = new ArrayList<ResourceTraversal>(); if (context instanceof RemoteResourceMappingContext) { for (int i = 0; i < fFragments.length; i++) { result.addAll( Arrays.asList( getRemotePackageFragmentTraversals( fFragments[i], (RemoteResourceMappingContext) context, monitor))); } } else { for (int i = 0; i < fFragments.length; i++) { result.addAll(Arrays.asList(getPackageFragmentTraversals(fFragments[i]))); } } return result.toArray(new ResourceTraversal[result.size()]); }
private static ResourceTraversal[] getPackageFragmentTraversals(IPackageFragment pack) throws CoreException { ArrayList<ResourceTraversal> res= new ArrayList<ResourceTraversal>(); IContainer container= (IContainer)pack.getResource(); if (container != null) { res.add(new ResourceTraversal(new IResource[] { container }, IResource.DEPTH_ONE, 0)); if (pack.exists()) { // folder may not exist any more, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=269167 Object[] nonJavaResources= pack.getNonJavaResources(); for (int i= 0; i < nonJavaResources.length; i++) { Object resource= nonJavaResources[i]; if (resource instanceof IFolder) { res.add(new ResourceTraversal(new IResource[] { (IResource)resource }, IResource.DEPTH_INFINITE, 0)); } } } } return res.toArray(new ResourceTraversal[res.size()]); }
private static ResourceTraversal[] getRemotePackageFragmentTraversals(IPackageFragment pack, RemoteResourceMappingContext context, IProgressMonitor monitor) throws CoreException { ArrayList<ResourceTraversal> res= new ArrayList<ResourceTraversal>(); IContainer container= (IContainer)pack.getResource(); if (container != null) { res.add(new ResourceTraversal(new IResource[] {container}, IResource.DEPTH_ONE, 0)); IResource[] remoteMembers= context.fetchRemoteMembers(container, monitor); if (remoteMembers == null) { remoteMembers= context.fetchMembers(container, monitor); } if (remoteMembers != null) { for (int i= 0; i < remoteMembers.length; i++) { IResource member= remoteMembers[i]; if (member instanceof IFolder && JavaConventionsUtil.validatePackageName(member.getName(), pack).getSeverity() == IStatus.ERROR) { res.add(new ResourceTraversal(new IResource[] { member }, IResource.DEPTH_INFINITE, 0)); } } } } return res.toArray(new ResourceTraversal[res.size()]); }
@Override public ResourceTraversal[] getTraversals( ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { IJavaProject[] projects = fJavaModel.getJavaProjects(); ResourceTraversal[] result = new ResourceTraversal[projects.length]; for (int i = 0; i < projects.length; i++) { result[i] = new ResourceTraversal( new IResource[] {projects[i].getProject()}, IResource.DEPTH_INFINITE, 0); } return result; }
@Override public ResourceTraversal[] getTraversals( ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fProject.getProject()}, IResource.DEPTH_INFINITE, 0) }; }
@Override public ResourceTraversal[] getTraversals( ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fRoot.getResource()}, IResource.DEPTH_INFINITE, 0) }; }
@Override public ResourceTraversal[] getTraversals( ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { if (context instanceof RemoteResourceMappingContext) { return getRemotePackageFragmentTraversals( fPack, (RemoteResourceMappingContext) context, monitor); } else { return getPackageFragmentTraversals(fPack); } }
@Override public ResourceTraversal[] getTraversals( ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fUnit.getResource()}, IResource.DEPTH_ONE, 0) }; }
@Override public ResourceTraversal[] getTraversals( ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fClassFile.getResource()}, IResource.DEPTH_ONE, 0) }; }
/** * Returns the associated resource. * * <p>This method only returns a meaningful result if the history contains refactorings of a * single project. * * @return the associated resource, or <code>null</code> if the refactoring history contains * workspace refactoring descriptors only, or if it contains refactoring descriptors from * multiple projects. */ public final IResource getResource() { try { final ResourceTraversal[] traversals = getTraversals(null, null); if (traversals.length > 0) { final IResource[] resources = traversals[0].getResources(); if (resources.length > 0) return resources[0]; } } catch (CoreException exception) { RefactoringCorePlugin.log(exception); } return null; }
/** * Returns the associated resource. * * @return the associated resource, or <code>null</code> if the descriptor contains no timestamp * or project information */ public final IResource getResource() { try { final ResourceTraversal[] traversals = getTraversals(null, null); if (traversals.length > 0) { final IResource[] resources = traversals[0].getResources(); if (resources.length > 0) return resources[0]; } } catch (CoreException exception) { RefactoringCorePlugin.log(exception); } return null; }
/** {@inheritDoc} */ public final ResourceTraversal[] getTraversals( final ResourceMappingContext context, final IProgressMonitor monitor) throws CoreException { if (fResourceTraversals == null) { fResourceTraversals = new ResourceTraversal[] {}; final long stamp = fDescriptor.getTimeStamp(); if (stamp >= 0) { final IPath path = RefactoringHistoryManager.stampToPath(stamp); if (path != null) { final IProject[] projects = getProjects(); if (projects != null && projects.length == 1 && projects[0] != null) { final IFolder folder = projects[0] .getFolder(RefactoringHistoryService.NAME_HISTORY_FOLDER) .getFolder(path); fResourceTraversals = new ResourceTraversal[] { new ResourceTraversal( new IResource[] {folder.getFile(RefactoringHistoryService.NAME_HISTORY_FILE)}, IResource.DEPTH_ZERO, IResource.NONE), new ResourceTraversal( new IResource[] {folder.getFile(RefactoringHistoryService.NAME_INDEX_FILE)}, IResource.DEPTH_ZERO, IResource.NONE) }; } } } } final ResourceTraversal[] traversals = new ResourceTraversal[fResourceTraversals.length]; System.arraycopy(fResourceTraversals, 0, traversals, 0, fResourceTraversals.length); return traversals; }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { IJavaProject[] projects= fJavaModel.getJavaProjects(); ResourceTraversal[] result= new ResourceTraversal[projects.length]; for (int i= 0; i < projects.length; i++) { result[i]= new ResourceTraversal(new IResource[] {projects[i].getProject()}, IResource.DEPTH_INFINITE, 0); } return result; }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { if (context instanceof RemoteResourceMappingContext) { return getRemotePackageFragmentTraversals(fPack, (RemoteResourceMappingContext)context, monitor); } else { return getPackageFragmentTraversals(fPack); } }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { List<ResourceTraversal> result= new ArrayList<ResourceTraversal>(); if (context instanceof RemoteResourceMappingContext) { for (int i= 0; i < fFragments.length; i++) { result.addAll(Arrays.asList(getRemotePackageFragmentTraversals(fFragments[i], (RemoteResourceMappingContext)context, monitor))); } } else { for (int i= 0; i < fFragments.length; i++) { result.addAll(Arrays.asList(getPackageFragmentTraversals(fFragments[i]))); } } return result.toArray(new ResourceTraversal[result.size()]); }
/** * Returns the resource traversals for the element. * * @param element * the element to get the resource traversals * @return the resource traversals */ static ResourceTraversal[] getResourceTraversals(final Object element) { final ResourceMapping mapping= getResourceMapping(element); if (mapping != null) try { return mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, new NullProgressMonitor()); } catch (final CoreException exception) { JavaPlugin.log(exception); } return new ResourceTraversal[0]; }
@Override public ResourceTraversal[] getTraversals(final ResourceMappingContext context, final IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(getProjects(), DEPTH_INFINITE, 0) }; }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fProject.getProject()}, IResource.DEPTH_INFINITE, 0) }; }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fRoot.getResource()}, IResource.DEPTH_INFINITE, 0) }; }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fUnit.getResource()}, IResource.DEPTH_ONE, 0) }; }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fClassFile.getResource()}, IResource.DEPTH_ONE, 0) }; }
@Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] {fPack.getResource()}, IResource.DEPTH_INFINITE, 0) }; }
/** * {@inheritDoc} */ @Override public ResourceTraversal[] getTraversals(final ResourceMappingContext context, final IProgressMonitor monitor) { return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { fResource }, IResource.DEPTH_INFINITE, IResource.NONE) }; }
/** * {@inheritDoc} */ @Override protected ResourceTraversal[] getTraversals(final ISynchronizationContext context, final Object object) { return getResourceTraversals(object); }