Java 类org.eclipse.core.resources.mapping.ResourceMapping 实例源码

项目:subclipse    文件:TeamAction.java   
/**
 * 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;
}
项目:che    文件:JavaElementResourceMapping.java   
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;
  }
}
项目:che    文件:CopyModifications.java   
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);
    }
  }
}
项目:che    文件:PackageFragmentRootReorgChange.java   
@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();
  }
}
项目:chromedevtools    文件:FileBasedAction.java   
private static <RES> List<RES> readFiles(ResourceMapping resourceMapping,
    final FileFilter<RES> fileFilter) {
  final List<RES> fileList = new ArrayList<RES>(1);
  IResourceVisitor visitor = new IResourceVisitor() {
    public boolean visit(IResource resource) throws CoreException {
      if (resource instanceof IFile == false) {
        return true;
      } else {
        IFile file = (IFile) resource;
        RES res = fileFilter.accept(file);
        if (res != null) {
          fileList.add(res);
        }
        return false;
      }
    }
  };
  try {
    resourceMapping.accept(null, visitor, null);
  } catch (CoreException e) {
    throw new RuntimeException(e);
  }
  return fileList;
}
项目:APICloud-Studio    文件:TeamAction.java   
/**
 * 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;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaElementResourceMapping.java   
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;
    }

}
项目:Eclipse-Postfix-Code-Completion    文件:JavaModelAdapterFactory.java   
/**
 * {@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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaElementResourceMapping.java   
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;
    }

}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaModelAdapterFactory.java   
/**
 * {@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;
}
项目:n4js    文件:WorkingSet.java   
@SuppressWarnings("unchecked")
@Override
default <T> T getAdapter(final Class<T> adapter) {

    if (IWorkingSet.class == adapter || ResourceMapping.class == adapter) {
        return (T) new WorkingSetAdapter(this);
    }

    return Platform.getAdapterManager().getAdapter(this, adapter);
}
项目:subclipse    文件:SVNLightweightDecorator.java   
/**
 * Returns the resource for the given input object, or
 * null if there is no resource associated with it.
 *
 * @param object  the object to find the resource for
 * @return the resource for the given object, or null
 */
private IResource getResource(Object object) {
    if (object instanceof ResourceMapping) {
        object = ((ResourceMapping) object).getModelObject();
        return getModelObjectResource(object);
    }
    if (object instanceof IResource) {
        return (IResource) object;
    }
    if (object instanceof IAdaptable) {
        return (IResource) ((IAdaptable) object).getAdapter(
            IResource.class);
    }
    return null;
}
项目:che    文件:JavaElementResourceMapping.java   
@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;
}
项目:che    文件:JavaElementResourceMapping.java   
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;
}
项目:che    文件:JavaElementResourceMapping.java   
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;
}
项目:che    文件:JavaElementResourceMapping.java   
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;
}
项目:che    文件:CreateCopyOfCompilationUnitChange.java   
private void markAsExecuted(ICompilationUnit unit, ResourceMapping mapping) {
  ReorgExecutionLog log = (ReorgExecutionLog) getAdapter(ReorgExecutionLog.class);
  if (log != null) {
    log.markAsProcessed(unit);
    log.markAsProcessed(mapping);
  }
}
项目:che    文件:CreateCopyOfCompilationUnitChange.java   
@Override
public Change perform(IProgressMonitor monitor) throws CoreException {
  ResourceMapping mapping = JavaElementResourceMapping.create(fOldCu);
  final Change result = super.perform(monitor);
  markAsExecuted(fOldCu, mapping);
  return result;
}
项目:che    文件:CopyModifications.java   
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);
  }
}
项目:che    文件:PackageFragmentRootReorgChange.java   
private void markAsExecuted(IPackageFragmentRoot root, ResourceMapping mapping) {
  //        ReorgExecutionLog log= (ReorgExecutionLog)getAdapter(ReorgExecutionLog.class);
  //        if (log != null) {
  //            log.markAsProcessed(root);
  //            log.markAsProcessed(mapping);
  //        }
}
项目:che    文件:CompilationUnitReorgChange.java   
@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();
  }
}
项目:che    文件:CompilationUnitReorgChange.java   
private void markAsExecuted(ICompilationUnit unit, ResourceMapping mapping) {
  //        ReorgExecutionLog log= (ReorgExecutionLog)getAdapter(ReorgExecutionLog.class);
  //        if (log != null) {
  //            log.markAsProcessed(unit);
  //            log.markAsProcessed(mapping);
  //        }
}
项目:che    文件:PackageReorgChange.java   
@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();
  }
}
项目:che    文件:PackageReorgChange.java   
private void markAsExecuted(IPackageFragment pack, ResourceMapping mapping) {
  ReorgExecutionLog log = (ReorgExecutionLog) getAdapter(ReorgExecutionLog.class);
  if (log != null) {
    log.markAsProcessed(pack);
    log.markAsProcessed(mapping);
  }
}
项目:datahierarchy    文件:ElementAdapterFactory.java   
@Override
public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) {
    if (adaptable instanceof TreeElement<?, ?>) {
        TreeElement<?, ?> elt = (TreeElement<?, ?>) adaptable;
        return super.getAdaptedResourceMapping(elt.getJavaElement());
    }
    return super.getAdaptedResourceMapping(adaptable);
}
项目:gama    文件:OpenActionProvider.java   
private void addOpenWithMenu(final IMenuManager aMenu) {
    final IStructuredSelection ss = (IStructuredSelection) getContext().getSelection();
    if (ss == null || ss.size() != 1) { return; }
    final Object o = ss.getFirstElement();
    // first try IResource
    IAdaptable openable = (IAdaptable) AdaptabilityUtility.getAdapter(o, IResource.class);
    // otherwise try ResourceMapping
    if (openable == null) {
        openable = (IAdaptable) AdaptabilityUtility.getAdapter(o, ResourceMapping.class);
    } else if (((IResource) openable).getType() != IResource.FILE) {
        openable = null;
    }
    if (openable != null) {
        // Create a menu flyout.
        final IMenuManager submenu =
                new MenuManager(WorkbenchNavigatorMessages.OpenActionProvider_OpenWithMenu_label,
                        ICommonMenuConstants.GROUP_OPEN_WITH);
        submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
        submenu.add(new OpenWithMenu(viewSite.getPage(), openable));
        submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_ADDITIONS));

        // Add the submenu.
        if (submenu.getItems().length > 2 && submenu.isEnabled()) {
            aMenu.appendToGroup(ICommonMenuConstants.GROUP_OPEN_WITH, submenu);
        }
    }
}
项目:chromedevtools    文件:FileBasedAction.java   
private static <RES> List<RES> readFilesFromSelectionObject(Object element,
    FileFilter<RES> fileFilter) {
  if (element instanceof ResourceMapping == false) {
    return null;
  }
  ResourceMapping resourceMapping = (ResourceMapping) element;
  return readFiles(resourceMapping, fileFilter);
}
项目:APICloud-Studio    文件:SVNLightweightDecorator.java   
/**
 * Returns the resource for the given input object, or
 * null if there is no resource associated with it.
 *
 * @param object  the object to find the resource for
 * @return the resource for the given object, or null
 */
private IResource getResource(Object object) {
    if (object instanceof ResourceMapping) {
        object = ((ResourceMapping) object).getModelObject();
        return getModelObjectResource(object);
    }
    if (object instanceof IResource) {
        return (IResource) object;
    }
    if (object instanceof IAdaptable) {
        return (IResource) ((IAdaptable) object).getAdapter(
            IResource.class);
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateCopyOfCompilationUnitChange.java   
private void markAsExecuted(ICompilationUnit unit, ResourceMapping mapping) {
    ReorgExecutionLog log= (ReorgExecutionLog) getAdapter(ReorgExecutionLog.class);
    if (log != null) {
        log.markAsProcessed(unit);
        log.markAsProcessed(mapping);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CreateCopyOfCompilationUnitChange.java   
@Override
public Change perform(IProgressMonitor monitor) throws CoreException {
    ResourceMapping mapping= JavaElementResourceMapping.create(fOldCu);
    final Change result= super.perform(monitor);
    markAsExecuted(fOldCu, mapping);
    return result;
}
项目:Eclipse-Postfix-Code-Completion    文件:CopyModifications.java   
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);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CopyModifications.java   
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);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:MonitoringNewNameQueries.java   
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;
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:MonitoringNewNameQueries.java   
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;
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:MonitoringNewNameQueries.java   
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;
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:PackageFragmentRootReorgChange.java   
@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();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:PackageFragmentRootReorgChange.java   
private void markAsExecuted(IPackageFragmentRoot root, ResourceMapping mapping) {
    ReorgExecutionLog log= (ReorgExecutionLog)getAdapter(ReorgExecutionLog.class);
    if (log != null) {
        log.markAsProcessed(root);
        log.markAsProcessed(mapping);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CompilationUnitReorgChange.java   
@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();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CompilationUnitReorgChange.java   
private void markAsExecuted(ICompilationUnit unit, ResourceMapping mapping) {
    ReorgExecutionLog log= (ReorgExecutionLog)getAdapter(ReorgExecutionLog.class);
    if (log != null) {
        log.markAsProcessed(unit);
        log.markAsProcessed(mapping);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:PackageReorgChange.java   
@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();
    }
}