Example #1
0
  @Override
  public void actionPerformed(ActionEvent pAE) {
    DocumentMaster docM = mOwner.getSelectedDocM();
    WorkflowModel wfModel = mOwner.getSelectedWorkflowModel();
    FolderTreeNode folderTreeNode = mOwner.getSelectedFolder();
    DocumentMasterTemplate template = mOwner.getSelectedDocMTemplate();
    MainController controller = MainController.getInstance();

    try {
      if (docM == null && wfModel == null && template == null && folderTreeNode != null) {
        if (folderTreeNode instanceof TagTreeNode) {
          String questionMsg =
              MessageFormat.format(
                  I18N.BUNDLE.getString("DeleteElement_question_tag"), folderTreeNode.getName());
          if (JOptionPane.YES_OPTION
              == JOptionPane.showConfirmDialog(
                  mOwner,
                  questionMsg,
                  I18N.BUNDLE.getString("DeleteElement_question_title"),
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.QUESTION_MESSAGE)) {
            controller.delTag(folderTreeNode.getName());
          }
        } else {
          String questionMsg =
              MessageFormat.format(
                  I18N.BUNDLE.getString("DeleteElement_question_folder"),
                  folderTreeNode.getCompletePath());
          if (JOptionPane.YES_OPTION
              == JOptionPane.showConfirmDialog(
                  mOwner,
                  questionMsg,
                  I18N.BUNDLE.getString("DeleteElement_question_title"),
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.QUESTION_MESSAGE)) {
            DocumentMasterKey[] pks = controller.delFolder(folderTreeNode.getCompletePath());
            for (DocumentMasterKey pk : pks) {
              FileIO.rmDir(Config.getCheckOutFolder(pk));
              FileIO.rmDir(Config.getCacheFolder(pk));
              Prefs.removeDocNode(pk);
            }
          }
        }
      } else if (docM != null) {
        String questionMsg =
            MessageFormat.format(I18N.BUNDLE.getString("DeleteElement_question_document"), docM);
        if (JOptionPane.YES_OPTION
            == JOptionPane.showConfirmDialog(
                mOwner,
                questionMsg,
                I18N.BUNDLE.getString("DeleteElement_question_title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)) {
          controller.delDocM(docM);
          FileIO.rmDir(Config.getCheckOutFolder(docM));
          FileIO.rmDir(Config.getCacheFolder(docM));
          Prefs.removeDocNode(docM);
        }
      } else if (wfModel != null) {
        String questionMsg =
            MessageFormat.format(I18N.BUNDLE.getString("DeleteElement_question_workflow"), wfModel);
        if (JOptionPane.YES_OPTION
            == JOptionPane.showConfirmDialog(
                mOwner,
                questionMsg,
                I18N.BUNDLE.getString("DeleteElement_question_title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)) {
          controller.delWorkflowModel(wfModel);
        }
      } else if (template != null) {
        String questionMsg =
            MessageFormat.format(
                I18N.BUNDLE.getString("DeleteElement_question_template"), template);
        if (JOptionPane.YES_OPTION
            == JOptionPane.showConfirmDialog(
                mOwner,
                questionMsg,
                I18N.BUNDLE.getString("DeleteElement_question_title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)) {
          controller.delDocMTemplate(template);
          FileIO.rmDir(Config.getCacheFolder(template));
        }
      }
    } catch (Exception pEx) {
      String message =
          pEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown") : pEx.getMessage();
      JOptionPane.showMessageDialog(
          null, message, I18N.BUNDLE.getString("Error_title"), JOptionPane.ERROR_MESSAGE);
    }
    ExplorerFrame.unselectElementInAllFrame();
  }