@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)); } }
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()); }
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(); } } } }
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"); }
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()); }
public void selectDevice(Device device) { deviceCombo.setValue(device, false); }