Java Code Examples for javafx.scene.input.InputEvent#consume()
The following examples show how to use
javafx.scene.input.InputEvent#consume() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditMicroinstructionsController.java From CPUSim with GNU General Public License v3.0 | 4 votes |
/** * initializes the dialog window after its root element has been processed. * contains a listener to the combo box, so that the content of the table will * change according to the selected type of microinstruction. * * @param url the location used to resolve relative paths for the root * object, or null if the location is not known. * @param rb the resources used to localize the root object, or null if the root * object was not localized. */ @Override public void initialize(URL url, ResourceBundle rb) { microinstructionCombo.setVisibleRowCount(14); // show all micros at once tableMap.setParents(tablePane); tablePane.getChildren().clear(); activeTable = tableMap.getMap().get("TransferRtoR"); tablePane.getChildren().add(activeTable); activeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); newButton.setDisable(!((MicroController)activeTable).newMicrosAreAllowed()); activeTable.getSelectionModel().selectedItemProperty().addListener(listener); // resizes the width and height of the table to match the dialog tablePane.widthProperty().addListener((observableValue, oldValue, newValue) -> activeTable.setPrefWidth((Double) newValue) ); tablePane.heightProperty().addListener((observableValue, oldValue, newValue) -> activeTable.setPrefHeight((Double)newValue) ); // listen for changes to the instruction combo box selection and update // the displayed micro instruction table accordingly. microinstructionCombo.getSelectionModel().selectedItemProperty().addListener( (selected, oldType, newType) -> { activeTable.getSelectionModel().selectedItemProperty(). removeListener(listener); tableMap.getMap().get(oldType).getSelectionModel().clearSelection(); tablePane.getChildren().clear(); tablePane.getChildren().add( tableMap.getMap().get(newType)); activeTable = tableMap.getMap().get(newType); activeTable.setPrefWidth(tablePane.getWidth()); activeTable.setPrefHeight(tablePane.getHeight()); activeTable.setColumnResizePolicy(TableView .CONSTRAINED_RESIZE_POLICY); newButton.setDisable(!((MicroController) activeTable).newMicrosAreAllowed()); selectedSet = null; deleteButton.setDisable(true); duplicateButton.setDisable(true); activeTable.getSelectionModel().selectedItemProperty(). addListener(listener); }); // Define an event filter for the ComboBox for Mouse_released events EventHandler validityFilter = new EventHandler<InputEvent>() { public void handle(InputEvent event) { try{ ((MicroController)activeTable).checkValidity(activeTable.getItems()); } catch (ValidationException ex){ Dialogs.createErrorDialog(tablePane.getScene().getWindow(), "Microinstruction Error", ex.getMessage()).showAndWait(); event.consume(); } } }; microinstructionCombo.addEventFilter(MouseEvent.MOUSE_RELEASED, validityFilter); }
Example 2
Source File: EditModulesController.java From CPUSim with GNU General Public License v3.0 | 4 votes |
/** * initializes the dialog window after its root element has been processed. * contains a listener to the combo box, so that the content of the table will * change according to the selected type of microinstruction. * * @param url the location used to resolve relative paths for the root * object, or null if the location is not known. * @param rb the resources used to localize the root object, or null if the root * object was not localized. */ @Override public void initialize(URL url, ResourceBundle rb) { moduleCombo.setVisibleRowCount(4); // show all modules at once tableMap.setParents(tablePane); tablePane.getChildren().clear(); activeTable = tableMap.getMap().get("Register"); tablePane.getChildren().add(activeTable); activeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); activeTable.getSelectionModel().selectedItemProperty().addListener (contentChangeListener); // resizes the width and height of the content panes tablePane.widthProperty().addListener((observableValue, oldValue, newValue) -> activeTable.setPrefWidth((Double) newValue) ); tablePane.heightProperty().addListener((observableValue, oldValue, newValue) -> activeTable.setPrefHeight((Double) newValue) ); // listen for changes to the instruction combo box selection and update // the displayed micro instruction table accordingly. moduleCombo.getSelectionModel().selectedItemProperty().addListener( (selected, oldType, newType) -> { ((ModuleController) activeTable).setClones(activeTable.getItems()); activeTable.getSelectionModel().selectedItemProperty(). removeListener(contentChangeListener); tableMap.getMap().get(oldType).getSelectionModel().clearSelection(); tablePane.getChildren().clear(); tablePane.getChildren().add( tableMap.getMap().get(newType)); activeTable = tableMap.getMap().get(newType); activeTable.setPrefWidth(tablePane.getWidth()); activeTable.setPrefHeight(tablePane.getHeight()); activeTable.setColumnResizePolicy(TableView .CONSTRAINED_RESIZE_POLICY); newButton.setDisable(!((ModuleController) activeTable) .newModulesAreAllowed()); if (oldType.equals("Register") || oldType.equals("RegisterArray")) { ((ConditionBitTableController) tableMap.getMap().get ("ConditionBit")).updateRegisters(); } propertiesButton.setDisable(!newType.equals("RegisterArray") || activeTable.getItems().size() == 0); selectedSet = null; deleteButton.setDisable(true); duplicateButton.setDisable(true); //listen for changes to the table selection and update the // status of buttons. activeTable.getSelectionModel().selectedItemProperty(). addListener(contentChangeListener); }); // Define an event filter for the ComboBox for Mouse_released events EventHandler validityFilter = new EventHandler<InputEvent>() { public void handle(InputEvent event) { try { ((ModuleController) activeTable).checkValidity(); } catch (ValidationException ex) { Dialogs.createErrorDialog(tablePane.getScene().getWindow(), "Modules Error", ex.getMessage()).showAndWait(); event.consume(); } } }; moduleCombo.addEventFilter(MouseEvent.MOUSE_RELEASED, validityFilter); }
Example 3
Source File: EditArrayRegistersController.java From CPUSim with GNU General Public License v3.0 | 4 votes |
/** * initializes the dialog window after its root element has been processed. * contains a listener to the combo box, so that the content of the table will * change according to the selected type of microinstruction. * * @param url the location used to resolve relative paths for the root * object, or null if the location is not known. * @param rb the resources used to localize the root object, or null if the root * object was not localized. */ @Override public void initialize(URL url, ResourceBundle rb) { arrayCombo.getItems().addAll(registerArrays.stream().map( RegisterArray::getName).collect(Collectors.toList())); arrayCombo.getSelectionModel().select(selection); tableMap = new ChangeTable(registerArrays); tableMap.setParents(tablePane); tablePane.getChildren().clear(); tablePane.getChildren().add(tableMap.getMap().get(selection)); activeTable = tableMap.getMap().get(selection); activeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // resizes the width and height of the content panes tablePane.widthProperty().addListener((observableValue, oldValue, newValue) -> activeTable.setPrefWidth((Double) newValue) ); tablePane.heightProperty().addListener((observableValue, oldValue, newValue) -> activeTable.setPrefHeight((Double) newValue) ); // listen for changes to the instruction combo box selection and update // the displayed micro instruction table accordingly. arrayCombo.getSelectionModel().selectedItemProperty().addListener( new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> selected, String oldType, String newType) { ((RegisterArrayTableView) activeTable).setClones(activeTable .getItems()); activeTable = tableMap.getMap().get(newType); tableMap.getMap().get(oldType).getSelectionModel() .clearSelection(); tablePane.getChildren().clear(); tablePane.getChildren().add( tableMap.getMap().get(newType)); activeTable.setPrefWidth(tablePane.getWidth()); activeTable.setPrefHeight(tablePane.getHeight()); activeTable.setColumnResizePolicy(TableView .CONSTRAINED_RESIZE_POLICY); } }); // Define an event filter for the ComboBox for Mouse_released events EventHandler validityFilter = new EventHandler<InputEvent>() { public void handle(InputEvent event) { try { ObservableList<Register> list = FXCollections.observableArrayList(); list.addAll(registerController.getItems()); for (RegisterArrayTableView r : tableMap.getMap().values()) { list.addAll(r.getItems()); } Validate.allNamesAreUnique(list.toArray()); ((RegisterArrayTableView) activeTable).checkValidity(list); } catch (ValidationException ex) { Dialogs.createErrorDialog(tablePane.getScene().getWindow(), "Registers Error", ex.getMessage()).showAndWait(); event.consume(); } } }; arrayCombo.addEventFilter(MouseEvent.MOUSE_RELEASED, validityFilter); }