Java Code Examples for javafx.scene.control.SelectionMode

The following are top voted examples for showing how to use javafx.scene.control.SelectionMode. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: code-tracker   File: MainController.java   Source Code and License 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void initialize(URL location, ResourceBundle resources) {
    // Initializes test base, tester and test map to access and modify the algorithm base
    testBase = TestBase.INSTANCE;   // Gets a reference to the test base
    tester = new Tester();          //
    testMap = tester.getTestMap();

    // Binds the list view with a list of algorithms (list items)
    listItems = FXCollections.observableList(new ArrayList<>(testMap.keySet()));
    list.itemsProperty().bindBidirectional(new SimpleListProperty<>(listItems));
    list.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    list.getSelectionModel().selectedItemProperty().addListener((((observable, oldValue, newValue) -> {
        if(newValue != null) {
            textArea.setText(testMap.get(newValue).getContent());
        } else {
            textArea.clear();
        }
    })));
    list.getSelectionModel().select(0);

    // Initializes the trie that stores all algorithm names
    algorithmNameTrie = new Trie();
    for(String algorithmName : testMap.keySet()) {
        algorithmNameTrie.addWord(algorithmName);
    }

    // Binds search field with the list view (displays search result)
    searchField.textProperty().addListener((observable, oldValue, newValue) -> {
        listItems.setAll(algorithmNameTrie.getWords(newValue.toLowerCase()));
        if(!listItems.isEmpty()) {
            list.getSelectionModel().select(0);
        }
    });

    // For unknown reasons, this style does not work on css, so I put it in here
    textArea.setStyle("-fx-focus-color: transparent; -fx-text-box-border: transparent;");
    textArea.setFocusTraversable(false);
}
 
Example 2
Project: marathonv5   File: ListViewCellFactorySample.java   Source Code and License 6 votes vote down vote up
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));
    
    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        
    
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
 
Example 3
Project: marathonv5   File: JavaFXTreeTableViewElementTest.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked") @Test public void selectAllCells() {
    TreeTableView<?> treeTableNode = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
    Platform.runLater(() -> {
        TreeTableViewSelectionModel<?> selectionModel = treeTableNode.getSelectionModel();
        selectionModel.setCellSelectionEnabled(true);
        selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
        selectionModel.selectRange(0, getTreeTableColumnAt(treeTableNode, 0), treeTableNode.getExpandedItemCount() - 1,
                getTreeTableColumnAt(treeTableNode, 1));
        treeTable.marathon_select("all");
    });
    new Wait("Waiting for all cells to be selected") {
        @Override public boolean until() {
            return treeTableNode.getSelectionModel().getSelectedCells().size() == treeTableNode.getExpandedItemCount()
                    * treeTableNode.getColumns().size();
        }
    };
}
 
Example 4
Project: marathonv5   File: JavaFXTableViewElementScrollTest.java   Source Code and License 6 votes vote down vote up
@Test public void scrollMultipleRows() {
    Stage primaryStage = getPrimaryStage();
    primaryStage.setWidth(250);
    primaryStage.setHeight(250);
    TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view");
    Platform.runLater(() -> {
        tableViewNode.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        tableView.marathon_select("{\"rows\":[2,9]}");
    });
    new Wait("Wating for rows to be select.") {
        @Override public boolean until() {
            return tableViewNode.getSelectionModel().getSelectedIndices().size() > 1;
        }
    };
    new Wait("Waiting for the point to be in viewport") {
        @Override public boolean until() {
            Point2D point = getPoint(tableViewNode, 2, 9);
            return tableViewNode.getBoundsInLocal().contains(point);
        }
    };
}
 
Example 5
Project: marathonv5   File: ListViewCellFactorySample.java   Source Code and License 6 votes vote down vote up
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));
    
    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        
    
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
 
Example 6
Project: marathonv5   File: SimpleListViewScrollSample.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
    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", "Row 21", "Row 22", "Row 23", "Row 24", "Row 25"));
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    Button button = new Button("Debug");
    button.setOnAction((e) -> {
        ObservableList<Integer> selectedIndices = listView.getSelectionModel().getSelectedIndices();
        for (Integer index : selectedIndices) {
            ListCell cellAt = getCellAt(listView, index);
            System.out.println("SimpleListViewScrollSample.SimpleListViewScrollSampleApp.start(" + cellAt + ")");
        }
    });
    VBox root = new VBox(listView, button);
    primaryStage.setScene(new Scene(root, 300, 400));
    primaryStage.show();
}
 
Example 7
Project: marathonv5   File: ChoiceBoxTreeTableSampleApp.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) {
    primaryStage.setTitle("TreeTable View Sample");
    primaryStage.setScene(new Scene(new ChoiceBoxTreeTableSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
    TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
Example 8
Project: marathonv5   File: TreeTableSampleApp.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) {
    primaryStage.setTitle("TreeTable View Sample");
    primaryStage.setScene(new Scene(new TreeTableSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
    TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
Example 9
Project: marathonv5   File: RFXTreeTableViewTest.java   Source Code and License 6 votes vote down vote up
@Test public void selectAllRows() {
    TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, null, lr);
        int count = treeTableView.getExpandedItemCount();
        for (int i = 0; i < count; i++) {
            treeTableView.getSelectionModel().select(i);
        }
        rfxTreeTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("all", recording.getParameters()[0]);
}
 
Example 10
Project: marathonv5   File: RFXTreeTableViewTest.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked") @Test public void selectMultipleCells() {
    TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel();
        selectionModel.setCellSelectionEnabled(true);
        selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
        Point2D point = getPoint(treeTableView, 1, 0);
        RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr);
        rfxTreeTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0);
        selectionModel.select(1, column);
        selectionModel.select(3, getTreeTableColumnAt(treeTableView, 1));
        rfxTreeTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals(
            "{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"],[\"/Sales Department/Michael Brown\",\"Email\"]]}",
            recording.getParameters()[0]);
}
 
Example 11
Project: marathonv5   File: RFXTreeTableViewTest.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked") @Test public void selectAllCells() {
    TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, null, lr);
        int count = treeTableView.getExpandedItemCount();
        treeTableView.getSelectionModel().selectRange(0, getTreeTableColumnAt(treeTableView, 0), count - 1,
                getTreeTableColumnAt(treeTableView, 1));
        rfxTreeTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("all", recording.getParameters()[0]);
}
 
Example 12
Project: marathonv5   File: RFXTreeViewTest.java   Source Code and License 6 votes vote down vote up
@Test public void getTextForMultipleSelection() {
    @SuppressWarnings("rawtypes")
    TreeView treeView = (TreeView) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXTreeView rTreeView = new RFXTreeView(treeView, null, null, lr);
            @SuppressWarnings("rawtypes")
            MultipleSelectionModel selectionModel = treeView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 3);
            rTreeView.focusLost(new RFXTreeView(null, null, null, null));
            text.add(rTreeView.getAttribute("text"));
        }
    });
    new Wait("Waiting for tree text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("[\"/Root node/Child Node 2\",\"/Root node/Child Node 3\"]", text.get(0));
}
 
Example 13
Project: marathonv5   File: RFXTableViewTest.java   Source Code and License 6 votes vote down vote up
@Test public void selectMulpitleRows() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        tableView.getSelectionModel().selectIndices(1, 3);
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("{\"rows\":[1,3]}", recording.getParameters()[0]);
}
 
Example 14
Project: marathonv5   File: RFXTableViewTest.java   Source Code and License 6 votes vote down vote up
@Test public void selectAllRows() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        tableView.getSelectionModel().selectRange(0, 5);
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("all", recording.getParameters()[0]);
}
 
Example 15
Project: marathonv5   File: RFXTableViewTest.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked") @Test public void selectMultipleCells() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TableColumn column = getTableColumnAt(tableView, 1);
        tableView.getSelectionModel().select(1, column);
        tableView.getSelectionModel().select(2, column);
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"],[\"2\",\"Last\"]]}", recording.getParameters()[0]);
}
 
Example 16
Project: marathonv5   File: RFXTableViewTest.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked") @Test public void selectAllCells() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        tableView.getSelectionModel().selectRange(0, getTableColumnAt(tableView, 0), 5, getTableColumnAt(tableView, 2));
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("all", recording.getParameters()[0]);
}
 
Example 17
Project: marathonv5   File: RFXListViewTest.java   Source Code and License 6 votes vote down vote up
@Test public void getTextForMultipleSelection() {
    ListView<?> listView = (ListView<?>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            MultipleSelectionModel<?> selectionModel = listView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 8);
            RFXListView rfxListView = new RFXListView(listView, null, null, lr);
            rfxListView.focusLost(new RFXListView(null, null, null, lr));
            text.add(rfxListView.getAttribute("text"));
        }
    });
    new Wait("Waiting for list text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("[\"Long Row 3\",\"Row 9\"]", text.get(0));
}
 
Example 18
Project: marathonv5   File: RFXListViewTest.java   Source Code and License 6 votes vote down vote up
@Test public void selectMultipleItemSelection() {
    ListView<?> listView = (ListView<?>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            MultipleSelectionModel<?> selectionModel = listView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 6);
            RFXListView rfxListView = new RFXListView(listView, null, null, lr);
            rfxListView.focusLost(new RFXListView(null, null, null, lr));
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("[\"Long Row 3\",\"Row 7\"]", recording.getParameters()[0]);
}
 
Example 19
Project: CSLMusicModStationCreator   File: ConjunctionEditor.java   Source Code and License 6 votes vote down vote up
@FXML
private void initialize() {
    content.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    addEntry.showingProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean t1) {
            rebuildAddItemMenu();
        }
    });

    content.setOnKeyPressed(keyEvent -> {
        if(keyEvent.getCode() == KeyCode.DELETE) {
            removeEntries();
        }
    });
}
 
Example 20
Project: CSLMusicModStationCreator   File: ContextEntryEditor.java   Source Code and License 6 votes vote down vote up
@FXML
private void initialize() {

    songs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    contextCollections.getCheckModel().getCheckedItems().addListener(new ListChangeListener<String>() {
        @Override
        public void onChanged(Change<? extends String> change) {
            updateSongsAutoComplete();
        }
    });
    songs.setOnKeyPressed(keyEvent -> {
        if(keyEvent.getCode() == KeyCode.DELETE) {
            removeSongs();
        }
    });
}
 
Example 21
Project: qupath-tracking-extension   File: ExtendedViewTrackerPlayback.java   Source Code and License 6 votes vote down vote up
public static TableView<ViewRecordingFrame> makeTable(QuPathViewer viewer, ViewTracker tracker) {

        TableView<ViewRecordingFrame> table = new TableView();

        for (int i = 0; i < nCols(tracker); ++i) {
            TableColumn<ViewRecordingFrame, Object> column = new TableColumn(getColumnName(i));
            final int j = i;
            column.setCellValueFactory(frame -> new SimpleObjectProperty(
                    getColumnValue((ViewRecordingFrame)frame.getValue(), j)));
            table.getColumns().add(column);
        }

        table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        table.getSelectionModel().selectedItemProperty().addListener((v, o, frame) -> {
            if (frame != null) {
                setViewerForFrame(viewer, frame);
            }
        });
        ObservableList<ViewRecordingFrame> frameList = FXCollections.observableArrayList(
                TrackerUtils.getFramesAsArrayList(tracker));

        table.setItems(frameList);
        return table;
    }
 
Example 22
Project: openjfx-8u-dev-tests   File: ListViewApp.java   Source Code and License 6 votes vote down vote up
private void reset() {
    //view.setItems(new ArrayList<Object>());
    while (view.getItems().size() > 0) {
        view.getItems().remove(0);
    }
    view.getItems().addAll(Arrays.asList(DEFAULT_ITEMS));
    view.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    view.getSelectionModel().clearSelection();
    textToAdd.setText("item");

    if (addItemsOnInit > 0) {
        for (int i = 0; i < addItemsOnInit; ++i) {
            view.getItems().add(0, "item " + (addItemsOnInit - i));
        }
    }
}
 
Example 23
Project: openjfx-8u-dev-tests   File: NewListViewTest.java   Source Code and License 6 votes vote down vote up
protected void commonClickingTest(Orientation orientation, SelectionMode selectionMode) throws InterruptedException, Throwable {
    setSize(130, 130);
    setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode);
    setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode);
    setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, selectionMode, Properties.selectionMode);

    setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, orientation, Properties.orientation);
    for (int i = 1; i < listItems; i++) {
        addElement(String.valueOf(Integer.valueOf((int) Math.round(Math.pow(i, i)))), i - 1);
    }

    selectionCycle(0, listItems - 1, null, selectionMode);

    localReset();

    selectionCycle(0, listItems - 1, KeyboardButtons.SHIFT, selectionMode);

    localReset();

    selectionCycle(0, listItems - 1, KeyboardButtons.CONTROL, selectionMode);
}
 
Example 24
Project: openjfx-8u-dev-tests   File: NewListViewTest.java   Source Code and License 6 votes vote down vote up
@Test(timeout = 300000)
/**
 * Add big amount of elements in a list and select some of the according to
 * some rule. After that checks, whether focus is correct.
 */
public void simpleSelectionScreenShotTest() throws InterruptedException, Throwable {
    setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 200);
    setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 200);
    setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode);
    setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation);

    final int elementsCount = 15;
    addAndSelectElements(elementsCount);

    final int step = 6;
    checkScreenshotsWithStep("SimpleTest", elementsCount, step);
}
 
Example 25
Project: ReqTraq   File: TreeTablePane.java   Source Code and License 6 votes vote down vote up
public TreeTablePane()
{
	tree = new TreeTableView<>();
	tree.setShowRoot(false);
	tree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	tree.setEditable(true);
	tree.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
	FX.style(tree, CssTools.NO_HORIZONTAL_SCROLL_BAR, TREE);
	
	handler = new TreeTableHandler<Page>(tree);
	
	setupActions();
	
	addColumn(Page.Field.TITLE, "Title");
	addColumn(Page.Field.TIME_CREATED, "Created");
	addColumn(Page.Field.STATUS, "Status");
	
	setCenter(tree);
}
 
Example 26
Project: JttDesktop   File: TestTableView.java   Source Code and License 6 votes vote down vote up
/**
 * Method to construct the table.
 * @param database the {@link JenkinsDatabase} providing the {@link TestClass}es.
 */
public void constructLayout( JenkinsDatabase database ) {
   root = new TreeItem<>();
   root.setExpanded( true );
   
   database.testClasses().forEach( test -> {
      createBranch( root, test );
   } );

   TreeTableView< TestTableItem > treeTableView = new TreeTableView<>( root );
   treeTableView.setEditable( false );
   treeTableView.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );

   createDescriptionColumn( treeTableView, DESCRIPTION_COLUMN_NAME, DESCRIPTION_COLUMN_INDEX, DESCRIPTION_COLUMN_WIDTH );
   createDescriptionColumn( treeTableView, STATUS_COLUMN_NAME, STATUS_COLUMN_INDEX, COMMON_COLUMN_WIDTH );
   createDescriptionColumn( treeTableView, SKIPPED_COLUMN_NAME, SKIPPED_COLUMN_INDEX, COMMON_COLUMN_WIDTH );
   createDescriptionColumn( treeTableView, AGE_COLUMN_NAME, AGE_COLUMN_INDEX, COMMON_COLUMN_WIDTH );
   createDescriptionColumn( treeTableView, DURATION_COLUMN_NAME, DURATION_COLUMN_INDEX, COMMON_COLUMN_WIDTH );
   
   treeTableView.setShowRoot( false );
   treeTableView.setTableMenuButtonVisible( true );
   setCenter( treeTableView );
}
 
Example 27
Project: JttDesktop   File: AssignmentDetailControllerTest.java   Source Code and License 6 votes vote down vote up
@Before public void initialiseSystemUnderTest(){
   TestApplication.startPlatform();
   MockitoAnnotations.initMocks( this );
   
   assignmentA = new UserAssignment( new JenkinsUserImpl( "A" ), 0, "", "" );
   assignmentB = new UserAssignment( new JenkinsUserImpl( "B" ), 0, "", "" );
   
   itemA = new AssignedTreeItem( assignmentA );
   itemB = new AssignedTreeItem( assignmentB );
   tree = new TreeTableView<>();
   tree.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );
   tree.setRoot( new TreeItem<>() );
   tree.getRoot().setExpanded( true );
   tree.getRoot().getChildren().add( new TreeItem<>( itemA ) );
   tree.getRoot().getChildren().add( new TreeItem<>( itemB ) );
   
   systemUnderTest = new AssignmentDetailController( tree, area );
}
 
Example 28
Project: certmgr   File: ExtendedKeyUsageController.java   Source Code and License 6 votes vote down vote up
/**
 * Initialize the dialog.
 *
 * @param expertMode Whether to run in expert mode ({@code true}) or not ({@code false}).
 * @return This controller.
 */
public ExtendedKeyUsageController init(boolean expertMode) {
	this.ctlCritical.setSelected(ExtendedKeyUsageExtensionData.CRITICAL_DEFAULT);

	ObservableList<ExtendedKeyUsage> usageItems = this.ctlUsages.getItems();

	for (ExtendedKeyUsage usage : ExtendedKeyUsage.instances()) {
		if (!ExtendedKeyUsage.ANY.equals(usage)) {
			usageItems.add(usage);
		}
	}
	usageItems.sort((o1, o2) -> o1.name().compareTo(o2.name()));
	this.ctlUsages.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	this.ctlAnyUsage.setSelected(false);
	return this;
}
 
Example 29
Project: certmgr   File: KeyUsageController.java   Source Code and License 6 votes vote down vote up
/**
 * Initialize the dialog.
 *
 * @param expertMode Whether to run in expert mode ({@code true}) or not ({@code false}).
 * @return This controller.
 */
public KeyUsageController init(boolean expertMode) {
	this.ctlCritical.setSelected(KeyUsageExtensionData.CRITICAL_DEFAULT);

	ObservableList<KeyUsage> usageItems = this.ctlUsages.getItems();

	for (KeyUsage usage : KeyUsage.instances()) {
		if (!KeyUsage.ANY.equals(usage)) {
			usageItems.add(usage);
		}
	}
	usageItems.sort((o1, o2) -> o1.name().compareTo(o2.name()));
	this.ctlUsages.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	this.ctlAnyUsage.setSelected(false);
	return this;
}
 
Example 30
Project: qupath   File: SingleFeatureClassifierCommand.java   Source Code and License 6 votes vote down vote up
InputPane(final ObservableList<PathClass> availableClasses) {
	// Input classes - classification will only be applied to objects of this class
	listInputClasses.setItems(availableClasses);
	listInputClasses.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	listInputClasses.setPrefHeight(200);
	pane = new TitledPane("Input", listInputClasses);
	pane.setCollapsible(false);
	
	listInputClasses.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
		// Not sure why, but this needs to be deferred to later...
		Platform.runLater(() -> selectedItemList.setAll(listInputClasses.getSelectionModel().getSelectedItems()));
	});
	
	Tooltip tooltip = new Tooltip("Select input classifications - only objects with these classes will be reclassified");
	pane.setTooltip(tooltip);
	listInputClasses.setTooltip(tooltip);
}
 
Example 31
Project: LuoYing   File: AssetsForm.java   Source Code and License 6 votes vote down vote up
public AssetsForm() {
        getChildren().add(assetTree);
        
        assetTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        assetTree.setOnMouseClicked((e) -> {
            if (e.getButton() == MouseButton.SECONDARY) {
                doShowPopup(e.getScreenX(), e.getScreenY());
                e.consume();
            } else if (e.getButton() == MouseButton.PRIMARY && e.getClickCount() == 2) {
                editMenu.fire();
                e.consume();
            }
        });
        
        assetTree.setOnDragDetected(this::doDragDetected);
        assetTree.setOnDragDone(this::doDragDone);
//        assetTree.setOnDragOver(this::doDragOver);
        assetTree.prefWidthProperty().bind(widthProperty());
        assetTree.prefHeightProperty().bind(heightProperty());

        updateAassetDir();
        Manager.getConfigManager().addListener(this);
        setPrefHeight(300);
    }
 
Example 32
Project: MatroskaBatch   File: RemoteFileChooserController.java   Source Code and License 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
	mainList.getSelectionModel().setSelectionMode(multiselect ? SelectionMode.MULTIPLE : SelectionMode.SINGLE);
	mainList.setCellFactory(new Callback<ListView<RESTPath>, ListCell<RESTPath>>() {
		@Override
		public ListCell<RESTPath> call(ListView<RESTPath> param) {
			return new RESTPathListCell();
		}
	});
	Platform.runLater(() -> {
		try {
			currentPath = remoteUtils.getRemoteRoot();
			loadDirectory(currentPath);
		} catch (IOException e) {
			throw new RuntimeException("couldn't get root", e);
		}
	});
}
 
Example 33
Project: sgf4j-gui   File: FileTreeView.java   Source Code and License 6 votes vote down vote up
public FileTreeView() {
  super();

  getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

  setCellFactory(new Callback<TreeView<File>, TreeCell<File>>() {
    @Override
    public TreeCell<File> call(TreeView<File> param) {
      return new FileFormatCell();
    }
  });

  final TreeItem<File> fakeRoot = new TreeItem<File>();
  setRoot(fakeRoot);
  setShowRoot(false);

  List<File> rootDevices = Sgf4jGuiUtil.getRootDevices();
  TreeItem<File>[] treeItems = new FileTreeItem[rootDevices.size()];
  for (int i = 0; i < rootDevices.size(); i++) {
    treeItems[i] = new FileTreeItem(rootDevices.get(i));
  }

  fakeRoot.getChildren().addAll(treeItems);

  openTreeAtRightLocation(fakeRoot);
}
 
Example 34
Project: WhoWhatWhere   File: WatchdogController.java   Source Code and License 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources)
{
	setColumnCellFactories();
	setGraphics();
	setButtonsDisableStates();

	table.setPlaceholder(new Label("No rules set"));
	table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	numFieldCooldown.setMinValue(WatchdogUI.minCooldownValue);
	numFieldCooldown.setMaxValue(WatchdogUI.maxCooldownValue);
	
	//show scrollbars only when needed. When not needed, allow to stretch GUI (AnchorPane behavior)
	scrollPane.fitToWidthProperty().bind(scrollPane.widthProperty().greaterThan(scrollPane.getPrefWidth()));
	scrollPane.fitToHeightProperty().bind(scrollPane.heightProperty().greaterThan(scrollPane.getPrefHeight()));
}
 
Example 35
Project: metastone   File: BattleOfDecksConfigView.java   Source Code and License 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 36
Project: metastone   File: TrainingConfigView.java   Source Code and License 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 37
Project: performance-test-harness-for-geoevent   File: ReportOptionsController.java   Source Code and License 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    reportTypeLabel.setText(UIMessages.getMessage("UI_REPORT_TYPE_LABEL"));
    reportType.setItems(getReportTypes());
    reportType.setValue(report.getType());
    reportFileLocationLabel.setText(UIMessages.getMessage("UI_REPORT_FILE_LOCATION_LABEL"));
    reportFileLocationBtn.setText(UIMessages.getMessage("UI_REPORT_FILE_BROWSE_LABEL"));
    reportFileLocationBtn.setTooltip(new Tooltip(UIMessages.getMessage("UI_REPORT_FILE_BROWSE_DESC")));
    allCoumnsLabel.setText(UIMessages.getMessage("UI_ALL_COLUMNS_LABEL"));
    selectedCoumnsLabel.setText(UIMessages.getMessage("UI_SELECTED_COLUMNS_LABEL"));
    allColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

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

    okBtn.setText(UIMessages.getMessage("UI_OK_BTN_LABEL"));
    cancelBtn.setText(UIMessages.getMessage("UI_CANCEL_BTN_LABEL"));

    // lookup current directory and add "/report" to it
    updateSelectedReportFile(report.getReportFile());
    updateSelectedReportColumns(report.getReportColumns());
}
 
Example 38
Project: StreamSis   File: MultiSourceFileListerController.java   Source Code and License 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
	browseSourceDirButton.disableProperty().bind(manualTitledPane.expandedProperty());
	srcPathTextField.disableProperty().bind(manualTitledPane.expandedProperty());
	fileTable.setPlaceholder(new Label("Let's add some files!"));
	fileTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	fileNameColumn.setCellValueFactory(
			p -> new ReadOnlyObjectWrapper<String>(p.getValue().getPath()));
	fileNameColumn.setCellFactory(view -> new FileNameCell());
	// indexOf operation might not be very fast. Also the code should ensure that the list with
	// items contains only unique values.
	numberColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper<String>(
			String.valueOf(p.getTableView().getItems().indexOf(p.getValue()) + 1)));
	manualPaneDotsAnima = new ThreeDotsAnimation(
			"Editing list of <filetype> files", '.',
			manualTitledPane.textProperty(), 1, 500, Timeline.INDEFINITE);
	setValidationForFileTableWithDelay.setCycleCount(1);
	fileTable.getSelectionModel().selectedItemProperty().addListener((o, oldVal, newVal) -> {
		sampleFile.set(newVal);
	});
	initializeListeners();
	// Set tooltips showing file paths.
	GUIUtil.createAndBindTooltipToTextfield(srcPathTextField);
}
 
Example 39
Project: subshare   File: UserPane.java   Source Code and License 6 votes vote down vote up
@FXML
private void assignPgpKeyToThisUserButtonClicked(final ActionEvent event) {
	final SelectPgpKeyDialog dialog = new SelectPgpKeyDialog(getScene().getWindow(),
			new ArrayList<>(getPgp().getMasterKeys()), null, SelectionMode.MULTIPLE,
			"Please select one or more PGP keys you want to 'pull' here.");
	dialog.showAndWait();
	final List<PgpKey> selectedPgpKeys = dialog.getSelectedPgpKeys();
	if (selectedPgpKeys == null || selectedPgpKeys.isEmpty())
		return;

	final Set<PgpKeyId> selectedPgpKeyIds = new HashSet<>(selectedPgpKeys.size());
	for (final PgpKey pgpKey : selectedPgpKeys)
		selectedPgpKeyIds.add(pgpKey.getPgpKeyId());

	for (User user : getUserRegistry().getUsersByPgpKeyIds(selectedPgpKeyIds))
		user.getPgpKeyIds().removeAll(selectedPgpKeyIds);

	user.getPgpKeyIds().addAll(selectedPgpKeyIds);
}
 
Example 40
Project: subshare   File: UserPane.java   Source Code and License 6 votes vote down vote up
@FXML
private void assignPgpKeyToOtherUserButtonClicked(final ActionEvent event) {
	final SelectUserDialog dialog = new SelectUserDialog(getScene().getWindow(),
			new ArrayList<>(getUserRegistry().getUsers()), null, SelectionMode.SINGLE,
			"Please select the user to whom you want to 'push' the selected PGP key(s).");
	dialog.showAndWait();
	final List<User> selectedUsers = dialog.getSelectedUsers();
	if (selectedUsers == null || selectedUsers.isEmpty())
		return;

	final User targetUser = selectedUsers.get(0);
	final Set<PgpKey> selectedPgpKeys = getSelectedPgpKeys();
	for (final PgpKey pgpKey : selectedPgpKeys) {
		user.getPgpKeyIds().remove(pgpKey.getPgpKeyId());
		targetUser.getPgpKeyIds().add(pgpKey.getPgpKeyId());
	}
}
 
Example 41
Project: subshare   File: ServerPane.java   Source Code and License 6 votes vote down vote up
public ServerPane(final Server server) {
		this.server = assertNotNull(server, "server");
		loadDynamicComponentFxml(ServerPane.class, this);
		tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
		tableView.getSelectionModel().getSelectedItems().addListener(selectionListener);
		for (final TableColumn<ServerRepoListItem, ?> tableColumn : tableView.getColumns()) {
			if ("nameColumn".equals(tableColumn.getId())) {
				final TableColumn<ServerRepoListItem, String> tc = cast(tableColumn);
				tc.setCellFactory(cast(TextFieldTableCell.forTableColumn()));
//				tc.setOnEditCommit(new EventHandler<CellEditEvent<ServerRepoListItem, String>>() { // not needed, anymore, because we use a StringProperty, now - only needed with plain getters+setters.
//					@Override
//					public void handle(CellEditEvent<ServerRepoListItem, String> event) {
//						event.getRowValue().setName(event.getNewValue());
//						getServerRepoRegistry().writeIfNeeded();
//					}
//				});
			}
		}
		populateTableViewAsync();
		updateEnabled();
	}
 
Example 42
Project: subshare   File: SelectUserWizardPage.java   Source Code and License 6 votes vote down vote up
@Override
protected Parent createContent() {
	List<User> users = new ArrayList<>(UserRegistryLs.getUserRegistry().getUsers());
	contentVBox = new VBox(8);
	statusLabel = new Label();
	selectUserPane = new SelectUserPane(
			users, issueInvitationData.getInvitees(), SelectionMode.MULTIPLE,
			Messages.getString("SelectUserWizardPage.selectUserPane.headerText")) { //$NON-NLS-1$
		@Override
		protected void updateComplete() {
			determineComplete();
			if (SelectUserWizardPage.this.isComplete())
				determineNextPage();
		}
	};
	contentVBox.getChildren().add(0, selectUserPane);
	return contentVBox;
}
 
Example 43
Project: subshare   File: PgpKeyTreePane.java   Source Code and License 6 votes vote down vote up
public PgpKeyTreePane() {
	loadDynamicComponentFxml(PgpKeyTreePane.class, this);

	treeTableView.setShowRoot(false);
	treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	nameTreeTableColumn.setCellFactory(new Callback<TreeTableColumn<PgpKeyTreeItem<?>,String>, TreeTableCell<PgpKeyTreeItem<?>,String>>() {
		@Override
		public TreeTableCell<PgpKeyTreeItem<?>, String> call(TreeTableColumn<PgpKeyTreeItem<?>, String> param) {
			return new NameCell();
		}
	});

	checkedTreeItems.addListener(new SetChangeListener<PgpKeyTreeItem<?>>() {
		@Override
		public void onChanged(SetChangeListener.Change<? extends PgpKeyTreeItem<?>> change) {
			final PgpKeyTreeItem<?> elementAdded = change.getElementAdded();
			if (elementAdded != null)
				elementAdded.setChecked(true);

			final PgpKeyTreeItem<?> elementRemoved = change.getElementRemoved();
			if (elementRemoved != null)
				elementRemoved.setChecked(false);
		}
	});
}
 
Example 44
Project: subshare   File: FileTreePane.java   Source Code and License 6 votes vote down vote up
public FileTreePane() {
	loadDynamicComponentFxml(FileTreePane.class, this);
	rootFileTreeItem = new RootFileTreeItem(this);

	// The root here is *not* the real root of the file system and should be hidden, because
	// (1) we might want to have 'virtual' visible roots like "Home", "Desktop", "Drives" and
	// (2) even if we displayed only the real file system without any shortcuts like "Desktop",
	// we'd still have multiple roots on a crappy pseudo-OS like Windows still having these shitty drive letters.
	treeTableView.setShowRoot(false);
	treeTableView.setRoot(rootFileTreeItem);
	treeTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
	treeTableView.getSelectionModel().selectedItemProperty().addListener((ChangeListener<TreeItem<FileTreeItem<?>>>) (observable, o, n) -> updateSelectedFiles());
	treeTableView.getSelectionModel().getSelectedItems().addListener((InvalidationListener) observable -> updateSelectedFiles());

	selectedFiles.addListener(selectedFilesChangeListener);
	showHiddenFilesCheckBox.selectedProperty().bindBidirectional(showHiddenFilesProperty);

	// TODO remove the following line - preferably replace by proper, use-case-dependent management!
	selectedFiles.add(IOUtil.getUserHome());
	updateDisable();
}
 
Example 45
Project: efiscen   File: SelectionTreeController.java   Source Code and License 6 votes vote down vote up
/**
 * Parameterized constructor.
 * @param selections Selections object containing the selected elements 
 * @param names ROSSnames element containing Region, owner, site and species names storage
 * @param selectionTree How the data is shown in the selection tree for the user 
 */
public SelectionTreeController(Selections selections,ROSSNames names,TreeView selectionTree) {
    this.selections = selections;
    this.names = names;
    this.selectionTree = selectionTree;
    TreeItem<TreeData> root = new TreeItem<>(new TreeData("Selections",-1l));
    root.setExpanded(true);
    selectionTree.setRoot(root);
    selectionTree.setShowRoot(false);
    selectionTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    regions = new TreeItem<>(new TreeData("Regions",0l));
    owners = new TreeItem<>(new TreeData("Owners",0l));
    sites = new TreeItem<>(new TreeData("Sites",0l));
    species = new TreeItem<>(new TreeData("Species",0l));
    root.getChildren().addAll(regions,owners,sites,species);
    selectionTree.getSelectionModel().getSelectedItems().addListener(this);
}
 
Example 46
Project: fancy-chart   File: TabTableController.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void initTable(final ObservableList<DataItem> items) {

	final TableColumn<DataItem, Number> xCol = new TableColumn<>("X");
	xCol.setCellValueFactory(new PropertyValueFactory<DataItem, Number>("x"));
	xCol.setMinWidth(TABLE_COL_MIN_WIDTH);
	final TableColumn<DataItem, Number> yCol = new TableColumn<>("Y");
	yCol.setCellValueFactory(new PropertyValueFactory<DataItem, Number>("y"));
	yCol.setMinWidth(TABLE_COL_MIN_WIDTH);

	tableView.setItems(items);
	tableView.getColumns().setAll(xCol, yCol);

	tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	tableView.setMinWidth(TABLE_MIN_WIDTH);
	tableView.setEditable(true);

	addSelectionListener();
	addCellFactory(xCol, yCol);
}
 
Example 47
Project: ISAAC   File: SearchResultsTable.java   Source Code and License 6 votes vote down vote up
private void setupTableAttributes() {
// Enable selection of multiple rows.  Context menu handlers are coded to send collections.
results.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

// Backup existing data in order to restore after reinitializing
resultsBackup = new ArrayList<>(results.getItems());

// Clear underlying data structure
results.getItems().clear();

// Enable optional menu to make visible columns invisible and currently invisible columns visible
results.setTableMenuButtonVisible(true);

// Disable editing of table data
results.setEditable(false);
}
 
Example 48
Project: ISAAC   File: LegoListTreeView.java   Source Code and License 6 votes vote down vote up
public LegoListTreeView()
{
	getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
	setCellFactory(new Callback<TreeView<String>, TreeCell<String>>()
	{
		@Override
		public TreeCell<String> call(TreeView<String> arg0)
		{
			return new LegoListTreeCell<String>(LegoListTreeView.this);
		}
	});
	// Not going to use the edit API, not reliable. Just detect doubleclick instead.
	setEditable(false);
	LegoListTreeItem treeRoot = new LegoListTreeItem();
	setShowRoot(false);
	setRoot(treeRoot);
}
 
Example 49
Project: JFTClient   File: JFTClient.java   Source Code and License 6 votes vote down vote up
private TreeView<Node> createLocalTree() {

        TreeItem<Node> root = localTree.createRootNode();
        root.setExpanded(true);
        TreeView<Node> treeView = createTree(root);
        treeView.setEditable(true);
        treeView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

        treeView.setCellFactory(param -> {
            cellLocal = new NodeTreeCell(primaryStage, connection, localTree, commonTree);
            commonTree.setDragDropEvent(cellLocal, localTree);
            return cellLocal;
        });

        treeView.setOnKeyPressed(event -> {
            if (event.getCode() == KeyCode.DELETE) {
                commonTree.deleteSelectedItems(treeView, localTree);
            } else if (event.getCode() == KeyCode.F5) {
                commonTree.refresh(treeView, localTree);
            } else if (event.getCode() == KeyCode.ENTER) {
                commonTree.expand(treeView);
            }
        });

        return treeView;
    }
 
Example 50
Project: jabref   File: ErrorConsoleController.java   Source Code and License 6 votes vote down vote up
@FXML
private void initialize() {
    viewModel = new ErrorConsoleViewModel(dialogService, clipBoardManager, buildInfo);

    messagesListView.setCellFactory(createCellFactory());
    messagesListView.itemsProperty().bind(viewModel.allMessagesDataProperty());
    messagesListView.scrollTo(viewModel.allMessagesDataProperty().getSize() - 1);
    messagesListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    viewModel.allMessagesDataProperty().addListener((ListChangeListener<LogEventViewModel>) (change -> {
        int size = viewModel.allMessagesDataProperty().size();
        if (size > 0) {
            messagesListView.scrollTo(size - 1);
        }
    }));
    descriptionLabel.setGraphic(IconTheme.JabRefIcon.CONSOLE.getGraphicNode());
}
 
Example 51
Project: jabref   File: KeyBindingsDialogController.java   Source Code and License 6 votes vote down vote up
@FXML
private void initialize() {
    viewModel = new KeyBindingsDialogViewModel(keyBindingRepository, dialogService, preferences);

    keyBindingsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    viewModel.selectedKeyBindingProperty().bind(
            EasyBind.monadic(keyBindingsTable.selectionModelProperty())
                    .flatMap(SelectionModel::selectedItemProperty)
                    .selectProperty(TreeItem::valueProperty)
    );
    keyBindingsTable.setOnKeyPressed(evt -> viewModel.setNewBindingForCurrent(evt));
    keyBindingsTable.rootProperty().bind(
            EasyBind.map(viewModel.rootKeyBindingProperty(),
                    keybinding -> new RecursiveTreeItem<>(keybinding, KeyBindingViewModel::getChildren))
    );
    actionColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().nameProperty());
    shortcutColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().shownBindingProperty());
    resetColumn.setCellFactory(new ViewModelTreeTableCellFactory<KeyBindingViewModel, String>()
            .withGraphic(keyBinding -> keyBinding.getIcon().map(IconTheme.JabRefIcon::getGraphicNode).orElse(null))
            .withOnMouseClickedEvent(keyBinding -> evt -> keyBinding.resetToDefault())
    );
}
 
Example 52
Project: kotlinfx-ensemble   File: ListViewCellFactorySample.java   Source Code and License 6 votes vote down vote up
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));
    
    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        
    
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
 
Example 53
Project: vars   File: StringValuePanel.java   Source Code and License 6 votes vote down vote up
private ListView<String> getListView() {
    if (listView == null) {
        listView = new ListView<>();
        listView.getSelectionModel()
                .setSelectionMode(SelectionMode.MULTIPLE);
        listView.getSelectionModel()
                .getSelectedItems()
                .addListener((ListChangeListener.Change<? extends String> c) -> {
                    if (listView.getSelectionModel().getSelectedItems().size() > 0) {
                        getConstrainCheckBox().setSelected(true);
                    }
                });
        listView.itemsProperty().addListener((obs, oldVal, newVal) -> {
            int visibleRows = 6;
            if (newVal.size() > 20) {
                visibleRows = 10;
            }
            else if (newVal.size() == 0) {
                visibleRows = 3;
            }
            listView.prefHeightProperty().set(getTextField().getHeight() * visibleRows);
        });
        HBox.setHgrow(listView, Priority.ALWAYS);
    }
    return listView;
}
 
Example 54
Project: jvarkit   File: FilesChooserPane.java   Source Code and License 6 votes vote down vote up
public FilesChooserPane()	{
final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FilesChooserPane.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
    fxmlLoader.load();
} catch (IOException exception) {
    throw new RuntimeException(exception);
	}
this.files.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
this.eraseButton.setDisable(true);
      this.files.getSelectionModel().selectedItemProperty().addListener( new ChangeListener<File>() {
              @Override
              public void changed(ObservableValue<? extends File> observable, File oldValue, File newValue) {
              eraseButton.setDisable(files.getSelectionModel().isEmpty());
              }
      	});
      eraseButton.setOnAction(new EventHandler<ActionEvent>() {
	@Override
	public void handle(ActionEvent event) {
		doClear(event);
	}
});
      }
 
Example 55
Project: marathonv5   File: SimpleListViewSample.java   Source Code and License 5 votes vote down vote up
public SimpleListViewSample() {
    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);
    getChildren().add(listView);
}
 
Example 56
Project: marathonv5   File: ResourceView.java   Source Code and License 5 votes vote down vote up
public ResourceView(IResourceActionSource source, Resource root, IResourceActionHandler handler,
        IResourceChangeListener listener) {
    this.source = source;
    this.handler = handler;
    setEditable(true);
    setRoot(root);
    getRoot().addEventHandler(ResourceModificationEvent.ANY, (event) -> {
        if (event.getEventType() == ResourceModificationEvent.DELETE) {
            listener.deleted(source, event.getResource());
        }
        if (event.getEventType() == ResourceModificationEvent.UPDATE) {
            listener.updated(source, event.getResource());
        }
        if (event.getEventType() == ResourceModificationEvent.MOVED) {
            listener.moved(source, event.getFrom(), event.getTo());
        }
        if (event.getEventType() == ResourceModificationEvent.COPIED) {
            listener.copied(source, event.getFrom(), event.getTo());
        }
    });
    setContextMenu(contextMenu);
    setContextMenuItems();
    getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getSelectionModel().getSelectedItems().addListener(new ListChangeListener<TreeItem<Resource>>() {
        @Override public void onChanged(Change<? extends TreeItem<Resource>> c) {
            setContextMenuItems();
        }
    });
    Callback<TreeView<Resource>, TreeCell<Resource>> value = new Callback<TreeView<Resource>, TreeCell<Resource>>() {
        @Override public TreeCell<Resource> call(TreeView<Resource> param) {
            return new TextFieldTreeCellImpl();
        }
    };
    setCellFactory(value);
}
 
Example 57
Project: marathonv5   File: ListLayout.java   Source Code and License 5 votes vote down vote up
private VBox createListView() {
    listViewBox = new VBox(5);
    classPathListView = new ListView<ClassPathElement>(classPathListItems);
    classPathListView.setPrefHeight(Node.BASELINE_OFFSET_SAME_AS_HEIGHT);
    classPathListView.setId("ClassPathList");
    classPathListView.setCellFactory((e) -> {
        ClassPathCell classPathCell = new ClassPathCell();
        classPathCell.setId("ClassPathCell");
        return classPathCell;
    });

    if (!isSingleSelection()) {
        classPathListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    }
    classPathListView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        MultipleSelectionModel<ClassPathElement> selectionModel = classPathListView.getSelectionModel();
        int itemCount = classPathListItems.size();
        int selectedIndex = selectionModel.getSelectedIndex();
        setButtonState(deleteButton, selectedIndex != -1);
        boolean enable = selectedIndex != 0 && selectedIndex != -1 && itemCount > 1;
        setButtonState(upButton, enable);
        enable = selectedIndex != itemCount - 1 && selectedIndex != -1 && itemCount > 1;
        setButtonState(downButton, enable);
    });
    listViewBox.getChildren().add(classPathListView);
    HBox.setHgrow(listViewBox, Priority.ALWAYS);
    VBox.setVgrow(classPathListView, Priority.ALWAYS);
    return listViewBox;
}
 
Example 58
Project: marathonv5   File: JavaFXTreeTableViewElementTest.java   Source Code and License 5 votes vote down vote up
@Test public void selectAllRows() {
    TreeTableView<?> treeTableNode = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
    Platform.runLater(() -> {
        treeTableNode.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        treeTable.marathon_select("all");
    });
    new Wait("Waiting for all rows to be selected.") {
        @Override public boolean until() {
            return treeTableNode.getSelectionModel().getSelectedIndices().size() == treeTableNode.getExpandedItemCount();
        }
    };
}
 
Example 59
Project: marathonv5   File: JavaFXTreeTableViewElementTest.java   Source Code and License 5 votes vote down vote up
@Test public void selectMultipleRows() {
    TreeTableView<?> treeTableNode = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
    Platform.runLater(() -> {
        treeTableNode.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        treeTable.marathon_select("{\"rows\":[\"/Sales Department/Emma Jones\",\"/Sales Department/Anna Black\"]}");
    });
    new Wait("Waiting for rows to be selected.") {
        @Override public boolean until() {
            return treeTableNode.getSelectionModel().getSelectedIndices().size() > 1;
        }
    };
}
 
Example 60
Project: marathonv5   File: JavaFXTreeTableViewElementTest.java   Source Code and License 5 votes vote down vote up
@Test public void selectMultipleCells() {
    TreeTableView<?> treeTableNode = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
    Platform.runLater(() -> {
        TreeTableViewSelectionModel<?> selectionModel = treeTableNode.getSelectionModel();
        selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
        selectionModel.setCellSelectionEnabled(true);
        treeTable.marathon_select(
                "{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"],[\"/Sales Department/Michael Brown\",\"Email\"]]}");
    });
    new Wait("Waiting for cells to be selected") {
        @Override public boolean until() {
            return treeTableNode.getSelectionModel().getSelectedCells().size() == 2;
        }
    };
}