示例#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);
    }
  }