Ejemplo n.º 1
0
  /** Process a cut operation. */
  public void processCut() {

    if (getSelectedText() != null) {
      cut();
    } else {
      ProjectCompendium.APP.displayMessage(
          LanguageProperties.getString(LanguageProperties.UI_GENERAL_BUNDLE, "UITextArea.tryAgain"),
          LanguageProperties.getString(
              LanguageProperties.UI_GENERAL_BUNDLE,
              "UITextArea.title1")); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
Ejemplo n.º 2
0
  /** Approve the file selection against the required extension. */
  public void approveSelection() {

    File file = getSelectedFile();
    if (file == null) {
      // no file selected ... -> cancelSelection()
    } else {
      if (getDialogType() == JFileChooser.SAVE_DIALOG) {

        String fileName = file.getAbsolutePath();

        File newfile = file;
        if (fileName != null && !sRequiredExtension.equals("")) { // $NON-NLS-1$
          if (!fileName.toLowerCase().endsWith(sRequiredExtension)) {
            fileName = fileName + sRequiredExtension;
            newfile = new File(fileName);
            setSelectedFile(newfile);
          }
        }

        if (newfile.exists()) {
          int answer =
              JOptionPane.showConfirmDialog(
                  this,
                  LanguageProperties.getString(
                      LanguageProperties.UI_GENERAL_BUNDLE, "UIFileChooser.fileExists"),
                  LanguageProperties.getString(
                      LanguageProperties.UI_GENERAL_BUNDLE,
                      "UIFileChooser.warning"), //$NON-NLS-1$ //$NON-NLS-2$
                  JOptionPane.OK_CANCEL_OPTION,
                  JOptionPane.WARNING_MESSAGE);

          if (answer == JOptionPane.OK_OPTION) {
            super.approveSelection();
          } else {
            // a user cancelled over write.
          }
        } else {
          super.approveSelection();
        }
      } else if (getDialogType() == JFileChooser.OPEN_DIALOG) {

        String fileName = file.getAbsolutePath();
        if (fileName != null) {
          if (!sRequiredExtension.equals("")) { // $NON-NLS-1$

            if (!fileName.toLowerCase().endsWith(sRequiredExtension)) {
              JOptionPane.showMessageDialog(
                  this,
                  LanguageProperties.getString(
                          LanguageProperties.UI_GENERAL_BUNDLE, "UIFileChooser.selectFile")
                      + " '"
                      + sRequiredExtension
                      + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            } else {
              super.approveSelection();
            }
          } else {
            super.approveSelection();
          }
        }
      } else {
        super.approveSelection();
      }
    }
  }