List of usage examples for javafx.event EventHandler EventHandler
EventHandler
From source file:retsys.client.controller.DeliveryChallanController.java
/** * Initializes the controller class.//from w w w. j a v a 2 s .c o m */ @Override public void initialize(URL url, ResourceBundle rb) { dc_date.setValue(LocalDate.now()); material_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("name")); brand_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("brand")); model_code.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model")); quantity.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("quantity")); units.setCellValueFactory(new PropertyValueFactory<DCItem, String>("units")); amount.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("amount")); dcDetail.getColumns().setAll(material_name, brand_name, model_code, quantity, units, amount); // TODO AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() { @Override public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) { List<Item> list = null; try { LovHandler lovHandler = new LovHandler("items", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Item>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Item>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Item>() { @Override public String toString(Item object) { System.out.println("here..." + object); return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Item fromString(String string) { throw new UnsupportedOperationException(); } }); //event handler for setting other item fields with values from selected Item object //fires after autocompletion bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) { Item item = event.getCompletion(); //fill other item related fields txt_name.setUserData(item.getId()); txt_brand.setText(item.getBrand()); txt_model.setText(item.getBrand()); // item doesn't have this field. add?? txt_rate.setText(String.valueOf(item.getRate())); txt_units.setText(item.getUnit()); txt_qty.setText(""); txt_amount.setText(""); txt_qty.requestFocus(); } }); AutoCompletionBinding<Project> bindForProject = TextFields.bindAutoCompletion(project, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() { @Override public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) { List<Project> list = null; try { LovHandler lovHandler = new LovHandler("projects", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Project>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Project>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Project>() { @Override public String toString(Project object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Project fromString(String string) { throw new UnsupportedOperationException(); } }); txt_qty.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { calcAmount(); } } }); }
From source file:com.rcs.shoe.shop.fx.controller.ui.SaleEnterController.java
private void setQuantities(Map<Integer, V_ProductHistory> map) { for (Label label : quantityLabels.values()) { Button button = quantityButtons.get("button" + getSize(label)); V_ProductHistory quantity = map.get(getSize(label)); if (quantity != null && quantity.getQuantity() > 0) { button.setOnAction(new EventHandler<ActionEvent>() { @Override/*w w w . ja v a 2 s. c o m*/ public void handle(ActionEvent e) { enterSale(button); } }); button.setDefaultButton(true); label.textProperty().setValue(quantity.getQuantity().toString()); } else { button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { noQuantitySale(); } }); button.setDefaultButton(false); label.textProperty().setValue("0"); } } }
From source file:retsys.client.controller.DeliveryChallanReturnController.java
/** * Initializes the controller class.//from ww w. j ava 2s. com */ @Override public void initialize(URL url, ResourceBundle rb) { dc_date.setValue(LocalDate.now()); material_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("name")); brand_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("brand")); model_code.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model")); units.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model")); quantity.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("quantity")); amount.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("amount")); dcDetail.getColumns().setAll(material_name, brand_name, model_code, quantity, amount); // TODO AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() { @Override public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) { List<Item> list = null; try { LovHandler lovHandler = new LovHandler("items", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Item>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Item>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Item>() { @Override public String toString(Item object) { System.out.println("here..." + object); return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Item fromString(String string) { throw new UnsupportedOperationException(); } }); //event handler for setting other item fields with values from selected Item object //fires after autocompletion bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) { Item item = event.getCompletion(); //fill other item related fields txt_name.setUserData(item.getId()); txt_brand.setText(item.getBrand()); txt_model.setText(null); // item doesn't have this field. add?? txt_rate.setText(String.valueOf(item.getRate())); } }); AutoCompletionBinding<DeliveryChallan> bindForProject = TextFields.bindAutoCompletion(project, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<DeliveryChallan>>() { @Override public Collection<DeliveryChallan> call(AutoCompletionBinding.ISuggestionRequest param) { List<DeliveryChallan> list = null; try { LovHandler lovHandler = new LovHandler("deliverychallans", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<DeliveryChallan>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<DeliveryChallan>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<DeliveryChallan>() { @Override public String toString(DeliveryChallan object) { System.out.println("here..." + object); String strDate = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format(LocalDateTime .ofInstant(object.getChallanDate().toInstant(), ZoneId.systemDefault())); return "Project:" + object.getProject().getName() + " DC Date:" + strDate + " DC No.:" + object.getId(); } @Override public DeliveryChallan fromString(String string) { throw new UnsupportedOperationException(); } }); bindForProject .setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan> event) { DeliveryChallan dc = event.getCompletion(); dc_no.setText(dc.getId().toString()); dc_date.setValue(LocalDateTime .ofInstant(dc.getChallanDate().toInstant(), ZoneId.systemDefault()).toLocalDate()); dc_no.setText(dc.getId().toString()); project.setText(dc.getProject().getName() + " (ID:" + dc.getProject().getId() + ")"); deliverymode.setText(dc.getDeliveryMode()); concernperson.setText(dc.getConcernPerson()); ObservableList<DCItem> items = FXCollections.observableArrayList(); Iterator detailsIt = dc.getDeliveryChallanDetail().iterator(); while (detailsIt.hasNext()) { DeliveryChallanDetail detail = (DeliveryChallanDetail) detailsIt.next(); Item item = detail.getItem(); int id = item.getId(); String site = item.getSite(); String name = item.getName(); String brand = item.getBrand(); String model = null; int rate = item.getRate().intValue(); int quantity = detail.getQuantity(); int amount = detail.getAmount(); String units = detail.getUnits(); items.add(new DCItem(id, name + " (ID:" + id + ")", brand, model, rate, quantity, units, amount)); } dcDetail.setItems(items); populateAuditValues(dc); } }); txt_qty.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { calcAmount(); } } }); }
From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java
private void addCheckBox(String id, String name, String path, boolean selected, boolean delete) { HBox hbox = new HBox(); hbox.setAlignment(Pos.CENTER_LEFT);//from w ww. j a va 2 s .co m CheckBox chk = new CheckBox(name); chk.setId(id); chk.getStyleClass().add("checkreport"); chk.setSelected(selected); chk.setEllipsisString(" ... "); chk.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); chk.setTooltip(new Tooltip(path)); hbox.getChildren().add(chk); // EDIT Button edit = new Button(); edit.getStyleClass().addAll("edit-img", "action-img-16"); edit.setCursor(Cursor.HAND); edit.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { String iso = chk.getId(); String path = null; if (iso.startsWith("external")) { iso = chk.getText(); path = iso; } else if (chk.getId().startsWith("config")) { iso = chk.getId().replace("config", ""); path = DPFManagerProperties.getIsosDir() + "/" + iso; } controller.editIso(iso, path); } }); hbox.getChildren().add(edit); HBox.setMargin(edit, new Insets(0, 0, 0, 10)); // DELETE if (delete) { Button icon = new Button(); icon.getStyleClass().addAll("delete-img", "action-img-16"); icon.setCursor(Cursor.HAND); icon.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (chk.getId().startsWith("external")) { // Only from gui vboxRadios.getChildren().remove(hbox); } else if (chk.getId().startsWith("config")) { // From system String name = chk.getId().replace("config", ""); File file = new File(DPFManagerProperties.getIsosDir() + "/" + name); if (file.exists() && file.isFile() && acceptDelete(file)) { file.delete(); vboxRadios.getChildren().remove(hbox); } } } }); hbox.getChildren().add(icon); HBox.setMargin(icon, new Insets(0, 0, 0, 10)); } vboxRadios.getChildren().add(hbox); }
From source file:caillou.company.clonemanager.gui.customComponent.results.ResultController.java
@Override public void initialize(URL location, ResourceBundle resources) { this.guiApplicationFileListFiltered = new FilteredList<>(guiApplicationFileList); this.initializePhaseAutomaticResizing(); this.initializeContextDependant(); SortedList<GUIApplicationFile> sortedList = new SortedList<>(guiApplicationFileListFiltered); // Bind the SortedList comparator to the TableView comparator. sortedList.comparatorProperty().bind(resultViewId.comparatorProperty()); resultViewId.setItems(sortedList);// w w w . ja v a 2s. c o m resultViewId.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); this.filterList(guiApplicationFileListFiltered); this.initializeFilter(); this.initializeRowFactory(); this.initializeStatistic(); accordionPaneId.setExpandedPane(informationPaneId); groupId.getItems().add(Group.GROUPA); groupId.getItems().add(Group.GROUPB); groupId.setValue(Group.GROUPA); /** * Due to the bug * "https://bitbucket.org/controlsfx/controlsfx/issue/185/nullpointerexception-when-using-popover" */ MainApp.getInstance().getStage().setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { if (popOver != null) { popOver.hide(Duration.millis(0)); } } }); /** * End * */ }
From source file:Main.java
@Override public void start(final Stage stage) { stage.setTitle("Xylophone"); camOffset.getChildren().add(cam);/*from w w w . j ava2 s . co m*/ resetCam(); final Scene scene = new Scene(camOffset, 800, 600, true); scene.setFill(new RadialGradient(225, 0.85, 300, 300, 500, false, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0f, Color.BLUE), new Stop(1f, Color.LIGHTBLUE) })); scene.setCamera(new PerspectiveCamera()); final AudioClip bar1Note = new AudioClip(Main.class.getResource("audio/Note1.wav").toString()); final AudioClip bar2Note = new AudioClip(Main.class.getResource("audio/Note2.wav").toString()); final AudioClip bar3Note = new AudioClip(Main.class.getResource("audio/Note3.wav").toString()); final AudioClip bar4Note = new AudioClip(Main.class.getResource("audio/Note4.wav").toString()); final AudioClip bar5Note = new AudioClip(Main.class.getResource("audio/Note5.wav").toString()); final AudioClip bar6Note = new AudioClip(Main.class.getResource("audio/Note6.wav").toString()); final AudioClip bar7Note = new AudioClip(Main.class.getResource("audio/Note7.wav").toString()); final AudioClip bar8Note = new AudioClip(Main.class.getResource("audio/Note8.wav").toString()); Group rectangleGroup = new Group(); rectangleGroup.getTransforms().add(shear); rectangleGroup.setDepthTest(DepthTest.ENABLE); double xStart = 260.0; double xOffset = 30.0; double yPos = 300.0; double zPos = 0.0; double barWidth = 22.0; double barDepth = 7.0; // Base1 Cube base1Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base1Cube.setTranslateX(xStart + 135); base1Cube.setTranslateZ(yPos + 20.0); base1Cube.setTranslateY(11.0); base1Cube.setScaleX(barWidth * 11.5); base1Cube.setScaleZ(10.0); base1Cube.setScaleY(barDepth * 2.0); // Base2 Cube base2Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base2Cube.setTranslateX(xStart + 135); base2Cube.setTranslateZ(yPos - 20.0); base2Cube.setTranslateY(11.0); base2Cube.setScaleX(barWidth * 11.5); base2Cube.setScaleZ(10.0); base2Cube.setScaleY(barDepth * 2.0); // Bar1 Cube bar1Cube = new Cube(1.0, Color.PURPLE, 1.0); bar1Cube.setTranslateX(xStart + 1 * xOffset); bar1Cube.setTranslateZ(yPos); bar1Cube.setScaleX(barWidth); bar1Cube.setScaleZ(100.0); bar1Cube.setScaleY(barDepth); // Bar2 Cube bar2Cube = new Cube(1.0, Color.BLUEVIOLET, 1.0); bar2Cube.setTranslateX(xStart + 2 * xOffset); bar2Cube.setTranslateZ(yPos); bar2Cube.setScaleX(barWidth); bar2Cube.setScaleZ(95.0); bar2Cube.setScaleY(barDepth); // Bar3 Cube bar3Cube = new Cube(1.0, Color.BLUE, 1.0); bar3Cube.setTranslateX(xStart + 3 * xOffset); bar3Cube.setTranslateZ(yPos); bar3Cube.setScaleX(barWidth); bar3Cube.setScaleZ(90.0); bar3Cube.setScaleY(barDepth); // Bar4 Cube bar4Cube = new Cube(1.0, Color.GREEN, 1.0); bar4Cube.setTranslateX(xStart + 4 * xOffset); bar4Cube.setTranslateZ(yPos); bar4Cube.setScaleX(barWidth); bar4Cube.setScaleZ(85.0); bar4Cube.setScaleY(barDepth); // Bar5 Cube bar5Cube = new Cube(1.0, Color.GREENYELLOW, 1.0); bar5Cube.setTranslateX(xStart + 5 * xOffset); bar5Cube.setTranslateZ(yPos); bar5Cube.setScaleX(barWidth); bar5Cube.setScaleZ(80.0); bar5Cube.setScaleY(barDepth); // Bar6 Cube bar6Cube = new Cube(1.0, Color.YELLOW, 1.0); bar6Cube.setTranslateX(xStart + 6 * xOffset); bar6Cube.setTranslateZ(yPos); bar6Cube.setScaleX(barWidth); bar6Cube.setScaleZ(75.0); bar6Cube.setScaleY(barDepth); // Bar7 Cube bar7Cube = new Cube(1.0, Color.ORANGE, 1.0); bar7Cube.setTranslateX(xStart + 7 * xOffset); bar7Cube.setTranslateZ(yPos); bar7Cube.setScaleX(barWidth); bar7Cube.setScaleZ(70.0); bar7Cube.setScaleY(barDepth); // Bar8 Cube bar8Cube = new Cube(1.0, Color.RED, 1.0); bar8Cube.setTranslateX(xStart + 8 * xOffset); bar8Cube.setTranslateZ(yPos); bar8Cube.setScaleX(barWidth); bar8Cube.setScaleZ(65.0); bar8Cube.setScaleY(barDepth); bar1Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar1Note.play(); } }); bar2Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar2Note.play(); } }); bar3Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar3Note.play(); } }); bar4Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar4Note.play(); } }); bar5Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar5Note.play(); } }); bar6Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar6Note.play(); } }); bar7Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar7Note.play(); } }); bar8Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar8Note.play(); } }); rectangleGroup.getChildren().addAll(base1Cube, base2Cube, bar1Cube, bar2Cube, bar3Cube, bar4Cube, bar5Cube, bar6Cube, bar7Cube, bar8Cube); rectangleGroup.setScaleX(2.5); rectangleGroup.setScaleY(2.5); rectangleGroup.setScaleZ(2.5); cam.getChildren().add(rectangleGroup); double halfSceneWidth = 375; // scene.getWidth()/2.0; double halfSceneHeight = 275; // scene.getHeight()/2.0; cam.p.setX(halfSceneWidth); cam.ip.setX(-halfSceneWidth); cam.p.setY(halfSceneHeight); cam.ip.setY(-halfSceneHeight); frameCam(stage, scene); scene.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mousePosX = me.getX(); mousePosY = me.getY(); mouseOldX = me.getX(); mouseOldY = me.getY(); //System.out.println("scene.setOnMousePressed " + me); } }); scene.setOnMouseDragged(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mouseOldX = mousePosX; mouseOldY = mousePosY; mousePosX = me.getX(); mousePosY = me.getY(); mouseDeltaX = mousePosX - mouseOldX; mouseDeltaY = mousePosY - mouseOldY; if (me.isAltDown() && me.isShiftDown() && me.isPrimaryButtonDown()) { double rzAngle = cam.rz.getAngle(); cam.rz.setAngle(rzAngle - mouseDeltaX); } else if (me.isAltDown() && me.isPrimaryButtonDown()) { double ryAngle = cam.ry.getAngle(); cam.ry.setAngle(ryAngle - mouseDeltaX); double rxAngle = cam.rx.getAngle(); cam.rx.setAngle(rxAngle + mouseDeltaY); } else if (me.isShiftDown() && me.isPrimaryButtonDown()) { double yShear = shear.getY(); shear.setY(yShear + mouseDeltaY / 1000.0); double xShear = shear.getX(); shear.setX(xShear + mouseDeltaX / 1000.0); } else if (me.isAltDown() && me.isSecondaryButtonDown()) { double scale = cam.s.getX(); double newScale = scale + mouseDeltaX * 0.01; cam.s.setX(newScale); cam.s.setY(newScale); cam.s.setZ(newScale); } else if (me.isAltDown() && me.isMiddleButtonDown()) { double tx = cam.t.getX(); double ty = cam.t.getY(); cam.t.setX(tx + mouseDeltaX); cam.t.setY(ty + mouseDeltaY); } } }); scene.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (KeyCode.A.equals(ke.getCode())) { resetCam(); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.F.equals(ke.getCode())) { frameCam(stage, scene); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.SPACE.equals(ke.getCode())) { if (stage.isFullScreen()) { stage.setFullScreen(false); frameCam(stage, scene); } else { stage.setFullScreen(true); frameCam(stage, scene); } } } }); stage.setScene(scene); stage.show(); }
From source file:com.wineshop.client.Home.java
@Override public void initialize(URL url, ResourceBundle bundle) { // Setup of the table view vineyards.setSortAdapter(new TableViewSortAdapter<Vineyard>(tableVineyards, Vineyard.class)); vineyards.getFilter().nameProperty().bindBidirectional(fieldSearch.textProperty()); // Setup of the creation/edit form labelFormVineyard.textProperty()//from w ww. j ava 2s .c o m .bind(Bindings.when(vineyard.savedProperty()).then("Edit vineyard").otherwise("Create vineyard")); vineyard.instanceProperty().addListener(new ChangeListener<Vineyard>() { @Override public void changed(ObservableValue<? extends Vineyard> observable, Vineyard oldValue, Vineyard newValue) { if (oldValue != null) { fieldName.textProperty().unbindBidirectional(oldValue.nameProperty()); fieldAddress.textProperty().unbindBidirectional(oldValue.getAddress().addressProperty()); listWines.setItems(null); } if (newValue != null) { fieldName.textProperty().bindBidirectional(newValue.nameProperty()); fieldAddress.textProperty().bindBidirectional(newValue.getAddress().addressProperty()); listWines.setItems(newValue.getWines()); } } }); // Define the cell factory for the list of wines listWines.setCellFactory(new Callback<ListView<Wine>, ListCell<Wine>>() { public ListCell<Wine> call(ListView<Wine> listView) { return new WineListCell(); } }); buttonDelete.visibleProperty().bind(vineyard.savedProperty()); buttonDelete.disableProperty().bind(Bindings.not(identity.ifAllGranted("ROLE_ADMIN"))); buttonSave.disableProperty().bind(Bindings.not(vineyard.dirtyProperty())); buttonCancel.disableProperty() .bind(Bindings.not(Bindings.or(vineyard.savedProperty(), vineyard.dirtyProperty()))); // Link the table selection and the entity instance in the form select(null); tableVineyards.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Vineyard>() { @Override public void changed(ObservableValue<? extends Vineyard> property, Vineyard oldSelection, Vineyard newSelection) { select(newSelection); } }); formVineyard.addEventHandler(ValidationResultEvent.INVALID, new EventHandler<ValidationResultEvent>() { @Override public void handle(ValidationResultEvent event) { ((Node) event.getTarget()).setStyle("-fx-border-color: red"); if (event.getTarget() instanceof TextInputControl && event.getErrorResults() != null && event.getErrorResults().size() > 0) { Tooltip tooltip = new Tooltip(event.getErrorResults().get(0).getMessage()); tooltip.setAutoHide(true); ((TextInputControl) event.getTarget()).setTooltip(tooltip); } } }); formVineyard.addEventHandler(ValidationResultEvent.VALID, new EventHandler<ValidationResultEvent>() { @Override public void handle(ValidationResultEvent event) { ((Node) event.getTarget()).setStyle("-fx-border-color: null"); if (event.getTarget() instanceof TextInputControl) { Tooltip tooltip = ((TextInputControl) event.getTarget()).getTooltip(); if (tooltip != null && tooltip.isActivated()) tooltip.hide(); ((TextInputControl) event.getTarget()).setTooltip(null); } } }); }
From source file:be.makercafe.apps.makerbench.Main.java
private ContextMenu createViewerContextMenu() { ContextMenu rootContextMenu = new ContextMenu(); // Add Folder.. MenuItem addFolder = new MenuItem("Add folder.."); addFolder.setOnAction(new EventHandler<ActionEvent>() { @Override//from w w w. ja v a2 s . c o m public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfolder"); dialog.setTitle("New folder"); dialog.setHeaderText("Create a new folder"); dialog.setContentText("Folder name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { if (!file.mkdir()) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating folder"); alert.setContentText("Folder path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); // Delete folder MenuItem deleteFolder = new MenuItem("Delete folder.."); deleteFolder.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete folder"); alert.setContentText("Please confirm deleteion of selected folder and all it's contents ?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { try { FileUtils.deleteDirectory(file); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting folder"); alert.setContentText("Error messsage: " + e.getMessage()); alert.showAndWait(); } } } } }); // Add File.. MenuItem addFile = new MenuItem("Add file.."); addFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfile.txt"); dialog.setTitle("New file"); dialog.setHeaderText("Create a new file (.jfxscad, .jfxmill, .txt, .md, .xml, .gcode"); dialog.setContentText("File name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { try { file.createNewFile(); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating file"); alert.setContentText( "File path: " + file.getAbsolutePath() + "\nError message: " + e.getMessage()); alert.showAndWait(); } } } } }); // Delete file MenuItem deleteFile = new MenuItem("Delete file.."); deleteFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete file"); alert.setContentText("Please confirm deleteion of selected file"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { if (!file.delete()) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting file"); alert.setContentText("File path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); rootContextMenu.getItems().addAll(addFolder, deleteFolder, addFile, deleteFile); return rootContextMenu; }
From source file:calendarioSeries.vistas.NewSerieController.java
private void changeStyleOnHover(Node node) { node.setOnMouseEntered(new EventHandler<MouseEvent>() { @Override//w w w .j av a 2s. c o m public void handle(MouseEvent event) { node.setStyle("-fx-background-color: derive(#0096C9, 30%);"); } }); node.setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { node.setStyle("-fx-background-color: #0096C9"); } }); }
From source file:com.rvantwisk.cnctools.operations.facing.FacingController.java
@FXML void initialize() { assert cutDirection != null : "fx:id=\"cutDirection\" was not injected: check your FXML file 'Facing.fxml'."; assert edgeDirection != null : "fx:id=\"edgeDirection\" was not injected: check your FXML file 'Facing.fxml'."; assert gCodeViewerControl != null : "fx:id=\"gCodeViewerControl\" was not injected: check your FXML file 'Facing.fxml'."; assert iClimb != null : "fx:id=\"iClimb\" was not injected: check your FXML file 'Facing.fxml'."; assert iConv != null : "fx:id=\"iConv\" was not injected: check your FXML file 'Facing.fxml'."; assert iCutStrategy != null : "fx:id=\"iCutStrategy\" was not injected: check your FXML file 'Facing.fxml'."; assert iEdgeCleanup != null : "fx:id=\"iEdgeCleanup\" was not injected: check your FXML file 'Facing.fxml'."; assert iEdgeClimb != null : "fx:id=\"iEdgeClimb\" was not injected: check your FXML file 'Facing.fxml'."; assert iEdgeConv != null : "fx:id=\"iEdgeConv\" was not injected: check your FXML file 'Facing.fxml'."; assert iPartReference != null : "fx:id=\"iPartReference\" was not injected: check your FXML file 'Facing.fxml'."; assert iXLength != null : "fx:id=\"iXLength\" was not injected: check your FXML file 'Facing.fxml'."; assert iYLength != null : "fx:id=\"iYLength\" was not injected: check your FXML file 'Facing.fxml'."; assert iZFinal != null : "fx:id=\"iZFinal\" was not injected: check your FXML file 'Facing.fxml'."; assert iZSafe != null : "fx:id=\"iZSafe\" was not injected: check your FXML file 'Facing.fxml'."; assert iZTop != null : "fx:id=\"iZTop\" was not injected: check your FXML file 'Facing.fxml'."; assert selectOrEditTool != null : "fx:id=\"selectOrEditTool\" was not injected: check your FXML file 'Facing.fxml'."; iCutStrategy.getItems().clear();// w ww.j a va 2 s. com iCutStrategy.getItems().addAll(FacingModel.CONFIGLIST); modelToForm(); selectOrEditTool.addEventHandler(ToolChangedEvent.TOOL_CHANGED_EVENT, new EventHandler<ToolChangedEvent>() { @Override public void handle(ToolChangedEvent toolChangedEvent) { generateGCode(); } }); iXLength.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iYLength.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iZFinal.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iZSafe.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iZTop.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iEdgeCleanup.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2) { generateGCode(); } }); edgeDirection.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observableValue, Toggle toggle, Toggle toggle2) { generateGCode(); } }); cutDirection.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observableValue, Toggle toggle, Toggle toggle2) { generateGCode(); } }); iCutStrategy.valueProperty().addListener(new ChangeListener<FacingModel.Configuration>() { @Override public void changed(ObservableValue<? extends FacingModel.Configuration> observableValue, FacingModel.Configuration configuration, FacingModel.Configuration configuration2) { generateGCode(); } }); iPartReference.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observableValue, String s, String s2) { generateGCode(); } }); generateGCode(); }