コード例 #1
0
  void generateBackupPaths() {
    ObservableList restorePaths = FXCollections.observableArrayList();
    restorePaths.clear();
    vBarBDirs.getChildren().clear();
    //        cbRestoreDirectory.getItems().clear();
    String[] backupArr = constants.getValue("s_dumpDir").split(";");
    for (final String dir : backupArr) {
      restorePaths.add(dir);
      HBox hbox = new HBox();
      Label lbl = new Label(dir);
      Button btn = new Button("Delete");
      btn.setOnAction(
          new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
              String nString = constants.getValue("s_dumpDir");
              nString = nString.replaceAll(";" + dir, "");
              nString = nString.replaceAll(dir, "");
              constants.addValue("s_dumpDir", nString);
              System.out.println(constants.getValue("s_dumpDir"));
              txtDir.setText(nString);
              generateBackupPaths();
            }
          });
      hbox.getChildren().add(lbl);
      hbox.getChildren().add(btn);
      vBarBDirs.getChildren().add(hbox);
    }

    try {

      cbRestoreDirectory.setItems(restorePaths);
      cbRestoreDirectory.setValue(restorePaths.get(0));
      generateRestore(restorePaths.get(0).toString());
    } catch (Exception e) {
      e.printStackTrace();
    }
    cbRestoreDirectory
        .valueProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(ObservableValue ov, String t, String t1) {
                //                System.out.println(ov);
                //                System.out.println(t);
                //                System.out.println(t1);
                generateRestore(t1);
              }
            });
  }
コード例 #2
0
  @FXML
  void browseDir() {

    DirectoryChooser directoryChooser = new DirectoryChooser();

    directoryChooser.setTitle("Select Archive Directory");
    // Show open file dialog

    File file = directoryChooser.showDialog(null);

    if (file != null) {

      txtDir.setText(txtDir.getText() + ";" + file.getPath());
      constants.addValue("s_dumpDir", txtDir.getText());
      generateBackupPaths();
    }
  }
コード例 #3
0
  @FXML
  void saveSettings() {
    //        AUTOUPLOAD
    if (chckboxautoUpload.isSelected()) {
      ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
      nvp.add(new BasicNameValuePair("value", "1"));
      tblsettings.save(nvp, "1");
      constants.addValue("s_autoupload", "1");
      Main.timer = new Timer();
      Main.timer.schedule(new Uploader(), 0, 15000);
    } else {
      ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
      nvp.add(new BasicNameValuePair("value", "0"));
      tblsettings.save(nvp, "1");
      constants.addValue("s_autoupload", "0");
      try {
        Main.timer.cancel();
      } catch (Exception e) {

      }
    }

    //        NRALCODE
    constants.addValue("s_nralcode", txtnralcode.getText());
    ArrayList<NameValuePair> nvp2 = new ArrayList<NameValuePair>();
    nvp2.add(new BasicNameValuePair("value", txtnralcode.getText()));
    tblsettings.save(nvp2, "2");

    //     ARCHIVE DIR
    constants.addValue("s_dumpDir", txtDir.getText());
    ArrayList<NameValuePair> nvp3 = new ArrayList<NameValuePair>();
    nvp2.add(new BasicNameValuePair("value", txtDir.getText()));
    tblsettings.save(nvp2, "3");

    //     ARCHIVE INTERVAL
    constants.addValue("s_backupInterval", txtinterval.getText());
    ArrayList<NameValuePair> nvp4 = new ArrayList<NameValuePair>();
    nvp2.add(new BasicNameValuePair("value", txtinterval.getText()));
    tblsettings.save(nvp2, "4");

    //     ARCHIVE COUNT
    constants.addValue("s_archiveCount", txtfiles.getText());
    ArrayList<NameValuePair> nvp5 = new ArrayList<NameValuePair>();
    nvp2.add(new BasicNameValuePair("value", txtfiles.getText()));
    tblsettings.save(nvp2, "5");

    closeSettings();
  }
コード例 #4
0
  public void initialize() {
    constants = Constants.getInstance();

    if (constants.getValue("s_autoupload").equalsIgnoreCase("1")) {
      chckboxautoUpload.setSelected(true);
    } else {
      chckboxautoUpload.setSelected(false);
    }

    txtnralcode.setText(constants.getValue("s_nralcode"));
    txtfiles.setText(constants.getValue("s_archiveCount"));
    txtinterval.setText(constants.getValue("s_backupInterval"));
    txtDir.setText(constants.getValue("s_dumpDir"));

    generateBackupPaths();

    //                generateRestore();

  }