Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  public void onSourceCheckBoxChanged() {
    // url path chosen
    if (view.isSourceCheckBoxSelected()) {
      view.setSourcePath("", true);
      view.setNewName("name");
    } else {
      view.setSourcePath(sourceNode.getLocation().toString(), false);
      view.setNewName(sourceNode.getName());
    }

    validate();
  }
Ejemplo n.º 2
0
  /** Show copy dialog. */
  public void showCopy() {
    final Project project = appContext.getRootProject();

    Preconditions.checkState(project != null && SvnUtil.isUnderSvn(project));

    final Resource[] resources = appContext.getResources();

    Preconditions.checkState(resources != null && resources.length == 1);

    sourceNode = resources[0];

    if (sourceNode.getResourceType() == Resource.FILE) {
      view.setDialogTitle(constants.copyViewTitleFile());
    } else {
      view.setDialogTitle(constants.copyViewTitleDirectory());
    }

    view.setNewName(sourceNode.getName());
    view.setComment(sourceNode.getName());
    view.setSourcePath(sourceNode.getLocation().toString(), false);

    validate();

    view.show();
    view.setProjectNode(project);
  }
Ejemplo n.º 3
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);
              }
            });
  }
Ejemplo n.º 4
0
  private void validate() {
    ValidationStrategy strategy;

    if (view.isSourceCheckBoxSelected()) {
      if (view.isTargetCheckBoxSelected()) {
        strategy = new UrlUrlValidation();
      } else {
        strategy = new UrlFileValidation();
      }
    } else {
      if (view.isTargetCheckBoxSelected()) {
        strategy = new FileUrlValidation();
      } else {
        strategy = new FileFileValidation();
      }
    }

    if (strategy.isValid()) {
      view.hideErrorMarker();
    }
  }
Ejemplo n.º 5
0
 /** {@inheritDoc} */
 @Override
 public void onCancelClicked() {
   view.hide();
 }