예제 #1
0
 @Override
 public void onAnything() {
   Device oldDevice = deviceCombo.getValue();
   if (oldDevice != null) {
     deviceCombo.setValue(deviceStore.findModel(oldDevice));
   } else if (deviceStore.size() == 1) {
     deviceCombo.setValue(deviceStore.get(0));
   }
 }
예제 #2
0
  public void initProviders() throws DataBaseException {
    providers = dao.getProviders();
    selectProviderCb.getItems().clear();

    for (Provider provider : providers) {
      selectProviderCb.getItems().add(provider.getName());
    }
    selectProviderCb.setValue(providers.get(0).getName());
  }
예제 #3
0
  public void open(File f) {
    Properties open = new Properties();
    InputStream input = null;

    try {
      input = new FileInputStream(f);
      open.load(input);

      selectProviderCb.setValue(open.getProperty("provider"));
      selectGrainCb.setValue(open.getProperty("grain"));
      weightTf.setText(open.getProperty("weight"));
      infoTa.setText(open.getProperty("info"));

      for (Entry<String, TextField> entry : propertiesTf.entrySet()) {
        String propertyName = entry.getKey();
        TextField tf = entry.getValue();
        CheckBox cb = propertiesCb.get(propertyName);

        tf.setText(open.getProperty(propertyName));
        if (open.getProperty(propertyName + "_ENABLED").equals("ON")) {
          tf.setDisable(false);
          cb.setSelected(true);
        } else {
          tf.setDisable(true);
          cb.setSelected(false);
        }
      }

      mainStage.setTitle(f.getName());
    } catch (Exception ex) {
      infoTa.setText("Не могу открыть файл");
    } finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
예제 #4
0
  public void newFile() {
    infoTa.setText("");
    selectProviderCb.setValue(providers.get(0).getName());
    weightTf.setText("0.0");

    for (Entry<String, TextField> entry : propertiesTf.entrySet()) {
      String propertyName = entry.getKey();
      TextField tf = entry.getValue();
      CheckBox cb = propertiesCb.get(propertyName);

      tf.setText("0.0");
      tf.setDisable(true);
      cb.setSelected(false);
    }

    file = null;
    mainStage.setTitle("unknown");
  }
예제 #5
0
  public void initGrains() {
    grains = new ArrayList<>();
    grains.add(new Wheat());
    grains.add(new Rice());
    for (Grain grain : grains) {
      selectGrainCb.getItems().add(grain.getDescription());
    }

    selectGrainCb
        .valueProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(ObservableValue ov, String t, String t1) {
                grain = getGrain(t1);
                initProperties(grain);
              }
            });

    selectGrainCb.setValue(grains.get(0).getDescription());
  }
예제 #6
0
 public void selectDevice(Device device) {
   deviceCombo.setValue(device, false);
 }