コード例 #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());
    }
コード例 #2
0
ファイル: Installer.java プロジェクト: suever/CTP
 private void setOwnership(File dir, String group, String owner) {
   try {
     Path path = dir.toPath();
     UserPrincipalLookupService lookupService =
         FileSystems.getDefault().getUserPrincipalLookupService();
     GroupPrincipal groupPrincipal = lookupService.lookupPrincipalByGroupName(group);
     UserPrincipal userPrincipal = lookupService.lookupPrincipalByName(owner);
     PosixFileAttributeView pfav =
         Files.getFileAttributeView(path, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
     pfav.setGroup(groupPrincipal);
     pfav.setOwner(userPrincipal);
   } catch (Exception ex) {
     cp.appendln("Unable to set the file group and owner for\n   " + dir);
   }
 }
コード例 #3
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());
    }