List of usage examples for javafx.collections FXCollections observableArrayList
public static <E> ObservableList<E> observableArrayList(Collection<? extends E> col)
From source file:de.perdoctus.ebikeconnect.gui.ActivitiesOverviewController.java
@FXML public void initialize() { logger.info("Init!"); NUMBER_FORMAT.setMaximumFractionDigits(2); webEngine = webView.getEngine();/*from w w w .j a va 2s . c om*/ webEngine.load(getClass().getResource("/html/googleMap.html").toExternalForm()); // Activity Headers activityDaysHeaderService.setOnSucceeded(event -> { activitiesTable.setItems(FXCollections.observableArrayList(activityDaysHeaderService.getValue())); activitiesTable.getSortOrder().add(tcDate); tcDate.setSortable(true); }); activityDaysHeaderService.setOnFailed( event -> logger.error("Failed to obtain ActivityList!", activityDaysHeaderService.getException())); final ProgressDialog activityHeadersProgressDialog = new ProgressDialog(activityDaysHeaderService); activityHeadersProgressDialog.initModality(Modality.APPLICATION_MODAL); // Activity Details activityDetailsGroupService.setOnSucceeded( event -> this.currentActivityDetailsGroup.setValue(activityDetailsGroupService.getValue())); activityDetailsGroupService.setOnFailed(event -> logger.error("Failed to obtain ActivityDetails!", activityDaysHeaderService.getException())); final ProgressDialog activityDetailsProgressDialog = new ProgressDialog(activityDetailsGroupService); activityDetailsProgressDialog.initModality(Modality.APPLICATION_MODAL); // Gpx Export gpxExportService.setOnSucceeded(event -> gpxExportFinished()); gpxExportService .setOnFailed(event -> handleError("Failed to generate GPX File", gpxExportService.getException())); tcxExportService.setOnSucceeded(event -> gpxExportFinished()); tcxExportService .setOnFailed(event -> handleError("Failed to generate TCX File", tcxExportService.getException())); // ActivityTable tcDate.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDate())); tcDate.setCellFactory(param -> new LocalDateCellFactory()); tcDate.setSortType(TableColumn.SortType.DESCENDING); tcDistance.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDistance() / 1000)); tcDistance.setCellFactory(param -> new NumberCellFactory(1, "km")); tcDuration.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDrivingTime())); tcDuration.setCellFactory(param -> new DurationCellFactory()); activitiesTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); activitiesTable.getSelectionModel().getSelectedItems() .addListener((ListChangeListener<ActivityHeaderGroup>) c -> { while (c.next()) { if (c.wasRemoved()) { for (ActivityHeaderGroup activityHeaderGroup : c.getRemoved()) { lstSegments.getItems().removeAll(activityHeaderGroup.getActivityHeaders()); } } if (c.wasAdded()) { for (ActivityHeaderGroup activityHeaderGroup : c.getAddedSubList()) { if (activityHeaderGroup != null) { // WTF? Why can this be null!? lstSegments.getItems().addAll(activityHeaderGroup.getActivityHeaders()); } } } } lstSegments.getItems().sort((o1, o2) -> o1.getStartTime().isAfter(o2.getStartTime()) ? 1 : 0); }); activitiesTable.setOnMouseClicked(event -> { if (event.getClickCount() == 2) { lstSegments.getCheckModel().checkAll(); openSelectedSections(); } }); // Segment List lstSegments .setCellFactory(listView -> new CheckBoxListCell<>(item -> lstSegments.getItemBooleanProperty(item), new StringConverter<ActivityHeader>() { @Override public ActivityHeader fromString(String arg0) { return null; } @Override public String toString(ActivityHeader activityHeader) { final String startTime = activityHeader.getStartTime().format(DATE_TIME_FORMATTER); final String endTime = activityHeader.getEndTime().format(TIME_FORMATTER); final double distance = activityHeader.getDistance() / 1000; return startTime + " - " + endTime + " (" + NUMBER_FORMAT.format(distance) + " km)"; } })); // -- Chart chartRangeSlider.setLowValue(0); chartRangeSlider.setHighValue(chartRangeSlider.getMax()); xAxis.setAutoRanging(false); xAxis.lowerBoundProperty().bind(chartRangeSlider.lowValueProperty()); xAxis.upperBoundProperty().bind(chartRangeSlider.highValueProperty()); xAxis.tickUnitProperty().bind( chartRangeSlider.highValueProperty().subtract(chartRangeSlider.lowValueProperty()).divide(20)); xAxis.setTickLabelFormatter(new StringConverter<Number>() { @Override public String toString(Number object) { final Duration duration = Duration.of(object.intValue(), ChronoUnit.SECONDS); return String.valueOf(DurationFormatter.formatHhMmSs(duration)); } @Override public Number fromString(String string) { return null; } }); chart.getChart().setOnScroll(event -> { final double scrollAmount = event.getDeltaY(); chartRangeSlider.setLowValue(chartRangeSlider.getLowValue() + scrollAmount); chartRangeSlider.setHighValue(chartRangeSlider.getHighValue() - scrollAmount); }); xAxis.setOnMouseMoved(event -> { if (getCurrentActivityDetailsGroup() == null) { return; } final Number valueForDisplay = xAxis.getValueForDisplay(event.getX()); final List<Coordinate> trackpoints = getCurrentActivityDetailsGroup().getJoinedTrackpoints(); final int index = valueForDisplay.intValue(); if (index >= 0 && index < trackpoints.size()) { final Coordinate coordinate = trackpoints.get(index); if (coordinate.isValid()) { final LatLng latLng = new LatLng(coordinate); try { webEngine.executeScript( "updateMarkerPosition(" + objectMapper.writeValueAsString(latLng) + ");"); } catch (JsonProcessingException e) { e.printStackTrace(); //TODO clean up ugly code!!!!-------------- } } } }); // -- Current ActivityDetails this.currentActivityDetailsGroup.addListener((observable, oldValue, newValue) -> { if (newValue != null) { activityGroupChanged(newValue); } }); }
From source file:gov.va.isaac.gui.ConceptNode.java
/** * descriptionReader is optional//from ww w.j a va2 s . c o m */ public ConceptNode(ConceptVersionBI initialConcept, boolean flagAsInvalidWhenBlank, ObservableList<SimpleDisplayConcept> dropDownOptions, Function<ConceptVersionBI, String> descriptionReader) { c_ = initialConcept; //We can't simply use the ObservableList from the CommonlyUsedConcepts, because it infinite loops - there doesn't seem to be a way //to change the items in the drop down without changing the selection. So, we have this hack instead. listChangeListener_ = new ListChangeListener<SimpleDisplayConcept>() { @Override public void onChanged(Change<? extends SimpleDisplayConcept> c) { //TODO I still have an infinite loop here. Find and fix. logger.debug("updating concept dropdown"); disableChangeListener_ = true; SimpleDisplayConcept temp = cb_.getValue(); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setValue(temp); cb_.getSelectionModel().select(temp); disableChangeListener_ = false; } }; descriptionReader_ = (descriptionReader == null ? (conceptVersion) -> { return conceptVersion == null ? "" : OTFUtility.getDescription(conceptVersion); } : descriptionReader); dropDownOptions_ = dropDownOptions == null ? AppContext.getService(CommonlyUsedConcepts.class).getObservableConcepts() : dropDownOptions; dropDownOptions_.addListener(new WeakListChangeListener<SimpleDisplayConcept>(listChangeListener_)); conceptBinding_ = new ObjectBinding<ConceptVersionBI>() { @Override protected ConceptVersionBI computeValue() { return c_; } }; flagAsInvalidWhenBlank_ = flagAsInvalidWhenBlank; cb_ = new ComboBox<>(); cb_.setConverter(new StringConverter<SimpleDisplayConcept>() { @Override public String toString(SimpleDisplayConcept object) { return object == null ? "" : object.getDescription(); } @Override public SimpleDisplayConcept fromString(String string) { return new SimpleDisplayConcept(string, 0); } }); cb_.setValue(new SimpleDisplayConcept("", 0)); cb_.setEditable(true); cb_.setMaxWidth(Double.MAX_VALUE); cb_.setPrefWidth(ComboBox.USE_COMPUTED_SIZE); cb_.setMinWidth(200.0); cb_.setPromptText("Type, drop or select a concept"); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setVisibleRowCount(11); cm_ = new ContextMenu(); MenuItem copyText = new MenuItem("Copy Description"); copyText.setGraphic(Images.COPY.createImageView()); copyText.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { CustomClipboard.set(cb_.getEditor().getText()); } }); cm_.getItems().add(copyText); CommonMenusNIdProvider nidProvider = new CommonMenusNIdProvider() { @Override public Set<Integer> getNIds() { Set<Integer> nids = new HashSet<>(); if (c_ != null) { nids.add(c_.getNid()); } return nids; } }; CommonMenuBuilderI menuBuilder = CommonMenus.CommonMenuBuilder.newInstance(); menuBuilder.setInvisibleWhenFalse(isValid); CommonMenus.addCommonMenus(cm_, menuBuilder, nidProvider); cb_.getEditor().setContextMenu(cm_); updateGUI(); new LookAheadConceptPopup(cb_); if (cb_.getValue().getNid() == 0) { if (flagAsInvalidWhenBlank_) { isValid.setInvalid("Concept Required"); } } else { isValid.setValid(); } cb_.valueProperty().addListener(new ChangeListener<SimpleDisplayConcept>() { @Override public void changed(ObservableValue<? extends SimpleDisplayConcept> observable, SimpleDisplayConcept oldValue, SimpleDisplayConcept newValue) { if (newValue == null) { logger.debug("Combo Value Changed - null entry"); } else { logger.debug("Combo Value Changed: {} {}", newValue.getDescription(), newValue.getNid()); } if (disableChangeListener_) { logger.debug("change listener disabled"); return; } if (newValue == null) { //This can happen if someone calls clearSelection() - it passes in a null. cb_.setValue(new SimpleDisplayConcept("", 0)); return; } else { if (newValue.shouldIgnoreChange()) { logger.debug("One time change ignore"); return; } //Whenever the focus leaves the combo box editor, a new combo box is generated. But, the new box will have 0 for an id. detect and ignore if (oldValue != null && oldValue.getDescription().equals(newValue.getDescription()) && newValue.getNid() == 0) { logger.debug("Not a real change, ignore"); newValue.setNid(oldValue.getNid()); return; } lookup(); } } }); AppContext.getService(DragRegistry.class).setupDragAndDrop(cb_, new SingleConceptIdProvider() { @Override public String getConceptId() { return cb_.getValue().getNid() + ""; } }, true); pi_ = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); pi_.visibleProperty().bind(isLookupInProgress_); pi_.setPrefHeight(16.0); pi_.setPrefWidth(16.0); pi_.setMaxWidth(16.0); pi_.setMaxHeight(16.0); lookupFailImage_ = Images.EXCLAMATION.createImageView(); lookupFailImage_.visibleProperty().bind(isValid.not().and(isLookupInProgress_.not())); Tooltip t = new Tooltip(); t.textProperty().bind(isValid.getReasonWhyInvalid()); Tooltip.install(lookupFailImage_, t); StackPane sp = new StackPane(); sp.setMaxWidth(Double.MAX_VALUE); sp.getChildren().add(cb_); sp.getChildren().add(lookupFailImage_); sp.getChildren().add(pi_); StackPane.setAlignment(cb_, Pos.CENTER_LEFT); StackPane.setAlignment(lookupFailImage_, Pos.CENTER_RIGHT); StackPane.setMargin(lookupFailImage_, new Insets(0.0, 30.0, 0.0, 0.0)); StackPane.setAlignment(pi_, Pos.CENTER_RIGHT); StackPane.setMargin(pi_, new Insets(0.0, 30.0, 0.0, 0.0)); hbox_ = new HBox(); hbox_.setSpacing(5.0); hbox_.setAlignment(Pos.CENTER_LEFT); hbox_.getChildren().add(sp); HBox.setHgrow(sp, Priority.SOMETIMES); }
From source file:de.hs.mannheim.modUro.controller.diagram.SimulationDiagramController.java
/** * Initializes Choicebox Content./*from w w w . jav a 2s . co m*/ */ private void initializeChoiceboxContent() { List<String> name = choiceBoxMetrictypeNames(); int left = 0; int right = 0; for (String val : name) { if (val.equals(FitnessName.ARRANGEMENT_FITNESS.getName())) { left = name.indexOf(FitnessName.ARRANGEMENT_FITNESS.getName()); } if (val.equals(FitnessName.VOLUME_FITNESS.getName())) { right = name.indexOf(FitnessName.VOLUME_FITNESS.getName()); } } leftMetricType.setItems(FXCollections.observableArrayList(name)); rightMetricType.setItems(FXCollections.observableArrayList(name)); leftMetricType.getSelectionModel().select(left); rightMetricType.getSelectionModel().select(right); leftLastSelectedIndex = left; rightLastSelectedIndex = right; leftLastSelectedMetrictypename = name.get(leftLastSelectedIndex); rightLastSelectedMetrictypename = name.get(rightLastSelectedIndex); setLeftChartContent(left); setRightChartContent(right); }
From source file:dsfixgui.view.DSFHudPane.java
private void initialize() { //Basic layout this.setFitToWidth(true); spacerColumn = new ColumnConstraints(); spacerColumn.setFillWidth(true);//from ww w. ja v a 2 s . c o m spacerColumn.setPercentWidth(3.0); primaryColumn = new ColumnConstraints(); primaryColumn.setFillWidth(true); primaryColumn.setPercentWidth(95.0); primaryPane = new GridPane(); primaryPane.getColumnConstraints().addAll(spacerColumn, primaryColumn); primaryVBox = new VBox(); primaryVBox.getStyleClass().add("spacing_15"); primaryPane.add(primaryVBox, 1, 0); titleLabel = new Label(HUD.toUpperCase() + " " + SETTINGS.toUpperCase()); titleLabel.getStyleClass().add("settings_title"); titleBar = new HBox(); titleBar.setAlignment(Pos.CENTER); titleBar.getChildren().add(titleLabel); restoreDefaultsBar = new HBox(); restoreDefaultsBar.setAlignment(Pos.CENTER); restoreDefaultsBar.setSpacing(5.0); applySettingsButton = new Button(APPLY_SETTINGS); restoreDefaultsButton = new Button(RESTORE_DEFAULTS); applySettingsButton.getStyleClass().add("translate_y_4"); restoreDefaultsButton.getStyleClass().add("translate_y_4"); restoreDefaultsBar.getChildren().addAll(applySettingsButton, restoreDefaultsButton); spacerHBox = new HBox(); spacerHBox.setMinHeight(10.0); bottomSpacerHBox = new HBox(); bottomSpacerHBox.setMinHeight(10.0); /////////////////////SETTINGS PANES///////////////////// // // //Toggle HUD Modifications hudModsPane = new FlowPane(); hudModsPane.getStyleClass().add("settings_pane"); hudModsLabel = new Label(HUD_MODS_LABEL + " "); hudModsLabel.getStyleClass().addAll("bold_text", "font_12_pt"); hudModsLabel.setTooltip(new Tooltip(HUD_MODS_TT)); hudModsPicker = new ComboBox(FXCollections.observableArrayList(DISABLE_ENABLE)); if (config.enableHudMod.get() == 0) { hudModsPicker.setValue(hudModsPicker.getItems().get(0)); } else { hudModsPicker.setValue(hudModsPicker.getItems().get(1)); } hudModsPane.getChildren().addAll(hudModsLabel, hudModsPicker); // //Minimal HUD minimalHUDPane = new FlowPane(); minimalHUDPane.getStyleClass().add("settings_pane"); minimalHUDLabel = new Label(MINIMAL_HUD_LABEL + " "); minimalHUDLabel.getStyleClass().addAll("bold_text", "font_12_pt"); minimalHUDLabel.setTooltip(new Tooltip(MIN_HUD_TT)); minimalHUDPicker = new ComboBox(FXCollections.observableArrayList(DISABLE_ENABLE)); if (config.enableMinimalHud.get() == 0) { minimalHUDPicker.setValue(minimalHUDPicker.getItems().get(0)); } else { minimalHUDPicker.setValue(minimalHUDPicker.getItems().get(1)); } minimalHUDPane.getChildren().addAll(minimalHUDLabel, minimalHUDPicker); // //HUD Scale hudScalePane = new FlowPane(); hudScalePane.getStyleClass().add("settings_pane"); hudScaleLabel = new Label(HUD_SCALE_LABEL + " "); hudScaleLabel.getStyleClass().addAll("bold_text", "font_12_pt"); hudScaleLabel.setTooltip(new Tooltip(HUD_SCALE_TT)); hudScaleField = new TextField(config.hudScaleFactor.toString()); hudScaleField.getStyleClass().add("settings_med_text_field"); hudScalePane.getChildren().addAll(hudScaleLabel, hudScaleField); // //HUD Opacities Parent Label hudOpacitiesPane = new FlowPane(); hudOpacitiesPane.getStyleClass().add("settings_pane"); hudOpacitiesLabel = new Label(HUD_OPACITIES_LABEL + " "); hudOpacitiesLabel.getStyleClass().addAll("bold_text", "font_14_pt"); hudOpacitiesLabel.setTooltip(new Tooltip(HUD_OPS_TT)); hudOpacitiesPane.getChildren().addAll(hudOpacitiesLabel); // //Top Left HUD Opacity topLeftHUDOpPane = new FlowPane(); topLeftHUDOpPane.getStyleClass().add("settings_pane"); topLeftHUDOpLabel = new Label(TOP_LEFT_HUD_OP_LABEL + " "); topLeftHUDOpLabel.getStyleClass().addAll("bold_text", "font_12_pt"); topLeftHUDOpLabel.setTooltip(new Tooltip(TOP_LEFT_HUD_TT)); topLeftHUDOpField = new TextField( config.hudTopLeftOpacity.toString().substring(0, config.hudTopLeftOpacity.length() - 1)); topLeftHUDOpField.getStyleClass().add("settings_med_text_field"); topLeftHUDOpPane.getChildren().addAll(topLeftHUDOpLabel, topLeftHUDOpField); // //Bottom Left HUD Opacity bottomLeftHUDOpPane = new FlowPane(); bottomLeftHUDOpPane.getStyleClass().add("settings_pane"); bottomLeftHUDOpLabel = new Label(BOTTOM_LEFT_HUD_OP_LABEL + " "); bottomLeftHUDOpLabel.getStyleClass().addAll("bold_text", "font_12_pt"); bottomLeftHUDOpLabel.setTooltip(new Tooltip(BOTTOM_LEFT_HUD_TT)); bottomLeftHUDOpField = new TextField( config.hudBottomLeftOpacity.toString().substring(0, config.hudBottomLeftOpacity.length() - 1)); bottomLeftHUDOpField.getStyleClass().add("settings_med_text_field"); bottomLeftHUDOpPane.getChildren().addAll(bottomLeftHUDOpLabel, bottomLeftHUDOpField); // //Bottom Riht HUD Opacity bottomRightHUDOpPane = new FlowPane(); bottomRightHUDOpPane.getStyleClass().add("settings_pane"); bottomRightHUDOpLabel = new Label(BOTTOM_RIGHT_HUD_OP_LABEL + " "); bottomRightHUDOpLabel.getStyleClass().addAll("bold_text", "font_12_pt"); bottomRightHUDOpLabel.setTooltip(new Tooltip(BOTTOM_RIGHT_HUD_TT)); bottomRightHUDOpField = new TextField( config.hudBottomRightOpacity.toString().substring(0, config.hudBottomRightOpacity.length() - 1)); bottomRightHUDOpField.getStyleClass().add("settings_med_text_field"); bottomRightHUDOpPane.getChildren().addAll(bottomRightHUDOpLabel, bottomRightHUDOpField); if (config.enableHudMod.get() == 0) { minimalHUDPicker.setDisable(true); hudScaleField.setDisable(true); topLeftHUDOpField.setDisable(true); bottomLeftHUDOpField.setDisable(true); bottomRightHUDOpField.setDisable(true); } primaryVBox.getChildren().addAll(titleBar, restoreDefaultsBar, spacerHBox, hudModsPane, minimalHUDPane, hudScalePane, hudOpacitiesPane, topLeftHUDOpPane, bottomLeftHUDOpPane, bottomRightHUDOpPane, bottomSpacerHBox); initializeEventHandlers(); this.setContent(primaryPane); }
From source file:de.hs.mannheim.modUro.controller.diagram.ModeltypeDiagramController.java
/** * Sets Content of Choicebox.//from ww w. j ava 2 s. com */ private void setChoiceBoxContent() { List<String> name = modeltypeDiagram.getMetricTypeNames(); leftMetricType.setItems(FXCollections.observableArrayList(name)); rightMetricType.setItems(FXCollections.observableArrayList(name)); leftMetricType.getSelectionModel().select(leftLastSelectedIndex.intValue()); rightMetricType.getSelectionModel().select(rightLastSelectedIndex.intValue()); }
From source file:io.bitsquare.gui.components.paymentmethods.CryptoCurrencyForm.java
@Override protected void addTradeCurrencyComboBox() { currencyComboBox = addLabelSearchComboBox(gridPane, ++gridRow, "Altcoin:", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second; currencyComboBox.setPromptText("Select or search altcoin"); currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedCryptoCurrencies())); currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 15)); currencyComboBox.setConverter(new StringConverter<TradeCurrency>() { @Override// w ww . ja v a2s .co m public String toString(TradeCurrency tradeCurrency) { return tradeCurrency != null ? tradeCurrency.getNameAndCode() : ""; } @Override public TradeCurrency fromString(String s) { Optional<TradeCurrency> tradeCurrencyOptional = currencyComboBox.getItems().stream() .filter(tradeCurrency -> tradeCurrency.getNameAndCode().equals(s)).findAny(); if (tradeCurrencyOptional.isPresent()) return tradeCurrencyOptional.get(); else return null; } }); currencyComboBox.setOnAction(e -> { paymentAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); updateFromInputs(); }); }
From source file:io.bitsquare.gui.components.paymentmethods.BlockChainForm.java
@Override protected void addTradeCurrencyComboBox() { currencyComboBox = addLabelComboBox(gridPane, ++gridRow, "Cryptocurrency:", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second; currencyComboBox.setPromptText("Select cryptocurrency"); currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedCryptoCurrencies())); currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 20)); currencyComboBox.setConverter(new StringConverter<TradeCurrency>() { @Override/*from w ww .j a va 2 s . c o m*/ public String toString(TradeCurrency tradeCurrency) { return tradeCurrency.getNameAndCode(); } @Override public TradeCurrency fromString(String s) { return null; } }); currencyComboBox.setOnAction(e -> { paymentAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); updateFromInputs(); }); }
From source file:com.mycompany.pfinanzaspersonales.BuscadorController.java
@FXML private void btnBuscar(ActionEvent event) throws IOException { String desde_t = "", hasta_t = ""; if (input_desde.getValue() != null) { desde_t = input_desde.getValue().toString(); }/*from w ww . j a va 2 s . c om*/ if (input_hasta.getValue() != null) { hasta_t = input_hasta.getValue().toString(); } final String desde = desde_t; final String hasta = hasta_t; final Task<Void> tarea = new Task<Void>() { @Override protected Void call() throws Exception { HttpResponse response; List<NameValuePair> parametros = new ArrayList<NameValuePair>(); parametros.add(new BasicNameValuePair("tipo", cbb_tipo.getValue().toString())); parametros.add(new BasicNameValuePair("pago", cbb_pago.getValue().toString())); parametros.add(new BasicNameValuePair("desde", desde)); parametros.add(new BasicNameValuePair("hasta", hasta)); System.out.println(desde); response = JSON.request(Config.URL + "usuarios/buscar.json", parametros); JSONObject jObject = JSON.JSON(response); tabla_json = new ArrayList<TablaBuscar>(); try { editar.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("editar")); eliminar.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("eliminar")); fecha.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("fecha")); categoria.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("categoria")); tpago.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("pago")); tmonto.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("monto")); ttipo.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("tipo")); tabla_json = new ArrayList<TablaBuscar>(); if (!jObject.get("data").equals(null)) { JSONArray jsonArr = jObject.getJSONArray("data"); for (int i = 0; i < jsonArr.length(); i++) { JSONObject data_json = jsonArr.getJSONObject(i); tabla_json.add(new TablaBuscar(data_json.get("idgastos").toString(), data_json.get("idgastos").toString(), data_json.get("idgastos").toString(), data_json.get("monto").toString(), data_json.get("fecha").toString(), data_json.get("nom_mediopago").toString(), data_json.get("categoria").toString(), data_json.get("tipo").toString())); } } tabla_buscador.setItems(FXCollections.observableArrayList(tabla_json)); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void succeeded() { super.succeeded(); eliminar.setCellFactory(new Callback<TableColumn<String, String>, TableCell<String, String>>() { @Override public TableCell<String, String> call(TableColumn<String, String> p) { return new TableCell<String, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty() && !empty) { final VBox vbox = new VBox(5); Image image = new Image(getClass().getResourceAsStream("/Imagenes/delete.png")); final Button boton = new Button("", new ImageView(image)); boton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Action response = Dialogs.create().title("Eliminar Gasto") .message("Ests seguro que desaeas eliminar el gasto?") .showConfirm(); if (response == Dialog.ACTION_YES) { TablaBuscar tabla = tabla_json.get(getTableRow().getIndex()); List<NameValuePair> parametros = new ArrayList<NameValuePair>(); String url = ""; if (tabla.getTipo() == "Gastos") { parametros .add(new BasicNameValuePair("idgastos", tabla.getId())); url = Config.URL + "gastos/eliminar.json"; } else { parametros.add( new BasicNameValuePair("idingresos", tabla.getId())); url = Config.URL + "ingresos/eliminar.json"; } HttpResponse responseJSON = JSON.request(url, parametros); JSONObject jObject = JSON.JSON(responseJSON); int code = Integer.parseInt(jObject.get("code").toString()); if (code == 201) { int selectdIndex = getTableRow().getIndex(); tabla_json.remove(selectdIndex); tabla_buscador.getItems().remove(selectdIndex); } else { Dialogs.create().title("Error sincronizacin").message( "Hubo un error al intentar eliminar . ERROR: 301") .showInformation(); } } } }); vbox.getChildren().add(boton); setGraphic(vbox); } else { setGraphic(null); } } }; } }); editar.setCellFactory(new Callback<TableColumn<String, String>, TableCell<String, String>>() { @Override public TableCell<String, String> call(TableColumn<String, String> p) { return new TableCell<String, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty() && !empty) { final VBox vbox = new VBox(5); Image image = new Image(getClass().getResourceAsStream("/Imagenes/edit.png")); final Button boton = new Button("", new ImageView(image)); boton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { TablaBuscar tabla = tabla_json.get(getTableRow().getIndex()); Parent parent = null; if (tabla.getTipo() == "Gastos") { AgregarGastos AG = AgregarGastos.getInstance(); AG.setID(tabla.getId()); AG.setMonto(tabla.getMonto()); AG.setCategoria(tabla.getCategoria()); AG.setPago(tabla.getPago()); AG.setActualizacion(true); try { parent = FXMLLoader.load(this.getClass() .getResource("/fxml/AgregarGastos.fxml")); } catch (IOException ex) { Logger.getLogger(FXMLController.class.getName()) .log(Level.SEVERE, null, ex); } } else { AgregarIngresos AI = AgregarIngresos.getInstance(); AI.setID(tabla.getId()); AI.setMonto(tabla.getMonto()); AI.setCategoria(tabla.getCategoria()); AI.setPago(tabla.getPago()); AI.setActualizar(true); try { parent = FXMLLoader.load(this.getClass() .getResource("/fxml/AgregarIngresos.fxml")); } catch (IOException ex) { Logger.getLogger(FXMLController.class.getName()) .log(Level.SEVERE, null, ex); } } Stage stage = new Stage(); Scene scene = new Scene(parent); stage.setScene(scene); stage.show(); } }); vbox.getChildren().add(boton); setGraphic(vbox); } else { setGraphic(null); } } }; } }); } }; new Thread(tarea).start(); }
From source file:dsfixgui.view.DSFUnsafeSettingsPane.java
private void initialize() { //Basic layout this.setFitToWidth(true); spacerColumn = new ColumnConstraints(); spacerColumn.setFillWidth(true);/* w w w . j a va 2 s . co m*/ spacerColumn.setPercentWidth(3.0); primaryColumn = new ColumnConstraints(); primaryColumn.setFillWidth(true); primaryColumn.setPercentWidth(95.0); primaryPane = new GridPane(); primaryPane.getColumnConstraints().addAll(spacerColumn, primaryColumn); primaryVBox = new VBox(); primaryVBox.getStyleClass().add("spacing_15"); primaryPane.add(primaryVBox, 1, 0); titleLabel = new Label(UNSAFE_OPS.toUpperCase() + " " + SETTINGS.toUpperCase()); titleLabel.getStyleClass().addAll("settings_title", "red_text"); titleLabel.setTooltip(new Tooltip(UNSAFE_TT)); titleBar = new HBox(); titleBar.setAlignment(Pos.CENTER); titleBar.getChildren().add(titleLabel); restoreDefaultsBar = new HBox(); restoreDefaultsBar.setAlignment(Pos.CENTER); restoreDefaultsBar.setSpacing(5.0); applySettingsButton = new Button(APPLY_SETTINGS); restoreDefaultsButton = new Button(RESTORE_DEFAULTS); applySettingsButton.getStyleClass().add("translate_y_4"); restoreDefaultsButton.getStyleClass().add("translate_y_4"); restoreDefaultsBar.getChildren().addAll(applySettingsButton, restoreDefaultsButton); spacerHBox = new HBox(); spacerHBox.setMinHeight(10.0); bottomSpacerHBox = new HBox(); bottomSpacerHBox.setMinHeight(10.0); /////////////////////SETTINGS PANES///////////////////// // // //Force Window Modes windowModePane = new FlowPane(); windowModePane.getStyleClass().add("settings_pane"); windowModeLabel = new Label(FORCE_WINDOW_MODE_LABEL + " "); windowModeLabel.getStyleClass().addAll("bold_text", "font_12_pt"); windowModeChoice = new ToggleGroup(); neitherWindowMode = new RadioButton(WINDOW_MODES[0] + " "); neitherWindowMode.setToggleGroup(windowModeChoice); forceWindowed = new RadioButton(WINDOW_MODES[1]); forceWindowed.setToggleGroup(windowModeChoice); forceFullscreen = new RadioButton(WINDOW_MODES[2]); forceFullscreen.setToggleGroup(windowModeChoice); if (config.forceWindowed.get() == 0 && config.forceFullscreen.get() == 0) { neitherWindowMode.setSelected(true); } else if (config.forceWindowed.get() == 1) { forceWindowed.setSelected(true); config.forceFullscreen.set(0); } else { forceFullscreen.setSelected(true); } windowModePane.getChildren().addAll(windowModeLabel, neitherWindowMode, forceWindowed, forceFullscreen); // //Toggle Vsync vsyncPane = new FlowPane(); vsyncPane.getStyleClass().add("settings_pane"); vsyncLabel = new Label(VSYNC_LABEL + " "); vsyncLabel.getStyleClass().addAll("bold_text", "font_12_pt"); vsyncLabel.setTooltip(new Tooltip(VSYNC_TT)); vsyncPicker = new ComboBox(FXCollections.observableArrayList(DISABLE_ENABLE)); if (config.enableVsync.get() == 0) { vsyncPicker.setValue(vsyncPicker.getItems().get(0)); } else { vsyncPicker.setValue(vsyncPicker.getItems().get(1)); } vsyncPane.getChildren().addAll(vsyncLabel, vsyncPicker); // //Fullscreen Refresh Rate refreshRatePane = new FlowPane(); refreshRatePane.getStyleClass().add("settings_pane"); refreshRateLabel = new Label(REFRESH_RATE_LABEL + " "); refreshRateLabel.getStyleClass().addAll("bold_text", "font_12_pt"); refreshRateLabel.setTooltip(new Tooltip(FULLSCREEN_HZ_TT)); refreshRateField = new TextField("" + config.fullscreenHz.get()); refreshRateField.getStyleClass().add("settings_text_field"); refreshRatePane.getChildren().addAll(refreshRateLabel, refreshRateField); // primaryVBox.getChildren().addAll(titleBar, restoreDefaultsBar, spacerHBox, windowModePane, vsyncPane, refreshRatePane, bottomSpacerHBox); initializeEventHandlers(); this.setContent(primaryPane); }
From source file:io.bitsquare.gui.components.paymentmethods.SepaForm.java
@Override public void addFormForAddAccount() { gridRowFrom = gridRow + 1;/*from ww w .j a v a 2 s . c om*/ InputTextField holderNameInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Account holder name:").second; holderNameInputTextField.setValidator(inputValidator); holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { sepaAccount.setHolderName(newValue); updateFromInputs(); }); ibanInputTextField = addLabelInputTextField(gridPane, ++gridRow, "IBAN:").second; ibanInputTextField.setValidator(ibanValidator); ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { sepaAccount.setIban(newValue); updateFromInputs(); }); bicInputTextField = addLabelInputTextField(gridPane, ++gridRow, "BIC:").second; bicInputTextField.setValidator(bicValidator); bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { sepaAccount.setBic(newValue); updateFromInputs(); }); addLabel(gridPane, ++gridRow, "Country of bank:"); HBox hBox = new HBox(); hBox.setSpacing(10); ComboBox<Country> countryComboBox = new ComboBox<>(); currencyComboBox = new ComboBox<>(); currencyTextField = new TextField(""); currencyTextField.setEditable(false); currencyTextField.setMouseTransparent(true); currencyTextField.setFocusTraversable(false); currencyTextField.setMinWidth(300); currencyTextField.setVisible(false); currencyTextField.setManaged(false); currencyComboBox.setVisible(false); currencyComboBox.setManaged(false); hBox.getChildren().addAll(countryComboBox, currencyTextField, currencyComboBox); GridPane.setRowIndex(hBox, gridRow); GridPane.setColumnIndex(hBox, 1); gridPane.getChildren().add(hBox); countryComboBox.setPromptText("Select country of bank"); countryComboBox.setConverter(new StringConverter<Country>() { @Override public String toString(Country country) { return country.name + " (" + country.code + ")"; } @Override public Country fromString(String s) { return null; } }); countryComboBox.setOnAction(e -> { Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem(); sepaAccount.setCountry(selectedItem); TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(selectedItem.code); setupCurrency(selectedItem, currency); updateCountriesSelection(true, euroCountryCheckBoxes); updateCountriesSelection(true, nonEuroCountryCheckBoxes); updateFromInputs(); }); addEuroCountriesGrid(true); addNonEuroCountriesGrid(true); addAllowedPeriod(); addAccountNameTextFieldWithAutoFillCheckBox(); countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllSepaCountries())); Country country = CountryUtil.getDefaultCountry(); if (CountryUtil.getAllSepaCountries().contains(country)) { countryComboBox.getSelectionModel().select(country); sepaAccount.setCountry(country); TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(country.code); setupCurrency(country, currency); } updateFromInputs(); }