Beispiel #1
0
  /** {@inheritDoc} */
  @Override
  public void onCopyClicked() {
    final Project project = appContext.getRootProject();

    Preconditions.checkState(project != null);

    final Path src =
        view.isSourceCheckBoxSelected()
            ? Path.valueOf(view.getSourcePath())
            : toRelative(project, sourceNode);
    final Path target =
        view.isTargetCheckBoxSelected()
            ? Path.valueOf(view.getTargetUrl())
            : toRelative(project, this.target);
    final String comment = view.isTargetCheckBoxSelected() ? view.getComment() : null;

    final StatusNotification notification =
        new StatusNotification(
            constants.copyNotificationStarted(src.toString()), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);

    view.hide();

    performOperationWithCredentialsRequestIfNeeded(
            new RemoteSubversionOperation<CLIOutputResponse>() {
              @Override
              public Promise<CLIOutputResponse> perform(Credentials credentials) {
                notification.setStatus(PROGRESS);
                notification.setTitle(constants.copyNotificationStarted(src.toString()));

                return service.copy(project.getLocation(), src, target, comment, credentials);
              }
            },
            notification)
        .then(
            new Operation<CLIOutputResponse>() {
              @Override
              public void apply(CLIOutputResponse response) throws OperationException {
                printResponse(
                    response.getCommand(),
                    response.getOutput(),
                    response.getErrOutput(),
                    constants.commandCopy());

                notification.setTitle(constants.copyNotificationSuccessful());
                notification.setStatus(SUCCESS);
              }
            })
        .catchError(
            new Operation<PromiseError>() {
              @Override
              public void apply(PromiseError error) throws OperationException {
                notification.setTitle(constants.copyNotificationFailed());
                notification.setStatus(FAIL);
              }
            });
  }
Beispiel #2
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);
    }
  }
  public void openFile(final String filePath, final TextRange selectionRange) {
    if (Strings.isNullOrEmpty(filePath)) {
      return;
    }

    EditorPartPresenter editorPartPresenter = editorAgent.getOpenedEditor(Path.valueOf(filePath));
    if (editorPartPresenter != null) {
      editorAgent.activateEditor(editorPartPresenter);
      fileOpened(editorPartPresenter, selectionRange);
      return;
    }

    appContext.getWorkspaceRoot().getFile(filePath).then(openNode(selectionRange));
  }