Esempio n. 1
0
    public void actionPerformed(ActionEvent e) {
      int index = list.getSelectedIndex();
      if (index == -1) {
        return;
      }
      int returnVal = fc.showOpenDialog(fileBackupProgram.this);

      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        Path directory = file.toPath();

        try {
          destination.setText("Destination Directory: " + directory.toRealPath());
          // destField.setValue(directory.toRealPath());
        } catch (IOException x) {
          printer.printError(x.toString());
        }

        directoryList.getDirectory(index).setDestination(directory);
        startButton.setEnabled(true);
      } else {
        log.append("Open command cancelled by user." + newline);
      }
      log.setCaretPosition(log.getDocument().getLength());
    }
Esempio n. 2
0
    public void actionPerformed(ActionEvent e) {
      int returnVal = fc.showOpenDialog(fileBackupProgram.this);

      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        Path directory = file.toPath();
        directoryList.addNewDirectory(directory, 3600000, 14400000, copy);

        try {
          listModel.addElement(directory.toRealPath());
        } catch (IOException x) {
          printer.printError(x.toString());
        }

        int index = list.getSelectedIndex();
        if (index == -1) {
          list.setSelectedIndex(0);
        }

        index = list.getSelectedIndex();
        Directory dir = directoryList.getDirectory(index);

        if (dir.copy) {
          copyButton.setSelected(true);
        } else {
          moveButton.setSelected(true);
        }

        destButton.setEnabled(true);
        checkField.setValue(dir.getInterval());
        waitField.setValue(dir.getWaitInterval());
        checkField.setEditable(true);
        waitField.setEditable(true);

      } else {
        log.append("Open command cancelled by user." + newline);
      }
      log.setCaretPosition(log.getDocument().getLength());
    }