예제 #1
0
  @Override
  protected void doRun(IProgressMonitor progressMonitor) throws Exception {
    CDOTransaction transaction = getTransaction();
    CDOResourceNode node = null;

    if (createFolder) {
      node = EresourceFactory.eINSTANCE.createCDOResourceFolder();
      node.setName(resourceNodeName);
      if (selectedNode instanceof CDOResourceFolder) {
        ((CDOResourceFolder) selectedNode).getNodes().add(node);
      } else {
        ((CDOResource) selectedNode).getContents().add(node);
      }
    } else {
      if (selectedNode instanceof CDOResourceFolder) {
        node =
            transaction.createResource(
                selectedNode.getPath() + "/" + resourceNodeName); // $NON-NLS-1$
      } else {
        node = transaction.createResource(resourceNodeName);
      }
    }

    transaction.commit();

    itemProvider.refreshViewer(true);
    itemProvider.selectElement(node, true);

    if (!createFolder) {
      String resourcePath = node.getPath();
      CDOEditorUtil.openEditor(getPage(), transaction, resourcePath);
    }
  }
예제 #2
0
  @Override
  protected final void doRun(
      CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
      throws Exception {
    CDOResourceNode newResourceNode = createNewResourceNode();
    newResourceNode.setName(name);

    if (object instanceof CDOResourceFolder) {
      ((CDOResourceFolder) object).getNodes().add(newResourceNode);
    } else {
      transaction.getRootResource().getContents().add(newResourceNode);
    }
  }
  @Override
  public Object getParent(Object element) {
    if (element instanceof CDOResourceNode) {
      CDOResourceNode node = (CDOResourceNode) element;
      CDOResourceNode parent = (CDOResourceNode) node.eContainer();
      if (parent.isRoot()) {
        return parent.cdoView();
      }

      return parent;
    }

    return super.getParent(element);
  }