private void onRemoveFileClicked() { File f = fileListView.getSelectionModel().getSelectedItem(); fileListView.getItems().remove(f); }
private void selectItem() { T item = suggestionList.getSelectionModel().getSelectedItem(); if (item == null) { try { suggestionList.getSelectionModel().select(0); item = suggestionList.getSelectionModel().getSelectedItem(); } catch (Exception e) { } } if (item != null) { control.getSelectionHandler().handle(new JFXAutoCompleteEvent<T>(JFXAutoCompleteEvent.SELECTION, item)); } }
private void moveItem(int direction) { // Checking selected item if (fileListView.getSelectionModel().getSelectedItem() == null) { return; } // Calculate new index using move direction int newIndex = fileListView.getSelectionModel().getSelectedIndex() + direction; if (newIndex < 0 || newIndex >= fileListView.getItems().size()) { return; } File selected = fileListView.getSelectionModel().getSelectedItem(); // Removing removable element fileListView.getItems().remove(selected); // Insert it in new position fileListView.getItems().add(newIndex, selected); //Restore Selection fileListView.scrollTo(newIndex); fileListView.getSelectionModel().select(newIndex); }
private void displayScopes(Node node, boolean focusScopeView) { // current selection TreeItem<Object> previousSelection = scopeHierarchyTreeView.getSelectionModel().getSelectedItem(); ScopeHierarchyTreeItem rootScope = ScopeHierarchyTreeItem.buildAscendantHierarchy(node); scopeHierarchyTreeView.setRoot(rootScope); if (focusScopeView && previousSelection != null) { // Try to find the node that was previously selected and focus it in the new ascendant hierarchy. // Otherwise, when you select a node in the scope tree, since focus of the app is shifted to that // node, the scope hierarchy is reset and you lose the selection - even though obviously the node // you selected is in its own scope hierarchy so it looks buggy. int maxDepth = DesignerIteratorUtil.count(DesignerIteratorUtil.parentIterator(previousSelection, true)); rootScope.tryFindNode(previousSelection.getValue(), maxDepth) .ifPresent(scopeHierarchyTreeView.getSelectionModel()::select); } }
@Override protected void updateItem(Node item, boolean empty) { super.updateItem(item, empty); if (empty || item == null) { setText(null); setGraphic(null); return; } else { setText(item.toString() + (item.getImage() == null ? "" : " \"" + item.getImage() + "\"")); setContextMenu(buildContextMenu(item)); } // Reclicking the selected node in the ast will scroll back to the node in the editor this.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> { if (t.getButton() == MouseButton.PRIMARY && getTreeView().getSelectionModel().getSelectedItem().getValue() == item) { controller.onNodeItemSelected(item); t.consume(); } }); }
setFitToHeight(true); treeView.getSelectionModel().selectedItemProperty().addListener(observable -> { TreeItem selectedItem = treeView.getSelectionModel().getSelectedItem(); TreeItem temp = selectedItem; int level = treeView.getTreeItemLevel(temp) - (treeView.isShowRoot() ? 0 : 1);
private void handleOpenRequest() { MPerspective selectedItem = this.listView.getSelectionModel().getSelectedItem(); if (this.openConsumer != null && selectedItem != null ) { this.openConsumer.accept(selectedItem); } }
private <T> T listSelection(final ListView<T> listView) { return listView.selectionModelProperty().get().getSelectedItem(); } }
/** * Action for editing the selected equipment. */ @FXML private void onEditEquipment(final ActionEvent event) { // display edit dialog for selected equipment final Equipment selectedEquipment = liEquipments.getSelectionModel().getSelectedItem(); if (selectedEquipment!= null) { editEquipment(selectedEquipment); } }
/** * Action for editing the selected sport subtype. */ @FXML private void onEditSportSubtype(final ActionEvent event) { // display edit dialog for selected sport subtype final SportSubType selectedSportSubtype = liSportSubtypes.getSelectionModel().getSelectedItem(); if (selectedSportSubtype != null) { editSportSubType(selectedSportSubtype); } }
private void selectItem() { T item = suggestionList.getSelectionModel().getSelectedItem(); if (item == null) { try { suggestionList.getSelectionModel().select(0); item = suggestionList.getSelectionModel().getSelectedItem(); } catch (Exception e) { } } if (item != null) { control.getSelectionHandler().handle(new JFXAutoCompleteEvent<T>(JFXAutoCompleteEvent.SELECTION, item)); } }
/** * Action for editing the selected sport type. */ @FXML private void onEditSportType(final ActionEvent event) { // start SportType dialog for the selected sport type (can be null due to double clicks) final SportType selectedSportType = liSportTypes.getSelectionModel().getSelectedItem(); if (selectedSportType != null) { prSportTypeDialogController.get().show(getWindow(liSportTypes), selectedSportType); updateSportTypeList(); } }
/** * @{inheritedDoc} */ @Override public synchronized <T extends GenericEvent> void handle(T e) { super.handle(e); if (e.isA(CoreEvent.TreePopulatedFromTemplateEvent)) { LazyTreeItem item = (LazyTreeItem) treeView.getSelectionModel().getSelectedItem(); item.reloadChildren(); } else if (e.isA(CoreEvent.TreeFolderCreatedEvent)) { LazyTreeItem item = (LazyTreeItem) treeView.getSelectionModel().getSelectedItem(); item.reloadChildren(); } }
/** * */ @FXML public void clickRemoveClass() { if (this.listClass.getSelectionModel().getSelectedItem() == null) { setAlert(RESOURCES.getString("library_no_selected"), RESOURCES.getString("library_no_selected_header"), RESOURCES.getString("library_no_selected_content")); } else { final String nameFile = this.listClass.getSelectionModel().getSelectedItem(); URLClassLoaderUtil.remove(this.ctrlLeft.getPathFolder() + File.separator + nameFile.replace("/", File.separator)); this.listClass.getItems().remove(nameFile); if (this.listClass.getItems().size() == 0) { this.removeClass.setDisable(true); } } }
@Override public void handle(ActionEvent t) { TreeItem<CalendarNode> selectedItem = nodeList.getTreeView().getSelectionModel().getSelectedItem(); if (selectedItem != null) { CalendarNode calendarNode = selectedItem.getValue(); chart.removeNode(calendarNode); } } });
@Override protected void setStepEvents() { this.setNextButtonAction(event -> { MenuItem menuItem = new MenuItem(listViewWidget.getSelectionModel().getSelectedItem(), listViewWidget.getSelectionModel().getSelectedIndex()); messageWaitingForResponse.send(menuItem); }); }
private void onKeyPressed(KeyEvent e) { if (e.getCode() == KeyCode.DELETE) { showRemoveAlert(); } else if (e.getCode() == KeyCode.F2) { TreeItem<Object> item = contingencyTree.getSelectionModel().getSelectedItem(); if (item.getValue() instanceof Contingency) { rename(); } } }
@Override public void handle(ActionEvent event) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); content.putString(treeView.getSelectionModel().getSelectedItem().getValue().displayName); clipboard.setContent(content); } });
private void handleDatasetSelection(MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2 && event.getTarget() instanceof LabeledText) { PrintTools.info("Submitting new dataset request"); messager.submitMessage(CurrentDatasetPath, datasetsListView.getSelectionModel().getSelectedItem()); } }
private void applySelection() { ICompletionProposal selectedItem = this.proposalList.getSelectionModel().getSelectedItem(); if( selectedItem != null ) { IDocument document = this.viewer.getDocument(); selectedItem.apply(document); this.viewer.getTextWidget().setSelection(selectedItem.getSelection(document)); this.stage.hide(); } }