@UiHandler("importButton") public void onImportClicked(SelectionEvent<Item> event) { if (deviceCombo.getValue() == null) { new AlertMessageBox(i18n.error(), i18n.errFillFields()).show(); } else { new ImportDialog(deviceCombo.getValue()).show(); } }
@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)); } }
@UiHandler("loadButton") public void onLoadClicked(SelectEvent event) { archiveHandler.onLoad( deviceCombo.getValue(), getCombineDate(fromDate, fromTime), getCombineDate(toDate, toTime), !disableFilter.getValue(), snapToRoads.getValue(), new ArchiveStyle(style)); }
public void save(File f) { Properties save = new Properties(); OutputStream output = null; try { save.setProperty("provider", selectProviderCb.getValue()); save.setProperty("grain", selectGrainCb.getValue()); save.setProperty("weight", weightTf.getText()); save.setProperty("info", infoTa.getText()); for (Entry<String, TextField> entry : propertiesTf.entrySet()) { TextField tf = entry.getValue(); String propertyName = entry.getKey(); save.setProperty(propertyName, tf.getText()); if (tf.isDisable()) { save.setProperty(propertyName + "_ENABLED", "OFF"); } else { save.setProperty(propertyName + "_ENABLED", "ON"); } } output = new FileOutputStream(f); save.store(output, null); mainStage.setTitle(f.getName()); } catch (Exception ex) { infoTa.setText("Не могу сохранить в файл"); } finally { if (output != null) { try { output.close(); } catch (IOException e) { e.printStackTrace(); } } } }
@UiHandler("gpxButton") public void onGPXClicked(SelectionEvent<Item> event) { if (deviceCombo.getValue() == null) { new AlertMessageBox(i18n.error(), i18n.errFillFields()).show(); } else { DateTimeFormat jsonTimeFormat = ApplicationContext.getInstance().getFormatterUtil().getRequestTimeFormat(); Window.open( "/traccar/export/gpx" + "?deviceId=" + (deviceCombo.getValue() == null ? null : deviceCombo.getValue().getId()) + "&from=" + jsonTimeFormat.format(getCombineDate(fromDate, fromTime)).replaceFirst("\\+", "%2B") + "&to=" + jsonTimeFormat.format(getCombineDate(toDate, toTime)).replaceFirst("\\+", "%2B") + "&filter=" + !disableFilter.getValue() + "&snapToRoads=" + snapToRoads.getValue(), "_blank", null); } }
public void showHistory() { provider = getProvider(selectProviderCb.getValue()); try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/main/by/ggtu/dzmitry/view/History.fxml")); AnchorPane layout = (AnchorPane) loader.load(); HistoryController historyController = loader.getController(); Scene scene = new Scene(layout); Stage stage = new Stage(); stage.setScene(scene); stage.show(); } catch (IOException e) { e.printStackTrace(); } }
public void HandlerCalcPriceButton(ActionEvent event) { try { grain = getGrain(selectGrainCb.getValue()); System.out.println("> " + grain.getName()); try { grain.setWeight(Double.parseDouble(weightTf.getText())); } catch (NumberFormatException e) { weightTf.requestFocus(); throw new NumberFormatException("Вес партии зерна"); } for (Entry<String, TextField> entry : propertiesTf.entrySet()) { TextField tf = entry.getValue(); String propertyName = entry.getKey(); System.out.println("\t> " + propertyName); if (!tf.isDisable()) { try { grain.getProperty(propertyName).setValue(Double.parseDouble(tf.getText())); } catch (NumberFormatException e) { tf.requestFocus(); throw new NumberFormatException(grain.getProperty(propertyName).getDescription()); } grain.getProperty(propertyName).setEnabled(true); } else { grain.getProperty(propertyName).setEnabled(false); } } System.out.println("> before calculator"); PriceCalculator calculator = new PriceCalculator(grain, dao); calculator.calculatePrice(); infoTa.setText(calculator.toString()); Supply supply = new Supply(); supply.setProvider(selectProviderCb.getValue()); supply.setDate(new Date(Calendar.getInstance().getTimeInMillis())); // supply.setGrain(grain.getName()); supply.setGrain(grain.getDescription()); supply.setWeight(grain.getWeight()); supply.setPrice(calculator.getPrice()); dao.saveSupply(supply); } catch (RestrictiveConditionException e) { Utils.showErrorDialog("Ограшичительные кондиции!", e); infoTa.clear(); } catch (DataBaseException e) { Utils.showErrorDialog("Обшибка базы данных!", e); infoTa.clear(); } catch (NumberFormatException e) { Utils.showErrorDialog("Неверный ввод!", e); infoTa.clear(); } catch (Exception ex) { Utils.showErrorDialog("Ошибка!", ex); infoTa.clear(); } }