List of usage examples for javafx.scene.control ComboBox ComboBox
public ComboBox()
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;//ww w .j av a 2 s . c o m final GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); TableView tv = new TableView(); final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name"); final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount"); final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove"); firstDataColumn.setMinWidth(130); secondDataColumn.setMinWidth(130); thirdDataColumn.setMinWidth(130); if (!pfname.equals("")) { firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey)); rows = 0; tv = new TableView<>(generateDataInMap(pfname, addPairs)); } tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn); // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn()); ScrollPane sp = new ScrollPane(); sp.setMinWidth(400); sp.setHbarPolicy(ScrollBarPolicy.NEVER); sp.setContent(tv); grid.add(sp, 0, 3); final ComboBox comboBox = new ComboBox(); HBox hb1 = new HBox(); comboBox.setValue("FILE"); comboBox.getItems().addAll("Save this file", "Load a new file"); Button btnOk = new Button(); btnOk.setText("OK"); hb1.getChildren().addAll(comboBox, btnOk); hb1.setSpacing(10); grid.add(hb1, 0, 1); Label label1 = new Label("Title:"); final TextField tfFilename = new TextField(); tfFilename.setText(getTitle(pfname)); HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); grid.add(hb, 0, 2); final Stage ps = new Stage(); final TableView tv1 = tv; btnOk.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (comboBox.getValue().equals("Load a new file")) { first(ps); st.close(); } else { PrintWriter pw = null; try { pw = new PrintWriter("abc.json"); BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false)); bw.write("{title:\"" + tfFilename.getText() + "\""); bw.write(",fruits:["); for (int i = 0; i < rows; i++) { bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:" + String.valueOf(secondDataColumn.getCellData(i)) + "}"); if (i != rows - 1) bw.write(","); } bw.write("]}"); bw.close(); } catch (Exception e) { System.out.println(e.toString()); } } } }); Button btn = new Button(); btn.setText("New Fruit"); grid.add(btn, 1, 2); // TableView tv=new TableView(); // TableColumn Col1 = new TableColumn("Name"); // TableColumn Col2 = new TableColumn("Amount"); // TableColumn Col3 = new TableColumn("Remove"); // tv.getColumns().addAll(Col1, Col2, Col3); //sp.setFitToWidth(true); Image img = new Image("file:music.jpg"); ImageView iv2 = new ImageView(); iv2.setImage(img); iv2.setFitWidth(200); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); grid.add(iv2, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); System.out.println(comboBox.valueProperty()); st.close(); third(pfname); } }); scene = new Scene(grid, 700, 450); st.setScene(scene); st.show(); }
From source file:statos2_0.StatOS2_0.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); GridPane root = new GridPane(); Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); root.setAlignment(Pos.CENTER);/*from w w w. j ava 2 s . c om*/ root.setHgap(10); root.setVgap(10); root.setPadding(new Insets(25, 25, 25, 25)); Text scenetitle = new Text(""); root.add(scenetitle, 0, 0, 2, 1); scenetitle.setId("welcome-text"); Label userName = new Label(":"); //userName.setId("label"); root.add(userName, 0, 1); TextField userTextField = new TextField(); root.add(userTextField, 1, 1); Label pw = new Label(":"); root.add(pw, 0, 2); PasswordField pwBox = new PasswordField(); root.add(pwBox, 1, 2); ComboBox store = new ComboBox(); store.setItems(GetByTag()); root.add(store, 1, 3); Button btn = new Button(""); //btn.setPrefSize(100, 20); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); root.add(hbBtn, 1, 4); Button btn2 = new Button(""); //btn2.setPrefSize(100, 20); HBox hbBtn2 = new HBox(10); hbBtn2.setAlignment(Pos.BOTTOM_RIGHT); hbBtn2.getChildren().add(btn2); root.add(hbBtn2, 1, 5); final Text actiontarget = new Text(); root.add(actiontarget, 1, 6); btn2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.exit(0); } }); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (userTextField.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (pwBox.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (store.getSelectionModel().getSelectedIndex() < 0) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { try { String[] resu = checkpas(userTextField.getText(), pwBox.getText()); if (resu[0].equals("-1")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !" + "\n - "); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } else { // ... user chose CANCEL or closed the dialog } } else { // idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } } catch (NoSuchAlgorithmException ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } } /** * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){ * actiontarget.setId("acttrue"); * actiontarget.setText(" !"); * MainA ma = new MainA(); * ma.m=1; * try { * ma.m=1; * ma.MT="m1"; * ma.start(primaryStage); * } catch (Exception ex) { * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); * } * }else{ * actiontarget.setId("actfalse"); * actiontarget.setText(" !"); * } **/ } }); //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); //sSize.getHeight(); Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight()); primaryStage.setScene(scene); scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm()); primaryStage.show(); }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java
@Override public Region getContent() { if (hBox == null) { VBox statedInferredToggleGroupVBox = new VBox(); statedInferredToggleGroupVBox.setSpacing(4.0); //Instantiate Everything pathComboBox = new ComboBox<>(); //Path statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred List<RadioButton> statedInferredOptionButtons = new ArrayList<>(); datePicker = new DatePicker(); //Date timeSelectCombo = new ComboBox<Long>(); //Time //Radio buttons for (StatedInferredOptions option : StatedInferredOptions.values()) { RadioButton optionButton = new RadioButton(); if (option == StatedInferredOptions.STATED) { optionButton.setText("Stated"); } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) { optionButton.setText("Inferred Then Stated"); } else if (option == StatedInferredOptions.INFERRED) { optionButton.setText("Inferred"); } else { throw new RuntimeException("oops"); }/*from ww w .j av a2 s .c o m*/ optionButton.setUserData(option); optionButton.setTooltip( new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption())); statedInferredToggleGroup.getToggles().add(optionButton); statedInferredToggleGroupVBox.getChildren().add(optionButton); statedInferredOptionButtons.add(optionButton); } statedInferredToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData()); } }); //Path Combo Box pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() { @Override public ListCell<UUID> call(ListView<UUID> param) { final ListCell<UUID> cell = new ListCell<UUID>() { @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }; return cell; } }); pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }); pathComboBox.setOnAction((event) -> { if (!pathComboFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); if (selectedPath != null) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); StampBdb stampDb = Bdb.getStampDb(); NidSet nidSet = new NidSet(); nidSet.add(path); //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE); pathDatesList.clear(); // disableTimeCombo(true); timeSelectCombo.setValue(Long.MAX_VALUE); for (Integer thisStamp : stamps.getAsSet()) { try { Position stampPosition = stampDb.getPosition(thisStamp); this.stampDate = new Date(stampPosition.getTime()); stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); this.pathDatesList.add(stampDateInstant); //Build DatePicker } catch (Exception e) { e.printStackTrace(); } } datePicker.setValue(LocalDate.now()); } } else { pathComboFirstRun = false; } }); pathComboBox.setTooltip( new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\"")); //Calendar Date Picker final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate thisDate, boolean empty) { super.updateItem(thisDate, empty); if (pathDatesList != null) { if (pathDatesList.contains(thisDate)) { setDisable(false); } else { setDisable(true); } } } }; } }; datePicker.setDayCellFactory(dayCellFactory); datePicker.setOnAction((event) -> { if (!datePickerFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault())); Long dateSelected = Date.from(instant).getTime(); if (selectedPath != null && dateSelected != 0) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); setTimeOptions(path, dateSelected); try { timeSelectCombo.setValue(times.first()); //Default Dropdown Value } catch (Exception e) { // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled // Right now, Sometimes Time Combo is disabled, so we catch this and eat it // Otherwise make a conditional from the Read Only Boolean Property to check first } } else { disableTimeCombo(false); logger.debug("The path isn't set or the date isn't set. Both are needed right now"); } } else { datePickerFirstRun = false; } }); //Commit-Time ComboBox timeSelectCombo.setMinWidth(200); timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() { @Override public ListCell<Long> call(ListView<Long> param) { final ListCell<Long> cell = new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }; return cell; } }); timeSelectCombo.setButtonCell(new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }); try { currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty()); } catch (Exception e) { e.printStackTrace(); } // DEFAULT VALUES UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); storedTimePref = loggedIn.getViewCoordinateTime(); storedPathPref = loggedIn.getViewCoordinatePath(); if (storedPathPref != null) { pathComboBox.getItems().clear(); //Set the path Dates by default pathComboBox.getItems().addAll(getPathOptions()); final UUID storedPath = getStoredPath(); if (storedPath != null) { pathComboBox.getSelectionModel().select(storedPath); } if (storedTimePref != null) { final Long storedTime = loggedIn.getViewCoordinateTime(); Calendar cal = Calendar.getInstance(); cal.setTime(new Date(storedTime)); cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds Long storedTruncTime = cal.getTimeInMillis(); if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid(); setTimeOptions(path, storedTimePref); timeSelectCombo.setValue(storedTruncTime); // timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work Date storedDate = new Date(storedTime); datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); } else { datePicker.setValue(LocalDate.now()); timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work timeSelectCombo.setValue(Long.MAX_VALUE); // disableTimeCombo(false); } } else { //Stored Time Pref == null logger.error("ERROR: Stored Time Preference = null"); } } else { //Stored Path Pref == null logger.error("We could not load a stored path, ISAAC cannot run"); throw new Error("No stored PATH could be found. ISAAC can't run without a path"); } GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Label pathLabel = new Label("View Coordinate Path"); gridPane.add(pathLabel, 0, 0); //Path Label - Row 0 GridPane.setHalignment(pathLabel, HPos.LEFT); gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2 gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2 GridPane.setValignment(pathComboBox, VPos.TOP); Label datePickerLabel = new Label("View Coordinate Dates"); gridPane.add(datePickerLabel, 0, 2); //Row 3 GridPane.setHalignment(datePickerLabel, HPos.LEFT); gridPane.add(datePicker, 0, 3); //Row 4 Label timeSelectLabel = new Label("View Coordinate Times"); gridPane.add(timeSelectLabel, 1, 2); //Row 3 GridPane.setHalignment(timeSelectLabel, HPos.LEFT); gridPane.add(timeSelectCombo, 1, 3); //Row 4 // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY /* UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy(); UUID chosenPathUuid = userProfile.getViewCoordinatePath(); Long chosenTime = userProfile.getViewCoordinateTime(); Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid)); gridPane.add(printSelectedPathLabel, 0, 4); GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT); Label printSelectedTimeLabel = null; if(chosenTime != getDefaultTime()) { printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime))); } else { printSelectedTimeLabel = new Label("Time: LONG MAX VALUE"); } gridPane.add(printSelectedTimeLabel, 1, 4); GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT); Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy); gridPane.add(printSelectedPolicyLabel, 2, 4); GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT); */ hBox = new HBox(); hBox.getChildren().addAll(gridPane); allValid_ = new ValidBooleanBinding() { { bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (currentStatedInferredOptionProperty.get() == null) { this.setInvalidReason("Null/unset/unselected StatedInferredOption"); for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.setTextErrorColor(button); } return false; } else { for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.clearTextErrorColor(button); } } if (currentPathProperty.get() == null) { this.setInvalidReason("Null/unset/unselected path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) { this.setInvalidReason("Invalid path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } // if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE) // { // this.setInvalidReason("View Coordinate Time is unselected"); // TextErrorColorHelper.setTextErrorColor(timeSelectCombo); // return false; // } this.clearInvalidReason(); return true; } }; } // createButton.disableProperty().bind(saveButtonValid.not())); // Reload persisted values every time final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption(); for (Toggle toggle : statedInferredToggleGroup.getToggles()) { if (toggle.getUserData() == storedStatedInferredOption) { toggle.setSelected(true); } } // pathComboBox.setButtonCell(new ListCell<UUID>() { // @Override // protected void updateItem(UUID c, boolean emptyRow) { // super.updateItem(c, emptyRow); // if (emptyRow) { // setText(""); // } else { // String desc = OTFUtility.getDescription(c); // setText(desc); // } // } // }); // timeSelectCombo.setButtonCell(new ListCell<Long>() { // @Override // protected void updateItem(Long item, boolean emptyRow) { // super.updateItem(item, emptyRow); // if (emptyRow) { // setText(""); // } else { // setText(timeFormatter.format(new Date(item))); // } // } // }); // datePickerFirstRun = false; // pathComboFirstRun = false; return hBox; }
From source file:cz.lbenda.rcp.DialogHelper.java
/** Open dialog with chooser when user can choose single option * @param question question which is show to user * @param items list of items which user can choose * @param <T> type of item/* w ww . j a va 2 s . co m*/ * @return null if user click on cancel or don't choose anything, elsewhere choosed item */ @SuppressWarnings("unchecked") public static <T> T chooseSingOption(String question, T... items) { if (items.length == 0) { return null; } Dialog<T> dialog = new Dialog<>(); dialog.setResizable(false); dialog.setTitle(chooseSingleOption_title); dialog.setHeaderText(question); ComboBox<T> comboBox = new ComboBox<>(); comboBox.getItems().addAll(items); dialog.getDialogPane().setContent(comboBox); ButtonType btCancel = ButtonType.CANCEL; ButtonType btOk = ButtonType.OK; dialog.getDialogPane().getButtonTypes().addAll(btCancel, btOk); Optional<T> result = dialog.showAndWait(); if (result.isPresent()) { if (btCancel == result.get()) { return null; } if (btOk == result.get()) { return comboBox.getSelectionModel().getSelectedItem(); } } else { return null; } return result.get(); }
From source file:be.makercafe.apps.makerbench.editors.JFXMillEditor.java
/** * Creates the toolBar for the editor./*from w w w .j av a 2s. c o m*/ * * @return */ private ToolBar createToolBar() { ToolBar toolBar = new ToolBar(); toolBar.setOrientation(Orientation.HORIZONTAL); Button btnSave = GlyphsDude.createIconButton(MaterialDesignIcon.FLOPPY, "Save"); btnSave.setOnAction(this::handleSaveButton); Button btnExportSTL = GlyphsDude.createIconButton(MaterialDesignIcon.EXPORT, "Export GCODE"); btnExportSTL.setOnAction(this::handleExportAsGCodeFile); Button btnExportPNG = GlyphsDude.createIconButton(MaterialDesignIcon.CAMERA, "Export PNG"); btnExportPNG.setOnAction(this::handleExportAsPngFile); Button btnRun = GlyphsDude.createIconButton(MaterialDesignIcon.RUN, "Run"); btnRun.setOnAction(this::handleCompileAndRun); ToggleButton btnAutoCompile = GlyphsDude.createIconToggleButton(MaterialDesignIcon.AUTO_FIX, "Automatic run", null, ContentDisplay.LEFT); btnAutoCompile.setOnAction(this::handleAutoCompile); btnAutoCompile.setSelected(false); ToggleButton btn3DNav = GlyphsDude.createIconToggleButton(MaterialDesignIcon.ROTATE_3D, "3D Navigation ", null, ContentDisplay.LEFT); btn3DNav.setSelected(false); ComboBox cbxSourceExamples = new ComboBox(); cbxSourceExamples.getItems().addAll("TestCut"); this.cbxSourceExamples = cbxSourceExamples; // TODO: maybe cleaner way // to do this ? Button btnPasteSource = GlyphsDude.createIconButton(MaterialDesignIcon.CONTENT_PASTE, "Paste source"); btnPasteSource.setOnAction(this::handlePasteSource); toolBar.getItems().addAll(btnSave, btnExportSTL, btnExportPNG, new Separator(), btnRun, new Separator(), btnAutoCompile, new Separator(), cbxSourceExamples, btnPasteSource); return toolBar; }
From source file:account.management.controller.NewVoucherController.java
@FXML private void onAddNewFieldButtonClick(ActionEvent event) { HBox row = new HBox(); row.setId("field_row"); ComboBox<Account> select_account = new ComboBox<>(); if (this.select_type.getSelectionModel().isEmpty()) { select_account.getItems().addAll(this.account_list); } else {/*w w w .j a v a 2s . c o m*/ select_account.getItems().addAll(this.filter_acc); } TextField dr = new TextField(); TextField cr = new TextField(); TextField remarks = new TextField(); Button del_row = new Button("Delete"); row.setSpacing(field_row.getSpacing()); ComboBox<Account> combo = (ComboBox) field_row.getChildren().get(0); select_account.setPrefWidth(combo.getPrefWidth()); select_account.setPromptText("Select account"); TextField tf = (TextField) field_row.getChildren().get(1); dr.setPrefWidth(tf.getPrefWidth()); dr.setPromptText("Dr"); tf = (TextField) field_row.getChildren().get(2); cr.setPrefWidth(tf.getPrefWidth()); cr.setPromptText("Cr"); tf = (TextField) field_row.getChildren().get(3); remarks.setPrefWidth(tf.getPrefWidth()); remarks.setPromptText("remarks"); row.getChildren().addAll(select_account, dr, cr, remarks, del_row); field_container.getChildren().add(row); del_row.setOnMouseClicked((MouseEvent event1) -> { field_container.getChildren().removeAll(row); validateFields(); }); combo.setOnAction((e) -> { if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 21) { combo.setPromptText("Select Party"); combo.getItems().clear(); combo.getItems().addAll(this.filter_party_rec); } if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 34) { combo.getItems().clear(); combo.getItems().addAll(this.filter_party_pay); combo.setPromptText("Select Party"); } }); new AutoCompleteComboBoxListener<>(select_account); select_account.setOnHiding((e) -> { Account a = select_account.getSelectionModel().getSelectedItem(); select_account.setEditable(false); select_account.getSelectionModel().select(a); }); select_account.setOnShowing((e) -> { select_account.setEditable(true); }); validateFields(); }
From source file:mesclasses.view.RapportEleveController.java
private void drawGrid(File file) { Hyperlink link = new Hyperlink(file.getName()); link.setOnAction((event) -> openFile(file)); int rowIndex = fileGrid.addOnNewLineIfNecessary(link, 1, HPos.LEFT); ComboBox<String> typeBox = new ComboBox<>(); typeBox.getItems().addAll(Constants.FILE_TYPES); typeBox.getSelectionModel().select(selectedFileType.get()); typeBox.valueProperty().addListener((observable, oldValue, newValue) -> { if (!newValue.equals(oldValue)) { try { EleveFileUtil.moveFileForEleve(eleve, file, newValue); selectFileType(newValue); refreshGrid();/* www .j av a2s .c o m*/ } catch (IOException e) { ModalUtil.alert("Impossible de dplacer le fichier", e.getMessage()); } } }); fileGrid.add(typeBox, 2, rowIndex, null); Button deleteBtn = Btns.deleteBtn(); deleteBtn.setOnAction(event -> { if (ModalUtil.confirm("Suppression du fichier", "Etes vous sr ?")) { if (file.delete()) { fileGrid.deleteRow(SmartGrid.row(deleteBtn)); } else { ModalUtil.alert("Suppression impossible", "Impossible de supprimer le fichier " + file.getName()); } } }); fileGrid.add(deleteBtn, 3, rowIndex, null); }
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
/** * Creates the toolBar for the editor.//from w ww. java 2 s . co m * * @return */ private ToolBar createToolBar() { ToolBar toolBar = new ToolBar(); toolBar.setOrientation(Orientation.HORIZONTAL); Button btnSave = GlyphsDude.createIconButton(MaterialDesignIcon.FLOPPY, "Save"); btnSave.setOnAction(this::handleSaveButton); Button btnExportSTL = GlyphsDude.createIconButton(MaterialDesignIcon.EXPORT, "Export STL"); btnExportSTL.setOnAction(this::handleExportAsStlFile); Button btnExportPNG = GlyphsDude.createIconButton(MaterialDesignIcon.CAMERA, "Export PNG"); btnExportPNG.setOnAction(this::handleExportAsPngFile); Button btnRun = GlyphsDude.createIconButton(MaterialDesignIcon.RUN, "Run"); btnRun.setOnAction(this::handleCompileAndRun); ToggleButton btnAutoCompile = GlyphsDude.createIconToggleButton(MaterialDesignIcon.AUTO_FIX, "Automatic run", null, ContentDisplay.LEFT); btnAutoCompile.setSelected(false); ToggleButton btn3DNav = GlyphsDude.createIconToggleButton(MaterialDesignIcon.ROTATE_3D, "3D Navigation ", null, ContentDisplay.LEFT); btn3DNav.setSelected(false); ComboBox cbxSourceExamples = new ComboBox(); cbxSourceExamples.getItems().addAll("BatteryHolder", "BoardMount", "BreadBoardConnector", "ServoMount", "Wheel"); this.cbxSourceExamples = cbxSourceExamples; // TODO: maybe cleaner way // to do this ? Button btnPasteSource = GlyphsDude.createIconButton(MaterialDesignIcon.CONTENT_PASTE, "Paste source"); btnPasteSource.setOnAction(this::handlePasteSource); toolBar.getItems().addAll(btnSave, btnExportSTL, btnExportPNG, new Separator(), btnRun, new Separator(), btnAutoCompile, new Separator(), cbxSourceExamples, btnPasteSource); return toolBar; }
From source file:com.panemu.tiwulfx.table.TableControl.java
private void initControls() { this.getStyleClass().add("table-control"); btnAdd = buildButton(TiwulFXUtil.getGraphicFactory().createAddGraphic()); btnDelete = buildButton(TiwulFXUtil.getGraphicFactory().createDeleteGraphic()); btnEdit = buildButton(TiwulFXUtil.getGraphicFactory().createEditGraphic()); btnExport = buildButton(TiwulFXUtil.getGraphicFactory().createExportGraphic()); btnReload = buildButton(TiwulFXUtil.getGraphicFactory().createReloadGraphic()); btnSave = buildButton(TiwulFXUtil.getGraphicFactory().createSaveGraphic()); btnFirstPage = new Button(); btnFirstPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageFirstGraphic()); btnFirstPage.setOnAction(paginationHandler); btnFirstPage.setDisable(true);/*from w ww. j a v a 2 s . c o m*/ btnFirstPage.setFocusTraversable(false); btnFirstPage.getStyleClass().addAll("pill-button", "pill-button-left"); btnPrevPage = new Button(); btnPrevPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPagePrevGraphic()); btnPrevPage.setOnAction(paginationHandler); btnPrevPage.setDisable(true); btnPrevPage.setFocusTraversable(false); btnPrevPage.getStyleClass().addAll("pill-button", "pill-button-center"); btnNextPage = new Button(); btnNextPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageNextGraphic()); btnNextPage.setOnAction(paginationHandler); btnNextPage.setDisable(true); btnNextPage.setFocusTraversable(false); btnNextPage.getStyleClass().addAll("pill-button", "pill-button-center"); btnLastPage = new Button(); btnLastPage.setGraphic(TiwulFXUtil.getGraphicFactory().createPageLastGraphic()); btnLastPage.setOnAction(paginationHandler); btnLastPage.setDisable(true); btnLastPage.setFocusTraversable(false); btnLastPage.getStyleClass().addAll("pill-button", "pill-button-right"); cmbPage = new ComboBox<>(); cmbPage.setEditable(true); cmbPage.setOnAction(paginationHandler); cmbPage.setFocusTraversable(false); cmbPage.setDisable(true); cmbPage.getStyleClass().addAll("combo-page"); cmbPage.setPrefWidth(75); paginationBox = new HBox(); paginationBox.setAlignment(Pos.CENTER); paginationBox.getChildren().addAll(btnFirstPage, btnPrevPage, cmbPage, btnNextPage, btnLastPage); spacer = new Region(); HBox.setHgrow(spacer, Priority.ALWAYS); toolbar = new ToolBar(btnReload, btnAdd, btnEdit, btnSave, btnDelete, btnExport, spacer, paginationBox); toolbar.getStyleClass().add("table-toolbar"); footer = new StackPane(); footer.getStyleClass().add("table-footer"); lblRowIndex = new Label(); lblTotalRow = new Label(); menuButton = new TableControlMenu(this); StackPane.setAlignment(lblRowIndex, Pos.CENTER_LEFT); StackPane.setAlignment(lblTotalRow, Pos.CENTER); StackPane.setAlignment(menuButton, Pos.CENTER_RIGHT); lblTotalRow.visibleProperty().bind(progressIndicator.visibleProperty().not()); progressIndicator.setProgress(-1); progressIndicator.visibleProperty().bind(service.runningProperty()); toolbar.disableProperty().bind(service.runningProperty()); menuButton.disableProperty().bind(service.runningProperty()); footer.getChildren().addAll(lblRowIndex, lblTotalRow, menuButton, progressIndicator); VBox.setVgrow(tblView, Priority.ALWAYS); getChildren().addAll(toolbar, tblView, footer); }
From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java
private void buildDataFields(boolean assemblageValid, DynamicSememeDataBI[] currentValues) { if (assemblageValid) { for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) { allValid_.removeBinding(ssp); }//from ww w. ja va 2 s . co m currentDataFieldWarnings_.clear(); for (SememeGUIDataTypeNodeDetails nd : currentDataFields_) { nd.cleanupListener(); } currentDataFields_.clear(); GridPane gp = new GridPane(); gp.setHgap(10.0); gp.setVgap(10.0); gp.setStyle("-fx-padding: 5;"); int row = 0; boolean extraInfoColumnIsRequired = false; for (DynamicSememeColumnInfo ci : assemblageInfo_.getColumnInfo()) { SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("") : null); SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null && ci.getValidator() == null) ? null : new SimpleStringProperty()); ComboBox<DynamicSememeDataType> polymorphicType = null; Label l = new Label(ci.getColumnName()); l.getStyleClass().add("boldLabel"); l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l)); Tooltip.install(l, new Tooltip(ci.getColumnDescription())); int col = 0; gp.add(l, col++, row); if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) { polymorphicType = new ComboBox<>(); polymorphicType.setEditable(false); polymorphicType.setConverter(new StringConverter<DynamicSememeDataType>() { @Override public String toString(DynamicSememeDataType object) { return object.getDisplayName(); } @Override public DynamicSememeDataType fromString(String string) { throw new RuntimeException("unecessary"); } }); for (DynamicSememeDataType type : DynamicSememeDataType.values()) { if (type == DynamicSememeDataType.POLYMORPHIC || type == DynamicSememeDataType.UNKNOWN) { continue; } else { polymorphicType.getItems().add(type); } } polymorphicType.getSelectionModel() .select((currentValues == null ? DynamicSememeDataType.STRING : (currentValues[row] == null ? DynamicSememeDataType.STRING : currentValues[row].getDynamicSememeDataType()))); } SememeGUIDataTypeNodeDetails nd = SememeGUIDataTypeFXNodeBuilder.buildNodeForType( ci.getColumnDataType(), ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip, (polymorphicType == null ? null : polymorphicType.getSelectionModel().selectedItemProperty()), allValid_, ci.getValidator(), ci.getValidatorData()); currentDataFieldWarnings_.addAll(nd.getBoundToAllValid()); if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) { nd.addUpdateParentListListener(currentDataFieldWarnings_); } currentDataFields_.add(nd); gp.add(nd.getNodeForDisplay(), col++, row); Label colType = new Label(ci.getColumnDataType().getDisplayName()); colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType)); gp.add((polymorphicType == null ? colType : polymorphicType), col++, row); if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) { extraInfoColumnIsRequired = true; StackPane stackPane = new StackPane(); stackPane.setMaxWidth(Double.MAX_VALUE); if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) { ImageView information = Images.INFORMATION.createImageView(); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(defaultValueTooltip); Tooltip.install(information, tooltip); tooltip.setAutoHide(true); information.setOnMouseClicked( event -> tooltip.show(information, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(information); } if (ci.isColumnRequired()) { ImageView exclamation = Images.EXCLAMATION.createImageView(); final BooleanProperty showExclamation = new SimpleBooleanProperty( StringUtils.isNotBlank(valueIsRequired.get())); valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue, newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue))); exclamation.visibleProperty().bind(showExclamation); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(valueIsRequired); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked( event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(exclamation); } gp.add(stackPane, col++, row); } row++; } ColumnConstraints cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.ALWAYS); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); if (extraInfoColumnIsRequired) { cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); } if (row == 0) { sp_.setContent(new Label("This assemblage does not allow data fields")); } else { sp_.setContent(gp); } allValid_.invalidate(); } else { sp_.setContent(null); } }