Example #1
0
  @Override
  public void actionPerformed(ActionEvent event) {
    final CurrentProject currentProject = appContext.getCurrentProject();

    if (currentProject == null || currentProject.getRootProject() == null) {
      return;
    }

    final ProjectDescriptor activeProject = currentProject.getRootProject();

    if (event.getParameters() == null) {
      Log.error(getClass(), localization.canNotOpenNodeWithoutParams());
      return;
    }

    final String path = event.getParameters().get(NODE_PARAM_ID);
    if (path == null || path.equals("")) {
      Log.error(getClass(), localization.nodeToOpenIsNotSpecified());
      return;
    }

    String nodePathToOpen =
        activeProject.getPath() + (!path.startsWith("/") ? "/".concat(path) : path);

    openNodeByPath(nodePathToOpen, currentProject, event);
  }
  public void openDeclaration() {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor == null) {
      return;
    }

    if (!(activeEditor instanceof EmbeddedTextEditorPresenter)) {
      Log.error(getClass(), "Open Declaration support only EmbeddedTextEditorPresenter as editor");
      return;
    }
    EmbeddedTextEditorPresenter editor = ((EmbeddedTextEditorPresenter) activeEditor);
    int offset = editor.getCursorOffset();
    final VirtualFile file = editor.getEditorInput().getFile();
    Unmarshallable<OpenDeclarationDescriptor> unmarshaller =
        factory.newUnmarshaller(OpenDeclarationDescriptor.class);
    navigationService.findDeclaration(
        file.getProject().getProjectConfig().getPath(),
        JavaSourceFolderUtil.getFQNForFile(file),
        offset,
        new AsyncRequestCallback<OpenDeclarationDescriptor>(unmarshaller) {
          @Override
          protected void onSuccess(OpenDeclarationDescriptor result) {
            if (result != null) {
              handleDescriptor(result);
            }
          }

          @Override
          protected void onFailure(Throwable exception) {
            Log.error(OpenDeclarationFinder.class, exception);
          }
        });
  }
 private void selectKeymap(final Keymap keymap) {
   resetKeymap();
   Keymap usedKeymap = keymap;
   if (usedKeymap == null) {
     usedKeymap = CodeMirrorKeymaps.DEFAULT;
     selectDefaultKeymap();
   } else if (CodeMirrorKeymaps.DEFAULT.equals(usedKeymap)) {
     selectDefaultKeymap();
   } else if (CodeMirrorKeymaps.EMACS.equals(usedKeymap)) {
     selectEmacsKeymap();
   } else if (CodeMirrorKeymaps.VIM.equals(usedKeymap)) {
     selectVimKeymap();
   } else if (CodeMirrorKeymaps.SUBLIME.equals(usedKeymap)) {
     selectSublimeKeymap();
   } else {
     usedKeymap = CodeMirrorKeymaps.DEFAULT;
     selectDefaultKeymap();
     Log.error(
         CodeMirrorEditorWidget.class,
         "Unknown keymap: " + keymap + " - replacing by default one.");
   }
   this.keymap = usedKeymap;
 }
  /**
   * Adds command node to process tree and displays command output
   *
   * @param machineId id of machine in which the command will be executed
   * @param outputConsole the console for command output
   */
  public void addCommandOutput(@NotNull String machineId, @NotNull OutputConsole outputConsole) {
    ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId);
    if (machineTreeNode == null) {
      notificationManager.notify(
          localizationConstant.failedToExecuteCommand(),
          localizationConstant.machineNotFound(machineId),
          FAIL,
          FLOAT_MODE);
      Log.error(getClass(), localizationConstant.machineNotFound(machineId));
      return;
    }

    String commandId;
    String outputConsoleTitle = outputConsole.getTitle();
    ProcessTreeNode processTreeNode = getProcessTreeNodeByName(outputConsoleTitle, machineTreeNode);
    if (processTreeNode != null && isCommandStopped(processTreeNode.getId())) {
      commandId = processTreeNode.getId();
      view.hideProcessOutput(commandId);
    } else {
      ProcessTreeNode commandNode =
          new ProcessTreeNode(
              COMMAND_NODE,
              machineTreeNode,
              outputConsoleTitle,
              outputConsole.getTitleIcon(),
              null);
      commandId = commandNode.getId();
      view.addProcessNode(commandNode);
      addChildToMachineNode(commandNode, machineTreeNode);
    }

    updateCommandOutput(commandId, outputConsole);

    resfreshStopButtonState(commandId);
    workspaceAgent.setActivePart(this);
  }