@Override @FXThread protected void createComponents() { super.createComponents(); comboBox = new ComboBox<>(); comboBox.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT)); comboBox.getItems().addAll(FONTS); comboBox.setVisibleRowCount(20); comboBox.setConverter(STRING_CONVERTER); comboBox.setEditable(true); final SingleSelectionModel<Font> selectionModel = comboBox.getSelectionModel(); selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) -> change()); final AutoCompletionTextFieldBinding<Font> binding = new AutoCompletionTextFieldBinding<>(comboBox.getEditor(), SuggestionProvider.create(comboBox.getItems()), STRING_CONVERTER); binding.setOnAutoCompleted(event -> selectionModel.select(event.getCompletion())); FXUtils.addClassesTo(comboBox.getEditor(), CSSClasses.TRANSPARENT_TEXT_FIELD, CSSClasses.TEXT_FIELD_IN_COMBO_BOX); FXUtils.addClassTo(comboBox, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX); FXUtils.addToPane(comboBox, this); }
@Override @FXThread protected void processOpen(@NotNull final ResourceElement element) { super.processOpen(element); final ComboBox<String> textureParamNameBox = getTextureParamNameComboBox(); final SingleSelectionModel<String> selectionModel = textureParamNameBox.getSelectionModel(); final String textureParamName = selectionModel.getSelectedItem(); final CheckBox transformBox = getApplyLightingTransformCheckBox(); final AssetManager assetManager = EDITOR.getAssetManager(); final Path file = element.getFile(); final Path assetFile = getAssetFile(file); if (assetFile == null) { throw new RuntimeException("AssetFile can't be null."); } final Material material = assetManager.loadAsset(new MaterialKey(toAssetPath(assetFile))); final Consumer<ParticlesMaterial> consumer = getConsumer(); consumer.accept(new ParticlesMaterial(material, textureParamName, transformBox.isSelected())); }
/** * Update a list of available path sizes. */ @FXThread private void updatePathSizeValues() { final ComboBox<Integer> pathSizeComboBox = getPatchSizeComboBox(); final SingleSelectionModel<Integer> selectionModel = pathSizeComboBox.getSelectionModel(); final Integer current = selectionModel.getSelectedItem(); final ObservableList<Integer> items = pathSizeComboBox.getItems(); items.clear(); final ComboBox<Integer> totalSizeComboBox = getTotalSizeComboBox(); final Integer naxValue = totalSizeComboBox.getSelectionModel().getSelectedItem(); for (final Integer value : PATCH_SIZE_VARIANTS) { if (value >= naxValue) break; items.add(value); } if (items.contains(current)) { selectionModel.select(current); } else { selectionModel.select(items.get(items.size() - 1)); } }
/** * Handle the request to open a file. */ @FXThread private void processOpenFile(@NotNull final RequestedOpenFileEvent event) { final Path file = event.getFile(); final ConcurrentObjectDictionary<Path, Tab> openedEditors = getOpenedEditors(); final Tab tab = DictionaryUtils.getInReadLock(openedEditors, file, ObjectDictionary::get); if (tab != null) { final SingleSelectionModel<Tab> selectionModel = getSelectionModel(); selectionModel.select(tab); return; } EditorUtil.incrementLoading(); EXECUTOR_MANAGER.addBackgroundTask(() -> processOpenFileImpl(event, file)); }
private void applyValues() { inConnectionPortField.setText(String.valueOf(ApplicationPreferences.getProperty( NetworkProperties.INCOMING_CONNECTION_PORT, ClientProperties.TCP_PORT))); final boolean randomizePortOnStart = ApplicationPreferences.getProperty( NetworkProperties.RANDOMIZE_CONNECTION_PORT, false); randomPortEachStartCheck.setSelected(randomizePortOnStart); final boolean upnpPortMappingEnabled = ApplicationPreferences.getProperty( NetworkProperties.ENABLE_UPNP_PORT_MAPPING, false); upnpPortMappingCheck.setSelected(upnpPortMappingEnabled); final String interfaceName = ApplicationPreferences.getProperty( NetworkProperties.NETWORK_INTERFACE_NAME, NetworkUtilities.DEFAULT_NETWORK_INTERFACE); final SingleSelectionModel<String> comboSelectionModel = networkInterfaceSelectionCombo.getSelectionModel(); if(networkInterfaceSelectionCombo.getItems().contains(interfaceName)) { comboSelectionModel.select(interfaceName); } else { comboSelectionModel.select(NetworkUtilities.DEFAULT_NETWORK_INTERFACE); } }
@Override protected void mouseClicked(MouseEvent me) { TabPane tp = (TabPane) node; SingleSelectionModel<Tab> selectionModel = tp.getSelectionModel(); Tab selectedTab = selectionModel.getSelectedItem(); if (selectedTab != null && prevSelection != selectionModel.getSelectedIndex()) { recorder.recordSelect(this, getTextForTab(tp, selectedTab)); } prevSelection = selectionModel.getSelectedIndex(); }
public <T> void bind(ComboBox<T> box) { box.getSelectionModel() .selectedItemProperty() .addListener((ob, o, n) -> add(Undoable.create( UndoUtil.<SingleSelectionModel<T>, T> weakConsumer(box.getSelectionModel(), SingleSelectionModel::select), n, o))); }
private void handleFilterChanged(String newValue) { if (filteredItems != null) { Predicate<T> p = filter.get().isEmpty() ? null : s -> comparator.matches(filter.get(), s); filteredItems.setPredicate(p); } if (!StringUtils.isBlank(newValue)) { comboBox.show(); if (StringUtils.isBlank(filter.get())) { restoreOriginalItems(); } else { showTooltip(); SingleSelectionModel<T> selectionModel = comboBox.getSelectionModel(); if (filteredItems.isEmpty()) { selectionModel.clearSelection(); } else { selectionModel.select(0); } } } else { comboBox.getTooltip().hide(); restoreOriginalItems(); } }
@Override @FXThread protected void changeImpl() { final ComboBox<String> comboBox = getComboBox(); final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel(); setPropertyValue(selectionModel.getSelectedItem()); super.changeImpl(); }
@Override @FXThread protected void changeImpl() { final ComboBox<Font> comboBox = getComboBox(); final SingleSelectionModel<Font> selectionModel = comboBox.getSelectionModel(); setPropertyValue(selectionModel.getSelectedItem()); super.changeImpl(); }
@Override @FXThread protected void changeImpl() { final ComboBox<T> enumComboBox = getEnumComboBox(); final SingleSelectionModel<T> selectionModel = enumComboBox.getSelectionModel(); setPropertyValue(selectionModel.getSelectedItem()); super.changeImpl(); }
@Override @FXThread protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() { final ComboBox<String> comboBox = getTextureParamNameComboBox(); final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel(); final ReadOnlyObjectProperty<String> itemProperty = selectionModel.selectedItemProperty(); final ObservableBooleanValue parent = super.buildAdditionalDisableCondition(); return Bindings.and(parent, itemProperty.isNull().or(itemProperty.isEqualTo(""))); }
@Override @FXThread protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) { final ComboBox<String> comboBox = getTextureParamNameComboBox(); final ObservableList<String> items = comboBox.getItems(); items.clear(); final Path file = element == null ? null : element.getFile(); if (file != null && !Files.isDirectory(file)) { final AssetManager assetManager = EDITOR.getAssetManager(); final Path assetFile = getAssetFile(file); if (assetFile == null) { throw new RuntimeException("AssetFile can't be null."); } final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile)); final Material material = assetManager.loadAsset(materialKey); final MaterialDef materialDef = material.getMaterialDef(); final Collection<MatParam> materialParams = materialDef.getMaterialParams(); materialParams.stream() .filter(param -> param.getVarType() == VarType.Texture2D) .filter(matParam -> material.getTextureParam(matParam.getName()) != null) .forEach(filtred -> items.add(filtred.getName())); final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel(); if (!items.isEmpty()) { selectionModel.select(0); } else { selectionModel.select(null); } } super.validate(warningLabel, element); }
/** * Update selected {@link Enum} value. */ @FXThread private void change() { if (isIgnoreListener()) return; final ComboBox<E> enumComboBox = getEnumComboBox(); final SingleSelectionModel<E> selectionModel = enumComboBox.getSelectionModel(); final E newValue = selectionModel.getSelectedItem(); changed(newValue, getPropertyValue()); }
@Override @FXThread protected void reload() { final E element = getPropertyValue(); final ComboBox<E> enumComboBox = getEnumComboBox(); final SingleSelectionModel<E> selectionModel = enumComboBox.getSelectionModel(); selectionModel.select(element); }
@Override @FXThread protected void createContent(@NotNull final GridPane root) { super.createContent(root); final Label algorithmTypeLabel = new Label(Messages.GENERATE_TANGENTS_DIALOG_ALGORITHM_LABEL + ":"); algorithmTypeLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT3)); algorithmTypeComboBox = new ComboBox<>(GenerateTangentsDialog.ALGORITHM_TYPES); algorithmTypeComboBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT3)); final SingleSelectionModel<AlgorithmType> selectionModel = algorithmTypeComboBox.getSelectionModel(); selectionModel.select(AlgorithmType.MIKKTSPACE); final Label splitMirroredLabel = new Label(Messages.GENERATE_TANGENTS_DIALOG_SPLIT_MIRRORED + ":"); splitMirroredLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT3)); splitMirroredCheckBox = new CheckBox(); splitMirroredCheckBox.disableProperty().bind(selectionModel.selectedItemProperty().isNotEqualTo(AlgorithmType.STANDARD)); splitMirroredCheckBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT3)); root.add(algorithmTypeLabel, 0, 0); root.add(algorithmTypeComboBox, 1, 0); root.add(splitMirroredLabel, 0, 1); root.add(splitMirroredCheckBox, 1, 1); FXUtils.addClassTo(algorithmTypeLabel, splitMirroredLabel, CSSClasses.DIALOG_DYNAMIC_LABEL); FXUtils.addClassTo(algorithmTypeComboBox, splitMirroredCheckBox, CSSClasses.DIALOG_FIELD); }
/** * Add and open the new file editor. * * @param editor the editor * @param needShow the need show */ @FXThread private void addEditor(@NotNull final FileEditor editor, final boolean needShow) { final Path editFile = editor.getEditFile(); final Tab tab = new Tab(editor.getFileName()); tab.setGraphic(new ImageView(ICON_MANAGER.getIcon(editFile, DEFAULT_FILE_ICON_SIZE))); tab.setContent(editor.getPage()); tab.setOnCloseRequest(event -> handleRequestToCloseEditor(editor, tab, event)); final ObservableMap<Object, Object> properties = tab.getProperties(); properties.put(KEY_EDITOR, editor); editor.dirtyProperty().addListener((observable, oldValue, newValue) -> { tab.setText(newValue == Boolean.TRUE ? "*" + editor.getFileName() : editor.getFileName()); }); final ObservableList<Tab> tabs = getTabs(); tabs.add(tab); if (needShow) { final SingleSelectionModel<Tab> selectionModel = getSelectionModel(); selectionModel.select(tab); } DictionaryUtils.runInWriteLock(getOpenedEditors(), editFile, tab, ObjectDictionary::put); EditorUtil.decrementLoading(); if (isIgnoreOpenedFiles()) { return; } final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace(); if (workspace != null) { workspace.addOpenedFile(editFile, editor); } }
public void request(RealtimeSearchItemVO userData) { SingleSelectionModel<Class<? extends ExtractorBase>> selectionModel = cbAlgorisms.getSelectionModel(); Class<? extends ExtractorBase> selectAlgorism = selectionModel.getSelectedItem(); if (selectAlgorism != null) { request(selectAlgorism, userData); } }
public void request(String url) { SingleSelectionModel<Class<? extends ExtractorBase>> selectionModel = cbAlgorisms.getSelectionModel(); Class<? extends ExtractorBase> selectAlgorism = selectionModel.getSelectedItem(); if (selectAlgorism != null) { RealtimeSearchItemVO vo = new RealtimeSearchItemVO(); vo.setLink(url); request(selectAlgorism, vo); } }
private void updateTabPane(TabPackage tabPack) { View v = tabPack.getController().getView(); VBox vbox = new VBox(); Tab tab = new Tab("Workspace " + this.views.size()); vbox.getChildren().addAll(v.getToolPanel(), v.getGrid()); tab.setContent(vbox); tabPane.getTabs().add(tab); SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); selectionModel.select(tab); tab.setOnClosed(e -> { this.views.remove(v); if(this.views.size() == 0) { System.exit(0); } }); tab.setOnSelectionChanged(e -> { if(tab.isSelected()) { tabPack.getController().getModel().updateCurrentTab(tabPack.getId()); internalEditor.setId(tabPack.getId()); } }); v.setCenter(tabPane); }
@FXML private void retrain(ActionEvent event) throws Exception{ //ADD retrain the model System.out.println("Retraining the model"); SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); selectionModel.select(tab2); }
@FXML private void processSave(ActionEvent event) { System.out.println("Steping to next step saving file..."); String path = outFolder.textProperty().getValue().toString(); at.saveChanges(path, personData, predicted.isSelected()); SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); selectionModel.select(tab5); }
@FXML public void btnHomeClicked(ActionEvent event) { System.out.println("Back to Accounts button clicked"); System.out.println(paneRslt.getParent().getParent().getId()); TabPane main = (TabPane) paneRslt.getParent().getParent(); SingleSelectionModel<Tab> tb = main.getSelectionModel(); tb.select(0); }
public void setTab(int i) { SingleSelectionModel<Tab> tb = tbMain.getSelectionModel(); tb.select(i); if (i == 2) resultsViewController.LoadLists(); }
@FXML private void handleRunAllButton(ActionEvent event) { SingleSelectionModel<Tab> selectionModel = tabs.getSelectionModel(); selectionModel.select(controlConsole); modelFacade.getJsConsole().start(); modelFacade.getSoyConsole().start(); modelFacade.getGssConsole().start(); }
private void focusToTab() { SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); selectionModel.selectLast(); }
/** * <p>Gets the model used for tab selection.</p> */ public final SingleSelectionModel<DockTab> getSelectionModel() { return selectionModel.get(); }
/** * The selection model used for selecting tabs. */ public final ObjectProperty<SingleSelectionModel<DockTab>> selectionModelProperty() { return selectionModel; }
/** * Switched the selected tab according to the source * @param source The object that trigger the change */ private void switchTab(Object source) { SingleSelectionModel<Tab> selection = this.contentPane.getSelectionModel(); Tab oldTab = selection.getSelectedItem(); if (oldTab == this.newsTab) { this.newsLabel.getStyleClass().remove("selectedItem"); } else if (oldTab == this.skinsTab) { this.skinsLabel.getStyleClass().remove("selectedItem"); } else if (oldTab == this.settingsTab) { this.settingsLabel.getStyleClass().remove("selectedItem"); } else if (oldTab == this.launchOptionsTab && source != this.profileEditorTab) { this.launchOptionsLabel.getStyleClass().remove("selectedItem"); } else if (oldTab == this.profileEditorTab) { //Show play button this.playPane.setVisible(true); this.launchOptionsLabel.getStyleClass().remove("selectedItem"); } else if (oldTab == this.loginTab) { this.newsLabel.getStyleClass().remove("selectedItem"); this.skinsLabel.getStyleClass().remove("selectedItem"); this.settingsLabel.getStyleClass().remove("selectedItem"); this.launchOptionsLabel.getStyleClass().remove("selectedItem"); } if (source == this.newsLabel) { this.newsLabel.getStyleClass().add("selectedItem"); selection.select(this.newsTab); } else if (source == this.skinsLabel) { this.skinsLabel.getStyleClass().add("selectedItem"); selection.select(this.skinsTab); if (!this.texturesLoaded) { this.loadTextures(); } } else if (source == this.settingsLabel) { this.settingsLabel.getStyleClass().add("selectedItem"); selection.select(this.settingsTab); } else if (source == this.launchOptionsLabel) { this.launchOptionsLabel.getStyleClass().add("selectedItem"); selection.select(this.launchOptionsTab); this.profileList.getSelectionModel().clearSelection(); } else if (source == this.profileEditorTab) { //Hide play button this.playPane.setVisible(false); selection.select(this.profileEditorTab); } }
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Tabs"); JFXTabPane tabPane = new JFXTabPane(); Tab tab = new Tab(); tab.setText(msg); tab.setContent(new Label(TAB_0)); tabPane.getTabs().add(tab); tabPane.setPrefSize(300, 200); Tab tab1 = new Tab(); tab1.setText(TAB_01); tab1.setContent(new Label(TAB_01)); tabPane.getTabs().add(tab1); SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); selectionModel.select(1); JFXButton button = new JFXButton("New Tab"); button.setOnMouseClicked((o) -> { Tab temp = new Tab(); int count = tabPane.getTabs().size(); temp.setText(msg + count); temp.setContent(new Label(TAB_0 + count)); tabPane.getTabs().add(temp); }); tabPane.setMaxWidth(500); HBox hbox = new HBox(); hbox.getChildren().addAll(button, tabPane); hbox.setSpacing(50); hbox.setAlignment(Pos.CENTER); hbox.setStyle("-fx-padding:20"); Group root = new Group(); Scene scene = new Scene(root, 700, 250); root.getChildren().addAll(hbox); scene.getStylesheets().add(TabsDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); primaryStage.setTitle("JFX Tabs Demo"); primaryStage.setScene(scene); primaryStage.show(); }
@FXML private void save(ActionEvent event) throws Exception{ //ADD the existing file to the output folder SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); selectionModel.select(tab5); }
@FXML private void handleRunButton(ActionEvent event) { SingleSelectionModel<Tab> selectionModel = tabs.getSelectionModel(); selectionModel.select(controlConsole); modelFacade.getGssConsole().start(); }
@FXML private void handleRunButton(ActionEvent event) { SingleSelectionModel<Tab> selectionModel = tabs.getSelectionModel(); selectionModel.select(controlConsole); modelFacade.getJsConsole().start(); }
@FXML private void handleRunButton(ActionEvent event) { SingleSelectionModel<Tab> selectionModel = tabs.getSelectionModel(); selectionModel.select(controlConsole); modelFacade.getSoyConsole().start(); }
private void addAndSelectNewTab(ObservableList<Tab> tabs, Tab tab2, SingleSelectionModel<Tab> selectedTab, SingleSelectionModel<Tab> fxSelectedTab ,int selectedTabIndex) { // TODO Auto-generated method stub Platform.runLater(new Runnable() { @Override public void run() { for(int a=0; a<tabs.size();a++){ String openTabName = tabs.get(a).getText(); if(openTabName.equals("History") || openTabName.equals("Bookmarks") || openTabName.equals("Downloads") || openTabName.equals("Setting")) { // fxSelectedTab.select(selectedTabIndex); System.out.println("Tab index:"+ selectedTabIndex); selectedTab.select(a); return; } } fxSelectedTab.select(selectedTabIndex); tabs.add(tabs.size() - 1, tab); selectedTab.select(tab); getBookMarkView(); } }); }