public void keyPressed(KeyEvent keyEvent) {
      AppLogger.finest(
          "keyModifiers=" + keyEvent.getModifiers() + " keyCode=" + keyEvent.getKeyCode());

      int keyCode = keyEvent.getKeyCode();
      if (keyCode == KeyEvent.VK_SHIFT
          || keyCode == KeyEvent.VK_CONTROL
          || keyCode == KeyEvent.VK_ALT
          || keyCode == KeyEvent.VK_META) return;

      KeyStroke pressedKeyStroke = KeyStroke.getKeyStrokeForEvent(keyEvent);

      if (pressedKeyStroke.equals(lastKeyStroke)) {
        TableCellEditor activeCellEditor = getCellEditor();
        if (activeCellEditor != null) activeCellEditor.stopCellEditing();
      } else {
        String actionId;
        if ((actionId = data.contains(pressedKeyStroke)) != null) {
          String errorMessage =
              "The shortcut ["
                  + KeyStrokeUtils.getKeyStrokeDisplayableRepresentation(pressedKeyStroke)
                  + "] is already assigned to '"
                  + ActionProperties.getActionDescription(actionId)
                  + "'";
          tooltipBar.showErrorMessage(errorMessage);
          createCancelEditingStateThread(getCellEditor());
        } else {
          lastKeyStroke = pressedKeyStroke;
          setText(KeyStrokeUtils.getKeyStrokeDisplayableRepresentation(lastKeyStroke));
        }
      }

      keyEvent.consume();
    }
    @Override
    public void setValueAt(Object value, int row, int column) {
      // if no keystroke was pressed
      if (value == null) return;
      // if the user pressed a keystroke that is used to indicate a delete operation should be made
      else if (value == DELETE) value = null;

      KeyStroke typedKeyStroke = (KeyStroke) value;
      switch (column) {
        case ACCELERATOR_COLUMN_INDEX:
          tableData.setAccelerator(typedKeyStroke, row);
          break;
        case ALTERNATE_ACCELERATOR_COLUMN_INDEX:
          tableData.setAlternativeAccelerator(typedKeyStroke, row);
          break;
        default:
          AppLogger.fine("Unexpected column index: " + column);
      }

      fireTableCellUpdated(row, column);

      AppLogger.finest("Value: " + value + ", row: " + row + ", col: " + column);
    }
Example #3
0
  /**
   * Copies recursively the given file or folder.
   *
   * @param file the file or folder to move
   * @param recurseParams destination folder where the given file will be copied (null for top level
   *     files)
   * @return <code>true</code> if the file has been copied.
   */
  @Override
  protected boolean processFile(AbstractFile file, Object recurseParams) {
    // Stop if interrupted
    if (getState() == INTERRUPTED) return false;

    // Destination folder
    AbstractFile destFolder = recurseParams == null ? baseDestFolder : (AbstractFile) recurseParams;

    // Is current file in base folder ?
    boolean isFileInBaseFolder = files.indexOf(file) != -1;

    // Determine filename in destination
    String destFileName;
    if (isFileInBaseFolder && newName != null) destFileName = newName;
    else destFileName = file.getName();

    // Create destination AbstractFile instance
    AbstractFile destFile = createDestinationFile(destFolder, destFileName);
    if (destFile == null) return false;
    currentDestFile = destFile;

    // Do nothing if file is a symlink (skip file and return)
    if (file.isSymlink()) return true;

    destFile = checkForCollision(file, destFolder, destFile, false);
    if (destFile == null) return false;

    // Copy directory recursively
    if (file.isDirectory()) {
      // Create the folder in the destination folder if it doesn't exist
      if (!(destFile.exists() && destFile.isDirectory())) {
        // Loop for retry
        do {
          try {
            destFile.mkdir();
          } catch (IOException e) {
            // Unable to create folder
            int ret =
                showErrorDialog(
                    errorDialogTitle, Translator.get("cannot_create_folder", destFileName));
            // Retry loops
            if (ret == RETRY_ACTION) continue;
            // Cancel or close dialog return false
            return false;
            // Skip continues
          }
          break;
        } while (true);
      }

      // and copy each file in this folder recursively
      do { // Loop for retry
        try {
          // for each file in folder...
          AbstractFile subFiles[] = file.ls();
          // filesDiscovered(subFiles);
          for (int i = 0; i < subFiles.length && getState() != INTERRUPTED; i++) {
            // Notify job that we're starting to process this file (needed for recursive calls to
            // processFile)
            nextFile(subFiles[i]);
            processFile(subFiles[i], destFile);
          }

          // Set currentDestFile back to the enclosing folder in case an overridden processFile
          // method
          // needs to work with the folder after calling super.processFile.
          currentDestFile = destFile;

          // Only when finished with folder, set destination folder's date to match the original
          // folder one
          if (destFile.isFileOperationSupported(FileOperation.CHANGE_DATE)) {
            try {
              destFile.changeDate(file.getDate());
            } catch (IOException e) {
              AppLogger.fine("failed to change the date of " + destFile, e);
              // Fail silently
            }
          }

          return true;
        } catch (IOException e) {
          // file.ls() failed
          int ret =
              showErrorDialog(
                  errorDialogTitle, Translator.get("cannot_read_folder", file.getName()));
          // Retry loops
          if (ret == RETRY_ACTION) continue;
          // Cancel, skip or close dialog returns false
          return false;
        }
      } while (true);
    }
    // File is a regular file, copy it
    else {
      // Copy the file
      return tryCopyFile(file, destFile, append, errorDialogTitle);
    }
  }
Example #4
0
 /** Prints out the process output. */
 public void processOutput(String output) {
   AppLogger.finest(command + ": " + output);
 }
Example #5
0
 /** Ignored. */
 public void processOutput(byte[] buffer, int offset, int length) {
   AppLogger.finest(command + ": " + new String(buffer, offset, length));
 }
Example #6
0
 /**
  * Prints out information about the way the process died.
  *
  * @param returnValue process' return value.
  */
 public void processDied(int returnValue) {
   AppLogger.finer(command + ": died with return code " + returnValue);
 }