示例#1
0
  public void actionPerformed(ActionEvent ae) {
    TreePath[] tree_paths = tree.getSelectionPaths();
    if (tree_paths.length == 0) {
      return;
    }
    if (tree_paths.length > 1) {
      JOptionPane.showMessageDialog(
          view, "Please select a single entry.", "Too many selections", JOptionPane.ERROR_MESSAGE);
      return;
    }
    String from_url = null;
    String defaultDestination = null;
    for (TreePath path : tree_paths) { // should be a single loop
      if (path != null) {
        Object[] parts = path.getPath();
        StringBuilder from = new StringBuilder();
        StringBuilder to = new StringBuilder();
        String preface = parts[0].toString();
        if (preface.endsWith("/")) {
          preface = preface.substring(0, preface.length() - 1);
        }
        from.append(preface);
        to.append(preface);
        for (int i = 1; i < parts.length; i++) {
          from.append("/").append(parts[i].toString());
        }
        for (int i = 1; i < parts.length - 1; i++) {
          if (parts[i].toString().equals("branches")) {
            continue;
          }
          to.append("/").append(parts[i].toString());
        }
        from_url = from.toString();
        defaultDestination = to.append("/tags").toString();
        break;
      }
    }

    TagBranchDialog dialog =
        new TagBranchDialog(view, TagBranchDialog.TAG_DIALOG, from_url, defaultDestination);
    GUIUtils.center(view, dialog);
    dialog.setVisible(true);
    CopyData cd = dialog.getData();
    if (cd != null) {
      if (username != null && password != null) {
        cd.setUsername(username);
        cd.setPassword(password);
      }
      cd.setTitle("Tag");
      CopyAction action = new CopyAction(view, cd);
      action.actionPerformed(null);
    }
  }
  public void actionPerformed(ActionEvent ae) {
    if (paths != null && paths.size() > 0) {
      dialog = new LockDialog(getView(), paths, false, remote);
      GUIUtils.center(getView(), dialog);
      dialog.setVisible(true);
      final CommitData data = dialog.getData();
      if (data == null) {
        return; // null means user canceled
      }

      if (getUsername() == null) {
        verifyLogin(data.getPaths() == null ? null : data.getPaths().get(0));
        if (isCanceled()) {
          return;
        }
      }
      data.setUsername(getUsername());
      data.setPassword(getPassword());
      data.setOut(new ConsolePrintStream(getView()));

      getView().getDockableWindowManager().showDockableWindow("subversion");
      final OutputPanel panel = SVNPlugin.getOutputPanel(getView());
      panel.showConsole();
      final Logger logger = panel.getLogger();
      logger.log(Level.INFO, jEdit.getProperty("ips.Unlocking_...", "Unlocking ..."));
      for (Handler handler : logger.getHandlers()) {
        handler.flush();
      }

      class Runner extends SwingWorker<LockResults, Object> {

        @Override
        public LockResults doInBackground() {
          try {
            Lock lock = new Lock();
            return lock.unlock(data);
          } catch (Exception e) {
            data.getOut().printError(e.getMessage());
          } finally {
            data.getOut().close();
          }
          return null;
        }

        @Override
        public boolean cancel(boolean mayInterruptIfRunning) {
          boolean cancelled = super.cancel(mayInterruptIfRunning);
          if (cancelled) {
            data.getOut().printError("Stopped 'Unlock' action.");
            data.getOut().close();
          } else {
            data.getOut().printError("Unable to stop 'Unlock' action.");
          }
          return cancelled;
        }

        @Override
        protected void done() {
          if (isCancelled()) {
            return;
          }

          try {
            JPanel results_panel =
                new AddResultsPanel(
                    get(), AddResultsPanel.UNLOCK, getView(), getUsername(), getPassword());
            panel.addTab(jEdit.getProperty("ips.Unlocked", "Unlocked"), results_panel);
          } catch (Exception e) { // NOPMD
            // ignored
          }
        }
      }
      Runner runner = new Runner();
      panel.addWorker("Unlock", runner);
      runner.execute();
    }
  }