Example #1
0
  @Override
  public void actionPerformed() {
    if (compilationUnit != null) {
      EditorPartPresenter editorPartPresenter =
          editorAgent.getOpenedEditor(Path.valueOf(compilationUnit.getPath()));
      if (editorPartPresenter != null) {
        editorAgent.activateEditor(editorPartPresenter);
        fileOpened(editorPartPresenter);
        return;
      }

      projectExplorer
          .getNodeByPath(new HasStorablePath.StorablePath(compilationUnit.getPath()))
          .then(selectNode())
          .then(openNode());
    } else if (classFile != null) {
      String className = classFile.getElementName();

      JarEntry jarEntry = dtoFactory.createDto(JarEntry.class);
      jarEntry.setName(className);
      jarEntry.setType(JarEntry.JarEntryType.CLASS_FILE);
      jarEntry.setPath(classFile.getPath());

      JarFileNode jarFileNode =
          javaNodeManager
              .getJavaNodeFactory()
              .newJarFileNode(
                  jarEntry,
                  null,
                  appContext.getCurrentProject().getProjectConfig(),
                  javaNodeManager.getJavaSettingsProvider().getSettings());
      openFile(jarFileNode);
    }
  }
  private void handleDescriptor(final OpenDeclarationDescriptor descriptor) {
    Map<String, EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors();
    for (String s : openedEditors.keySet()) {
      if (descriptor.getPath().equals(s)) {
        EditorPartPresenter editorPartPresenter = openedEditors.get(s);
        editorAgent.activateEditor(editorPartPresenter);
        fileOpened(editorPartPresenter, descriptor.getOffset());
        return;
      }
    }

    if (descriptor.isBinary()) {
      javaNodeManager
          .getClassNode(
              context.getCurrentProject().getProjectConfig(),
              descriptor.getLibId(),
              descriptor.getPath())
          .then(
              new Operation<Node>() {
                @Override
                public void apply(Node node) throws OperationException {
                  if (node instanceof VirtualFile) {
                    openFile((VirtualFile) node, descriptor);
                  }
                }
              });
    } else {
      projectExplorer
          .getNodeByPath(new HasStorablePath.StorablePath(descriptor.getPath()))
          .then(selectNode())
          .then(openNode(descriptor));
    }
  }