javafx.scene.control.cell.TextFieldListCell Java Examples

The following examples show how to use javafx.scene.control.cell.TextFieldListCell. 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: NameListPane.java    From OpenLabeler with Apache License 2.0 6 votes vote down vote up
public NameListPane() {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/preference/NameListPane.fxml"), bundle);
    loader.setRoot(this);
    loader.setController(this);

    try {
        loader.load();
    }
    catch (Exception ex) {
        LOG.log(Level.SEVERE, "Unable to load FXML", ex);
    }

    listName.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    listName.setCellFactory(TextFieldListCell.forListView());
    listName.setOnEditCommit((EventHandler<ListView.EditEvent<String>>) t -> {
        listName.getItems().set(t.getIndex(), t.getNewValue());
        listName.getSelectionModel().clearAndSelect(t.getIndex());
    });
}
 
Example #2
Source File: RFXListViewTextFieldListCellTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void select() {
    @SuppressWarnings("unchecked")
    ListView<String> listView = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        @SuppressWarnings("unchecked")
        TextFieldListCell<String> cell = (TextFieldListCell<String>) getCellAt(listView, 3);
        Point2D point = getPoint(listView, 3);
        RFXListView rfxListView = new RFXListView(listView, null, point, lr);
        rfxListView.focusGained(rfxListView);
        cell.startEdit();
        cell.updateItem("Item 4 Modified", false);
        cell.commitEdit("Item 4 Modified");
        rfxListView.focusLost(rfxListView);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Item 4 Modified", recording.getParameters()[0]);
}
 
Example #3
Source File: FolderEditorView.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
public void initialize(URL arg0, ResourceBundle arg1) {		
	folders.getSelectionModel().selectedIndexProperty().addListener((observable, oldVal, newVal) -> {
		if(oldVal != newVal) {
			updateTableFolder();				
		}
	});
	folders.setCellFactory((ListView) -> {
		return new TextFieldListCell<TableFolder>() {
			@Override
			public void updateItem(TableFolder course, boolean empty) {
				super.updateItem(course, empty);
				setText(empty ? "" : course.getName());
			}
		};
	});
	folderSongsController.setVisible("fullTitle", "sha256");
	searchSongsController.setVisible("fullTitle", "fullArtist", "mode", "level", "notes", "sha256");

	searchSongs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	
	updateFolder(null);
}
 
Example #4
Source File: PathEditorController.java    From standalone-app with Apache License 2.0 6 votes vote down vote up
@FXML
private void initialize() {
    this.list.setCellFactory(TextFieldListCell.forListView());

    List<String> path = configuration.getList(String.class, Settings.PATH_KEY, Collections.emptyList());
    this.list.getItems().addAll(path);

    stage = new Stage();
    stage.setOnCloseRequest(event -> {
        event.consume();
        stage.hide();
        this.list.getItems().removeAll(Arrays.asList(null, ""));
        configuration.setProperty(Settings.PATH_KEY, this.list.getItems());
        eventBus.post(new PathUpdatedEvent());
        pathController.reload();
    });
    stage.setScene(new Scene(root));
    stage.getIcons().add(new Image(getClass().getResourceAsStream("/res/icon.png")));
    stage.setTitle("Edit Path");
}
 
Example #5
Source File: BattleOfDecksConfigView.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public BattleOfDecksConfigView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/BattleOfDecksConfigView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	setupBehaviourBox();
	setupNumberOfGamesBox();

	selectedDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	selectedDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	availableDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	availableDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	addButton.setOnAction(this::handleAddButton);
	removeButton.setOnAction(this::handleRemoveButton);

	backButton.setOnAction(event -> NotificationProxy.sendNotification(GameNotification.MAIN_MENU));
	startButton.setOnAction(this::handleStartButton);
}
 
Example #6
Source File: CardCollectionEditor.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public CardCollectionEditor(String title, CardCollection cardCollection, ICardCollectionEditingListener listener, int cardLimit) {
	super("CardCollectionEditor.fxml");
	this.listener = listener;
	this.cardLimit = cardLimit;

	setTitle(title);

	editableListView.setCellFactory(TextFieldListCell.forListView(new CardStringConverter()));
	populateEditableView(cardCollection);

	catalogueListView.setCellFactory(TextFieldListCell.forListView(new CardStringConverter()));
	populateCatalogueView(null);

	filterTextfield.textProperty().addListener(this::onFilterTextChanged);
	clearFilterButton.setOnAction(actionEvent -> filterTextfield.clear());

	okButton.setOnAction(this::handleOkButton);
	cancelButton.setOnAction(this::handleCancelButton);

	addCardButton.setOnAction(this::handleAddCardButton);
	removeCardButton.setOnAction(this::handleRemoveCardButton);
}
 
Example #7
Source File: TrainingConfigView.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public TrainingConfigView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/TrainingConfigView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	setupDeckBox();
	setupNumberOfGamesBox();

	selectedDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	selectedDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	availableDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	availableDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	addButton.setOnAction(this::handleAddButton);
	removeButton.setOnAction(this::handleRemoveButton);

	backButton.setOnAction(event -> NotificationProxy.sendNotification(GameNotification.MAIN_MENU));
	startButton.setOnAction(this::handleStartButton);
}
 
Example #8
Source File: TextFieldListViewSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public TextFieldListViewSample() {
    final ListView<String> listView = new ListView<String>();
    listView.setItems(FXCollections.observableArrayList("Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7",
            "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18",
            "Row 19", "Row 20"));
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    listView.setEditable(true);
    listView.setCellFactory(TextFieldListCell.forListView());
    getChildren().add(listView);
}
 
Example #9
Source File: RFXTextFieldListCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    TextFieldListCell<?> cell = (TextFieldListCell<?>) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example #10
Source File: CourseEditorView.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public void initialize(URL arg0, ResourceBundle arg1) {
	gradeType.getItems().setAll(null, CLASS, MIRROR, RANDOM);
	hispeedType.getItems().setAll(null, NO_SPEED);
	judgeType.getItems().setAll(null, NO_GOOD, NO_GREAT);
	gaugeType.getItems().setAll(null, GAUGE_LR2,  GAUGE_5KEYS,  GAUGE_7KEYS,  GAUGE_9KEYS,  GAUGE_24KEYS);
	lnType.getItems().setAll(null, LN,  CN,  HCN);
	
	courses.getSelectionModel().selectedIndexProperty().addListener((observable, oldVal, newVal) -> {
		if(oldVal != newVal) {
			updateCourseData();				
		}
	});
	courses.setCellFactory((ListView) -> {
		return new TextFieldListCell<CourseData>() {
			@Override
			public void updateItem(CourseData course, boolean empty) {
				super.updateItem(course, empty);
				setText(empty ? "" : course.getName());
			}
		};
	});
	courseSongsController.setVisible("fullTitle", "sha256");
	searchSongsController.setVisible("fullTitle", "fullArtist", "mode", "level", "notes", "sha256");

	searchSongs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	updateCourse(null);
}
 
Example #11
Source File: FeatureTableColumnsEditor.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public FeatureTableColumnsEditor(PropertySheet.Item parameter) {

    // HBox properties
    setSpacing(10);
    setAlignment(Pos.CENTER_LEFT);

    namePatternList = new ListView<>();
    namePatternList.setEditable(true);
    namePatternList.setPrefHeight(150);
    namePatternList.setCellFactory(TextFieldListCell.forListView());

    Button addButton = new Button("Add");
    addButton.setOnAction(e -> {
      TextInputDialog dialog = new TextInputDialog();
      dialog.setTitle("Add name pattern");
      dialog.setHeaderText("New name pattern");
      Optional<String> result = dialog.showAndWait();
      result.ifPresent(value -> namePatternList.getItems().add(value));
    });

    Button removeButton = new Button("Remove");
    removeButton.setOnAction(e -> {
      List<String> selectedItems = namePatternList.getSelectionModel().getSelectedItems();
      namePatternList.getItems().removeAll(selectedItems);
    });

    VBox buttons = new VBox(addButton, removeButton);
    buttons.setSpacing(10);

    getChildren().addAll(namePatternList, buttons);
  }
 
Example #12
Source File: DefaultSpellCheckLanguageFactory.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
@Override
public FXFormNode call(Void param) {

    final ListView<Path> listView = spellcheckConfigBean.getLanguagePathList();

    listView.setCellFactory(li -> new TextFieldListCell<>(new StringConverter<Path>() {
        @Override
        public String toString(Path object) {
            return IOHelper.getPathCleanName(object);
        }

        @Override
        public Path fromString(String string) {
            return IOHelper.getPath(string);
        }
    }));

    HBox hBox = new HBox(5);
    hBox.getChildren().add(listView);

    hBox.getChildren().add(new VBox(10, languageLabel, setDefaultButton, addNewLanguageButton));
    HBox.setHgrow(listView, Priority.ALWAYS);

    listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

    setDefaultButton.setOnAction(this::setDefaultLanguage);

    return new FXFormNodeWrapper(hBox, listView.itemsProperty());
}
 
Example #13
Source File: UIEnumMenuItem.java    From tcMenu with Apache License 2.0 4 votes vote down vote up
@Override
protected int internalInitPanel(GridPane grid, int idx) {
    idx++;
    grid.add(new Label("Values"), 0, idx);
    ObservableList<String> list = FXCollections.observableArrayList(getMenuItem().getEnumEntries());
    listView = new ListView<>(list);
    listView.setEditable(true);

    listView.setCellFactory(TextFieldListCell.forListView());

    listView.setOnEditCommit(t -> {
        listView.getItems().set(t.getIndex(), t.getNewValue());
    });

    listView.setMinHeight(100);
    grid.add(listView, 1, idx, 1, 3);
    idx+=3;
    Button addButton = new Button("Add");
    addButton.setId("addEnumEntry");
    Button removeButton = new Button("Remove");
    removeButton.setId("removeEnumEntry");
    removeButton.setDisable(true);
    HBox hbox = new HBox(addButton, removeButton);
    grid.add(hbox, 1, idx);

    addButton.setOnAction(event -> {
        listView.getItems().add("ChangeMe");
        listView.getSelectionModel().selectLast();
    });

    removeButton.setOnAction(event -> {
        String selectedItem = listView.getSelectionModel().getSelectedItem();
        if(selectedItem != null) {
            list.remove(selectedItem);
        }
    });

    list.addListener((ListChangeListener<? super String>) observable -> callChangeConsumer());

    listView.setId("enumList");
    listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) ->
            removeButton.setDisable(newValue == null)
    );
    listView.getSelectionModel().selectFirst();
    return idx;
}
 
Example #14
Source File: AutoCompletePopupSkin2.java    From BlockMap with MIT License 2 votes vote down vote up
/**
 * @param displayConverter
 *            An alternate {@link StringConverter} to use. This way, you can show autocomplete suggestions that when applied will fill in a
 *            different text than displayed. For example, you may preview {@code Files.newBufferedReader(Path: path) - Bufferedreader} but
 *            only fill in {@code Files.newBufferedReader(}
 */
public AutoCompletePopupSkin2(AutoCompletePopup<T> control, StringConverter<T> displayConverter) {
	this(control, TextFieldListCell.forListView(displayConverter));
}