org.eclipse.core.resources.mapping.ResourceMapping Java Examples
The following examples show how to use
org.eclipse.core.resources.mapping.ResourceMapping.
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: JavaElementResourceMapping.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static ResourceMapping create(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.TYPE: return create((IType)element); case IJavaElement.COMPILATION_UNIT: return create((ICompilationUnit)element); case IJavaElement.CLASS_FILE: return create((IClassFile)element); case IJavaElement.PACKAGE_FRAGMENT: return create((IPackageFragment)element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return create((IPackageFragmentRoot)element); case IJavaElement.JAVA_PROJECT: return create((IJavaProject)element); case IJavaElement.JAVA_MODEL: return create((IJavaModel)element); default: return null; } }
Example #2
Source File: TeamAction.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #3
Source File: JavaModelAdapterFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ public Object getAdapter(final Object adaptable, final Class adapter) { if (adaptable instanceof JavaModelProvider) { if (adapter == IResourceMappingMerger.class) return new JavaModelMerger((ModelProvider) adaptable); else if (adapter == ISynchronizationCompareAdapter.class) return new JavaSynchronizationCompareAdapter(); } else if (adaptable instanceof RefactoringHistory) { if (adapter == ResourceMapping.class) return new JavaRefactoringHistoryResourceMapping((RefactoringHistory) adaptable); else if (adapter == IResource.class) return new JavaRefactoringHistoryResourceMapping((RefactoringHistory) adaptable).getResource(); } else if (adaptable instanceof RefactoringDescriptorProxy) { if (adapter == ResourceMapping.class) return new JavaRefactoringDescriptorResourceMapping((RefactoringDescriptorProxy) adaptable); } return null; }
Example #4
Source File: XdsVirtualContainer.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
@Override public synchronized Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { Object adapted = XdsElementCommons.adaptToResource(new IResourceAccess() { @Override public IResource getResource() throws CoreException { return resource; } }, adapter); if (adapted != null){ return adapted; } if (ResourceMapping.class.equals(adapter)) { return XdsElementUtils.createResourceMappingFrom(children, this); } else if (File.class.equals(adapter)) { return new File(getPath()); // TODO : convert path to java.io.File } return null; }
Example #5
Source File: JavaElementResourceMapping.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static ResourceMapping create(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.TYPE: return create((IType)element); case IJavaElement.COMPILATION_UNIT: return create((ICompilationUnit)element); case IJavaElement.CLASS_FILE: return create((IClassFile)element); case IJavaElement.PACKAGE_FRAGMENT: return create((IPackageFragment)element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return create((IPackageFragmentRoot)element); case IJavaElement.JAVA_PROJECT: return create((IJavaProject)element); case IJavaElement.JAVA_MODEL: return create((IJavaModel)element); default: return null; } }
Example #6
Source File: JavaElementResourceMapping.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean contains(ResourceMapping mapping) { if (mapping instanceof JavaElementResourceMapping) { JavaElementResourceMapping javaMapping = (JavaElementResourceMapping) mapping; IJavaElement element = getJavaElement(); IJavaElement other = javaMapping.getJavaElement(); if (other != null && element != null) return element.getPath().isPrefixOf(other.getPath()); } return false; }
Example #7
Source File: CopyModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void copy(IPackageFragmentRoot sourceFolder, CopyArguments javaArgs, CopyArguments resourceArgs) { add(sourceFolder, javaArgs, null); ResourceMapping mapping= JavaElementResourceMapping.create(sourceFolder); if (mapping != null) { add(mapping, resourceArgs, null); } IResource sourceResource= sourceFolder.getResource(); if (sourceResource != null) { getResourceModifications().addCopyDelta(sourceResource, resourceArgs); IFile classpath= getClasspathFile((IResource) resourceArgs.getDestination()); if (classpath != null) { getResourceModifications().addChanged(classpath); } } }
Example #8
Source File: CopyModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void copy(ICompilationUnit unit, CopyArguments javaArgs, CopyArguments resourceArgs) { add(unit, javaArgs, null); ResourceMapping mapping= JavaElementResourceMapping.create(unit); if (mapping != null) { add(mapping, resourceArgs, null); } if (unit.getResource() != null) { getResourceModifications().addCopyDelta(unit.getResource(), resourceArgs); } }
Example #9
Source File: MonitoringNewNameQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public INewNameQuery createNewCompilationUnitNameQuery(final ICompilationUnit cu, final String initialSuggestedName) { return new INewNameQuery() { public String getNewName() throws OperationCanceledException { String result= fDelegate.createNewCompilationUnitNameQuery(cu, initialSuggestedName).getNewName(); String newName= JavaModelUtil.getRenamedCUName(cu, result); fExecutionLog.setNewName(cu, newName); ResourceMapping mapping= JavaElementResourceMapping.create(cu); if (mapping != null) { fExecutionLog.setNewName(mapping, newName); } return result; } }; }
Example #10
Source File: MonitoringNewNameQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public INewNameQuery createNewPackageFragmentRootNameQuery(final IPackageFragmentRoot root, final String initialSuggestedName) { return new INewNameQuery() { public String getNewName() throws OperationCanceledException { String result= fDelegate.createNewPackageFragmentRootNameQuery(root, initialSuggestedName).getNewName(); fExecutionLog.setNewName(root, result); ResourceMapping mapping= JavaElementResourceMapping.create(root); if (mapping != null) { fExecutionLog.setNewName(mapping, result); } return result; } }; }
Example #11
Source File: MonitoringNewNameQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public INewNameQuery createNewPackageNameQuery(final IPackageFragment pack, final String initialSuggestedName) { return new INewNameQuery() { public String getNewName() throws OperationCanceledException { String result= fDelegate.createNewPackageNameQuery(pack, initialSuggestedName).getNewName(); fExecutionLog.setNewName(pack, result); ResourceMapping mapping= JavaElementResourceMapping.create(pack); if (mapping != null) { int index= result.lastIndexOf('.'); String newFolderName= index == -1 ? result : result.substring(index + 1); fExecutionLog.setNewName(mapping, newFolderName); } return result; } }; }
Example #12
Source File: PackageFragmentRootReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException { pm.beginTask(getName(), 2); try { String newName= getNewResourceName(); IPackageFragmentRoot root= getRoot(); ResourceMapping mapping= JavaElementResourceMapping.create(root); final Change result= doPerformReorg(getDestinationProjectPath().append(newName), new SubProgressMonitor(pm, 1)); markAsExecuted(root, mapping); return result; } finally { pm.done(); } }
Example #13
Source File: PackageFragmentRootReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void markAsExecuted(IPackageFragmentRoot root, ResourceMapping mapping) { ReorgExecutionLog log= (ReorgExecutionLog)getAdapter(ReorgExecutionLog.class); if (log != null) { log.markAsProcessed(root); log.markAsProcessed(mapping); } }
Example #14
Source File: CompilationUnitReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException { pm.beginTask(getName(), 1); try { ICompilationUnit unit= getCu(); ResourceMapping mapping= JavaElementResourceMapping.create(unit); Change result= doPerformReorg(new SubProgressMonitor(pm, 1)); markAsExecuted(unit, mapping); return result; } finally { pm.done(); } }
Example #15
Source File: CompilationUnitReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void markAsExecuted(ICompilationUnit unit, ResourceMapping mapping) { ReorgExecutionLog log= (ReorgExecutionLog)getAdapter(ReorgExecutionLog.class); if (log != null) { log.markAsProcessed(unit); log.markAsProcessed(mapping); } }
Example #16
Source File: PackageReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException { pm.beginTask(getName(), 1); try { IPackageFragment pack= getPackage(); ResourceMapping mapping= JavaElementResourceMapping.create(pack); final Change result= doPerformReorg(pm); markAsExecuted(pack, mapping); return result; } finally { pm.done(); } }
Example #17
Source File: PackageReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void markAsExecuted(IPackageFragment pack, ResourceMapping mapping) { ReorgExecutionLog log= (ReorgExecutionLog)getAdapter(ReorgExecutionLog.class); if (log != null) { log.markAsProcessed(pack); log.markAsProcessed(mapping); } }
Example #18
Source File: JavaElementResourceMapping.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public boolean contains(ResourceMapping mapping) { if (mapping instanceof JavaElementResourceMapping) { JavaElementResourceMapping javaMapping = (JavaElementResourceMapping) mapping; IJavaElement element = getJavaElement(); IJavaElement other = javaMapping.getJavaElement(); if (other != null && element != null) { return element.getPath().isPrefixOf(other.getPath()); } } return false; }
Example #19
Source File: JavaElementResourceMapping.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ResourceMapping create(final IPackageFragment pack) { // test if in an archive IPackageFragmentRoot root= (IPackageFragmentRoot)pack.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (!root.isArchive() && !root.isExternal()) { return new PackageFragmentResourceMapping(pack); } return null; }
Example #20
Source File: JavaElementResourceMapping.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ResourceMapping create(IClassFile classFile) { // test if in a archive IPackageFragmentRoot root= (IPackageFragmentRoot)classFile.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (!root.isArchive() && !root.isExternal()) { return new ClassFileResourceMapping(classFile); } return null; }
Example #21
Source File: JavaElementResourceMapping.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ResourceMapping create(IType type) { // top level types behave like the CU IJavaElement parent= type.getParent(); if (parent instanceof ICompilationUnit) { return create((ICompilationUnit)parent); } return null; }
Example #22
Source File: JavaElementResourceMapping.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ResourceMapping create(LogicalPackage logicalPackage) { IPackageFragment[] fragments= logicalPackage.getFragments(); List<IPackageFragment> toProcess= new ArrayList<IPackageFragment>(fragments.length); for (int i= 0; i < fragments.length; i++) { // only add if not part of an archive IPackageFragmentRoot root= (IPackageFragmentRoot)fragments[i].getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (!root.isArchive() && !root.isExternal()) { toProcess.add(fragments[i]); } } if (toProcess.size() == 0) return null; return new LogicalPackageResourceMapping(toProcess.toArray(new IPackageFragment[toProcess.size()])); }
Example #23
Source File: JavaElementAdapterFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) { IJavaElement je= getJavaElement(adaptable); if (je != null) return JavaElementResourceMapping.create(je); return null; }
Example #24
Source File: JavaModelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public ResourceMapping[] getMappings(final IResource resource, final ResourceMappingContext context, final IProgressMonitor monitor) throws CoreException { final IJavaElement element= JavaCore.create(resource); if (element != null) return new ResourceMapping[] { JavaElementResourceMapping.create(element)}; final Object adapted= resource.getAdapter(ResourceMapping.class); if (adapted instanceof ResourceMapping) return new ResourceMapping[] { ((ResourceMapping) adapted)}; return new ResourceMapping[] { new JavaResourceMapping(resource)}; }
Example #25
Source File: JavaSynchronizationContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the resource mapping for the element. * * @param element * the element to get the resource mapping * @return the resource mapping */ static ResourceMapping getResourceMapping(final Object element) { if (element instanceof IJavaElement) return JavaElementResourceMapping.create((IJavaElement) element); if (element instanceof IAdaptable) { final IAdaptable adaptable= (IAdaptable) element; final Object adapted= adaptable.getAdapter(ResourceMapping.class); if (adapted instanceof ResourceMapping) return (ResourceMapping) adapted; } return null; }
Example #26
Source File: JavaSynchronizationContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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]; }
Example #27
Source File: LogicalPackageAdapterFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Object getAdapter(Object element, Class key) { updateLazyLoadedAdapters(); if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key)) { return fSearchPageScoreComputer; } else if (ResourceMapping.class.equals(key)) { if (!(element instanceof LogicalPackage)) return null; return JavaElementResourceMapping.create((LogicalPackage)element); } return null; }
Example #28
Source File: LogicalPackageAdapterFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void createSearchPageScoreComputer() { fSearchPageScoreComputer= new JavaSearchPageScoreComputer(); PROPERTIES= new Class[] { ISearchPageScoreComputer.class, ResourceMapping.class }; }
Example #29
Source File: PackageFragmentRootReorgChange.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public final Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException { pm.beginTask(getName(), 2); try { String newName= getNewResourceName(); IPackageFragmentRoot root= getRoot(); ResourceMapping mapping= JavaElementResourceMapping.create(root); final Change result= doPerformReorg(getDestinationProjectPath().append(newName), new SubProgressMonitor(pm, 1)); markAsExecuted(root, mapping); return result; } finally { pm.done(); } }
Example #30
Source File: JavaElementResourceMapping.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static ResourceMapping create(final IPackageFragment pack) { // test if in an archive IPackageFragmentRoot root= (IPackageFragmentRoot)pack.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (!root.isArchive() && !root.isExternal()) { return new PackageFragmentResourceMapping(pack); } return null; }