/**
   * executes a command that does not need any additional options from a dialog
   *
   * @param command command to be run
   * @param args parameters to configure the command correctly
   */
  private void executeCommand(Commandable command, Map args) {
    JSVNCommandExecutor executor = new JSVNCommandExecutor(command, args);
    executor.addJSVNEventListener(Application.getApplicationFrame());

    // invoke the executor in a separate thread
    Thread t = new Thread(executor);
    t.start();
  }
 /**
  * displays a dialog with the given message text
  *
  * @param message text to be displayed
  */
 private void showMessageDialog(String message) {
   JOptionPane.showMessageDialog(Application.getApplicationFrame().getContentPane(), message);
 }
 /** @param ae */
 public void actionPerformed(ActionEvent ae) {
   String targets = getSelectedTargetsAsString();
   if (targets == null) {
     // user hasn't selected anything -- pop-up a error message
   } else {
     if (ae.getActionCommand().equals(ACTION_ADD)) {
       // process add request
       Commandable command = new Add();
       Map args = new HashMap();
       args.put(Add.TARGETS, targets);
       executeCommand(command, args);
     } else if (ae.getActionCommand().equals(ACTION_CAT)) {
       // process cat request
       CommandDialog dialog = new CatDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_CHECKOUT)) {
       // process checkout request
       CommandDialog dialog = new CheckoutDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_CLEANUP)) {
       // check that all targets are directories
       TreePath[] paths = this.getSelectionPaths();
       for (int i = 0; i < paths.length; i++) {
         TreePath path = paths[i];
         DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) path.getLastPathComponent();
         SVNTreeNodeData svnNode = (SVNTreeNodeData) dmtn.getUserObject();
         if (svnNode.getNodeKind() != SVNTreeNodeData.NODE_KIND_DIRECTORY) {
           showMessageDialog(CLEANUP_ERROR + svnNode.getPath());
           return;
         }
       }
       // process cleanup request
       Commandable command = new Cleanup();
       Map args = new HashMap();
       args.put(Cleanup.TARGETS, targets);
       executeCommand(command, args);
     } else if (ae.getActionCommand().equals(ACTION_COMMIT)) {
       // process commit request
       CommandDialog dialog = new CommitDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_COPY)) {
       // process copy request
       CommandDialog dialog = new CopyDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_DELETE)) {
       // process delete request
       Commandable command = new Delete();
       Map args = new HashMap();
       args.put(Delete.TARGETS, targets);
       executeCommand(command, args);
     } else if (ae.getActionCommand().equals(ACTION_DIFF)) {
       // process diff request
       CommandDialog dialog = new DiffDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_INFO)) {
       // process info request
       Commandable command = new Info();
       Map args = new HashMap();
       args.put(Info.TARGETS, targets);
       executeCommand(command, args);
     } else if (ae.getActionCommand().equals(ACTION_LOG)) {
       // process log request
       CommandDialog dialog = new LogDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_LS)) {
       // process log request
       CommandDialog dialog = new LsDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_MERGE)) {
       // process merge request
       CommandDialog dialog = new MergeDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_MOVE)) {
       // process move request
       CommandDialog dialog = new MoveDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_REFRESH_ONLINE)) {
       // process recursive online refresh request
       refreshSelectedTargets(true);
     } else if (ae.getActionCommand().equals(ACTION_REFRESH_OFFLINE)) {
       // process recursive offline refresh request
       refreshSelectedTargets(false);
     } else if (ae.getActionCommand().equals(ACTION_RESOLVE)) {
       // process resolve request
       String message = RESOLVE_WARNING;
       String[] targetArray = getSelectedTargetsAsArray();
       for (int i = 0; i < targetArray.length; i++) {
         String s = targetArray[i];
         message += s + Constants.NEWLINE;
       }
       int confirmation =
           JOptionPane.showConfirmDialog(
               this, message, CONFIRMATION, JOptionPane.OK_CANCEL_OPTION);
       if (confirmation == JOptionPane.OK_OPTION) {
         // process add request
         Commandable command = new Resolve();
         Map args = new HashMap();
         args.put(Resolve.TARGETS, targets);
         executeCommand(command, args);
       }
     } else if (ae.getActionCommand().equals(ACTION_REVERT)) {
       // process revert request
       String message = REVERT_WARNING;
       String[] targetArray = getSelectedTargetsAsArray();
       for (int i = 0; i < targetArray.length; i++) {
         String s = targetArray[i];
         message += s + Constants.NEWLINE;
       }
       int confirmation =
           JOptionPane.showConfirmDialog(
               this, message, CONFIRMATION, JOptionPane.OK_CANCEL_OPTION);
       if (confirmation == JOptionPane.OK_OPTION) {
         // process add request
         Commandable command = new Revert();
         Map args = new HashMap();
         args.put(Revert.TARGETS, targets);
         executeCommand(command, args);
       }
     } else if (ae.getActionCommand().equals(ACTION_STATUS)) {
       // process status request
       CommandDialog dialog = new StatusDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_SWITCH)) {
       // process switch request
       CommandDialog dialog = new SwitchDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     } else if (ae.getActionCommand().equals(ACTION_UPDATE)) {
       // process update request
       CommandDialog dialog = new UpdateDialog(Application.getApplicationFrame(), true);
       initializeAndShowDialog(dialog, targets);
     }
   }
 }