Ejemplo n.º 1
0
public class ConflictOpenServerAction extends ConflictAction {
  private static ICarbonStudioLog log = Logger.getLog(Activator.PLUGIN_ID);

  /** execute action on the file */
  protected void execute(IFile file, IAction action) {
    String conflictResourceLocalCopy =
        RegistryCheckInClientUtils.getConflictResourceServerCopy(file.getLocation().toOSString());
    IFile conflictFile =
        file.getWorkspace().getRoot().getFileForLocation(new Path(conflictResourceLocalCopy));
    try {
      IEditorDescriptor defaultEditor = IDE.getEditorDescriptor(file);
      IWorkbenchPage activePage =
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      activePage.openEditor(new FileEditorInput(conflictFile), defaultEditor.getId());
    } catch (PartInitException e) {
      log.error(e);
    }
  }
}
Ejemplo n.º 2
0
public class WARArtifactContentProvider implements ICommonContentProvider {
  private static ICarbonStudioLog log = Logger.getLog(Activator.PLUGIN_ID);

  public void init(ICommonContentExtensionSite arg0) {}

  public Object[] getChildren(Object obj) {
    if (obj instanceof WARArtifactLocationNode) {
      WARArtifactLocationNode node = (WARArtifactLocationNode) obj;
      List<IResource> resources = getResources(node);
      //	    		if (resources.size()>0)
      return resources.toArray();
      //	    		else
      //	    			return new Object[]{"<Empty>"};
    }
    return new Object[] {};
  }

  private List<IResource> getResources(WARArtifactLocationNode node) {
    final IFolder folder = node.getProject().getFolder(node.getPath());
    final List<IResource> resources = new ArrayList<IResource>();
    try {
      folder.accept(
          new IResourceVisitor() {

            public boolean visit(IResource arg0) throws CoreException {
              if (folder.getFullPath().toOSString().equals(arg0.getFullPath().toOSString())) {
                return true;
              } else {
                resources.add(arg0);
                return false;
              }
            }
          });
    } catch (CoreException e) {
      log.error(e);
    }
    return resources;
  }

  public Object getParent(Object arg0) {
    return null;
  }

  public boolean hasChildren(Object obj) {
    if (obj instanceof WARArtifactLocationNode) {
      WARArtifactLocationNode node = (WARArtifactLocationNode) obj;
      return getResources(node).size() > 0;
    }
    return false;
  }

  public Object[] getElements(Object arg0) {
    return getChildren(arg0);
  }

  public void dispose() {}

  public void inputChanged(Viewer arg0, Object arg1, Object arg2) {}

  public void restoreState(IMemento arg0) {}

  public void saveState(IMemento arg0) {}
}