javafx.scene.control.cell.CheckBoxTableCell Java Examples

The following examples show how to use javafx.scene.control.cell.CheckBoxTableCell. 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: AxesTab.java    From phoebus with Eclipse Public License 1.0 8 votes vote down vote up
private TableColumn<AxisConfig, Boolean> createCheckboxColumn(final String label,
        final Function<AxisConfig, Boolean> getter,
        final BiConsumer<AxisConfig, Boolean> setter)
{
    final TableColumn<AxisConfig, Boolean> check_col = new TableColumn<>(label);
    check_col.setCellValueFactory(cell ->
    {
        final AxisConfig axis = cell.getValue();
        final BooleanProperty prop = new SimpleBooleanProperty(getter.apply(axis));
        prop.addListener((p, old, value) ->
        {
            final ChangeAxisConfigCommand command = new ChangeAxisConfigCommand(undo, axis);
            updating = true;
            setter.accept(axis, value);
            updating = false;
            command.rememberNewConfig();
        });
        return prop;
    });
    check_col.setCellFactory(CheckBoxTableCell.forTableColumn(check_col));
    return check_col;
}
 
Example #2
Source File: ReverseColumn.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public TableColumn<SelectionTableRowData, Boolean> getTableColumn() {
    TableColumn<SelectionTableRowData, Boolean> tableColumn = new TableColumn<>(getColumnTitle());
    tableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(tableColumn));
    tableColumn.setCellValueFactory(
            new Callback<CellDataFeatures<SelectionTableRowData, Boolean>, ObservableValue<Boolean>>() {
                @Override
                public ObservableValue<Boolean> call(CellDataFeatures<SelectionTableRowData, Boolean> param) {
                    if (param.getValue() != null) {
                        return param.getValue().reverse;
                    }
                    return null;
                }
            });
    return tableColumn;
}
 
Example #3
Source File: RFXCheckBoxTableCell.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String _getValue() {
    CheckBoxTableCell cell = (CheckBoxTableCell) node;
    Callback selectedStateCallback = cell.getSelectedStateCallback();
    String cbText;
    if (selectedStateCallback != null) {
        ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem());
        int selection = call.getValue() ? 2 : 0;
        cbText = JavaFXCheckBoxElement.states[selection];
    } else {
        Node cb = cell.getGraphic();
        RFXComponent comp = getFinder().findRawRComponent(cb, null, null);
        cbText = comp._getValue();
    }
    return cbText;
}
 
Example #4
Source File: JavaFXCheckBoxTableCellElement.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String _getValue() {
    CheckBoxTableCell cell = (CheckBoxTableCell) node;
    Callback selectedStateCallback = cell.getSelectedStateCallback();
    String cbText;
    if (selectedStateCallback != null) {
        ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem());
        int selection = call.getValue() ? 2 : 0;
        cbText = JavaFXCheckBoxElement.states[selection];
    } else {
        Node cb = cell.getGraphic();
        JavaFXElement comp = (JavaFXElement) JavaFXElementFactory.createElement(cb, driver, window);
        cbText = comp._getValue();

    }
    String cellText = cell.getText();
    if (cellText == null) {
        cellText = "";
    }
    String text = cellText + ":" + cbText;
    return text;
}
 
Example #5
Source File: JavaFXElementFactory.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static void reset() {
    add(Node.class, JavaFXElement.class);
    add(TextInputControl.class, JavaFXTextInputControlElement.class);
    add(HTMLEditor.class, JavaFXHTMLEditor.class);
    add(CheckBox.class, JavaFXCheckBoxElement.class);
    add(ToggleButton.class, JavaFXToggleButtonElement.class);
    add(Slider.class, JavaFXSliderElement.class);
    add(Spinner.class, JavaFXSpinnerElement.class);
    add(SplitPane.class, JavaFXSplitPaneElement.class);
    add(ProgressBar.class, JavaFXProgressBarElement.class);
    add(ChoiceBox.class, JavaFXChoiceBoxElement.class);
    add(ColorPicker.class, JavaFXColorPickerElement.class);
    add(ComboBox.class, JavaFXComboBoxElement.class);
    add(DatePicker.class, JavaFXDatePickerElement.class);
    add(TabPane.class, JavaFXTabPaneElement.class);
    add(ListView.class, JavaFXListViewElement.class);
    add(TreeView.class, JavaFXTreeViewElement.class);
    add(TableView.class, JavaFXTableViewElement.class);
    add(TreeTableView.class, JavaFXTreeTableViewElement.class);
    add(CheckBoxListCell.class, JavaFXCheckBoxListCellElement.class);
    add(ChoiceBoxListCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxListCell.class, JavaFXComboBoxCellElement.class);
    add(CheckBoxTreeCell.class, JavaFXCheckBoxTreeCellElement.class);
    add(ChoiceBoxTreeCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxTreeCell.class, JavaFXComboBoxCellElement.class);
    add(TableCell.class, JavaFXTableViewCellElement.class);
    add(CheckBoxTableCell.class, JavaFXCheckBoxTableCellElement.class);
    add(ChoiceBoxTableCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxTableCell.class, JavaFXComboBoxCellElement.class);
    add(TreeTableCell.class, JavaFXTreeTableCellElement.class);
    add(CheckBoxTreeTableCell.class, JavaFXCheckBoxTreeTableCell.class);
    add(ChoiceBoxTreeTableCell.class, JavaFXChoiceBoxCellElement.class);
    add(ComboBoxTreeTableCell.class, JavaFXComboBoxCellElement.class);
    add(WebView.class, JavaFXWebViewElement.class);
    add(GenericStyledArea.GENERIC_STYLED_AREA_CLASS, RichTextFXGenericStyledAreaElement.class);
}
 
Example #6
Source File: SnapshotTable.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
SelectionTableColumn() {
    super("", "Include this PV when restoring values", 30, 30, false);
    setCellValueFactory(new PropertyValueFactory<>("selected"));
    //for those entries, which have a read-only property, disable the checkbox
    setCellFactory(column -> {
        TableCell<TableEntry, Boolean> cell = new CheckBoxTableCell<>(null,null);
        cell.itemProperty().addListener((a, o, n) -> {
            cell.getStyleClass().remove("check-box-table-cell-disabled");
            TableRow<?> row = cell.getTableRow();
            if (row != null) {
                TableEntry item = (TableEntry) row.getItem();
                if (item != null) {
                    cell.setEditable(!item.readOnlyProperty().get());
                    if (item.readOnlyProperty().get()) {
                        cell.getStyleClass().add("check-box-table-cell-disabled");
                    }
                }
            }
        });
        return cell;
    });
    setEditable(true);
    setSortable(false);
    selectAllCheckBox = new CheckBox();
    selectAllCheckBox.setSelected(false);
    selectAllCheckBox.setOnAction(e -> getItems().stream().filter(te -> !te.readOnlyProperty().get())
            .forEach(te -> te.selectedProperty().setValue(selectAllCheckBox.isSelected())));
    setGraphic(selectAllCheckBox);
    MenuItem inverseMI = new MenuItem("Inverse Selection");
    inverseMI.setOnAction(e -> getItems().stream().filter(te -> !te.readOnlyProperty().get())
            .forEach(te -> te.selectedProperty().setValue(!te.selectedProperty().get())));
    final ContextMenu contextMenu = new ContextMenu(inverseMI);
    selectAllCheckBox.setOnMouseReleased(e -> {
        if (e.getButton() == MouseButton.SECONDARY) {
            contextMenu.show(selectAllCheckBox, e.getScreenX(), e.getScreenY());
        }
    });
}
 
Example #7
Source File: ImportedPacketTableView.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize table rows and columns
 */
private void initTableRowsColumns() {

    selectedColumn.setCellValueFactory(new PropertyValueFactory<>("selected"));
    selectedColumn.setCellFactory(CheckBoxTableCell.forTableColumn(selectedColumn));
    selectAll = new CheckBox();
    selectAll.getStyleClass().add("selectAll");
    selectAll.setSelected(true);
    selectAll.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
        selectAllRows();
    });
    selectedColumn.setGraphic(selectAll);

    nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
    nameColumn.setCellFactory(new TextFieldTableViewCell());

    packetNumColumn.setCellValueFactory(new PropertyValueFactory<>("index"));
    lengthColumn.setCellValueFactory(new PropertyValueFactory<>("length"));
    macSrcColumn.setCellValueFactory(new PropertyValueFactory<>("macSrc"));
    macDstColumn.setCellValueFactory(new PropertyValueFactory<>("macDst"));
    ipSrcColumn.setCellValueFactory(new PropertyValueFactory<>("ipSrc"));
    ipDstColumn.setCellValueFactory(new PropertyValueFactory<>("ipDst"));
    packetTypeColumn.setCellValueFactory(new PropertyValueFactory<>("packetType"));

    importedStreamTable.setRowFactory(highlightedRowFactory);

}
 
Example #8
Source File: MainController.java    From neural-style-gui with GNU General Public License v3.0 5 votes vote down vote up
private void setupContentLayersTable() {
    log.log(Level.FINER, "Setting content layer table list.");
    contentLayersTable.setItems(contentLayers);
    contentLayersTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    log.log(Level.FINER, "Setting content layer table selection listener.");
    EventStreams.changesOf(contentLayers).subscribe(change -> {
        log.log(Level.FINE, "contentLayers changed");

        List<NeuralBoolean> selectedContentLayers = contentLayers.stream()
                .filter(NeuralBoolean::getValue)
                .collect(Collectors.toList());

        String[] newContentLayers = new String[selectedContentLayers.size()];
        for (int i = 0; i < selectedContentLayers.size(); i++)
            newContentLayers[i] = selectedContentLayers.get(i).getName();
        neuralStyle.setContentLayers(newContentLayers);

        toggleStyleButtons();
    });

    log.log(Level.FINER, "Setting style layer table shortcut listener");
    EventStreams.eventsOf(contentLayersTable, KeyEvent.KEY_RELEASED).filter(spaceBar::match).subscribe(keyEvent -> {
        ObservableList<NeuralBoolean> selectedStyleLayers =
                contentLayersTable.getSelectionModel().getSelectedItems();
        for (NeuralBoolean neuralLayer : selectedStyleLayers)
            neuralLayer.setValue(!neuralLayer.getValue());
    });

    log.log(Level.FINER, "Setting content layer table column factories.");
    contentLayersTableSelected.setCellValueFactory(new PropertyValueFactory<>("value"));
    contentLayersTableSelected.setCellFactory(CheckBoxTableCell.forTableColumn(contentLayersTableSelected));

    contentLayersTableName.setCellValueFactory(new PropertyValueFactory<>("name"));
    contentLayersTableName.setCellFactory(TextFieldTableCell.forTableColumn());
}
 
Example #9
Source File: MsSpectrumLayersDialogController.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void initialize() {

    final ObservableList<MsSpectrumType> renderingChoices =
        FXCollections.observableArrayList(MsSpectrumType.CENTROIDED, MsSpectrumType.PROFILE);
    renderingTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(renderingChoices));

    colorColumn.setCellFactory(column -> new ColorTableCell<MsSpectrumDataSet>(column));

    lineThicknessColumn
        .setCellFactory(column -> new SpinnerTableCell<MsSpectrumDataSet>(column, 1, 5));

    intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn(
        new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat())));

    showDataPointsColumn
        .setCellFactory(column -> new CheckBoxTableCell<MsSpectrumDataSet, Boolean>() {
          {
            tableRowProperty().addListener(e -> {
              TableRow<?> row = getTableRow();
              if (row == null)
                return;
              MsSpectrumDataSet dataSet = (MsSpectrumDataSet) row.getItem();
              if (dataSet == null)
                return;
              disableProperty()
                  .bind(dataSet.renderingTypeProperty().isEqualTo(MsSpectrumType.CENTROIDED));

            });
          }
        });
  }
 
Example #10
Source File: ConnectionView.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
private TableColumn<KnownNode, Boolean> newNodeRunningColumn(String colText, String colPropertyName, double colWidth) {
    TableColumn<KnownNode, Boolean> column;
    column = new TableColumn<>(colText);
    column.setCellValueFactory( node -> { return node.getValue().runningProperty(); });
    column.setCellFactory( tc -> new CheckBoxTableCell<>());
    column.setPrefWidth(colWidth);
    return column;
}
 
Example #11
Source File: WatchlistController.java    From Noexes with GNU General Public License v3.0 4 votes vote down vote up
@FXML
public void initialize() {
    updateCol.setCellValueFactory(param -> param.getValue().updateProperty());
    lockedCol.setCellValueFactory(param -> param.getValue().lockedProperty());
    typeCol.setCellValueFactory(param -> param.getValue().typeProperty());
    addrCol.setCellValueFactory(param -> param.getValue().addrProperty());
    descCol.setCellValueFactory(param -> param.getValue().descProperty());
    valueCol.setCellValueFactory(param -> param.getValue().valueProperty());

    updateCol.setCellFactory(param -> new CheckBoxTableCell<>());
    lockedCol.setCellFactory(param -> new CheckBoxTableCell<>());
    typeCol.setCellFactory(param -> new ComboBoxTableCell<>(DataType.values()) {
        {
            setItem(DataType.INT);
        }
    });
    addrCol.setCellFactory(TextFieldTableCell.forTableColumn());
    descCol.setCellFactory(TextFieldTableCell.forTableColumn());
    valueCol.setCellFactory(param -> new SpinnerTableCell<>(valueCol, new HexSpinner() {
                {
                    setEditable(true);
                    setSize(16);
                }
            }) {
                @Override
                protected void updateItem(Long item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item == null || empty) {
                        return;
                    }
                    WatchlistModel model = getTableRow().getItem();
                    if (model == null) {
                        return;
                    }
                    getSpinner().setSize(model.getSize() * 2);
                }
            }
    );

    watchlistTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> removeButton.setDisable(newValue == null));
}
 
Example #12
Source File: ColorsManageController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
@Override
protected void initColumns() {
    try {
        dataColumn.setPrefWidth(400);
        tableView.getColumns().remove(dataColumn);

        colorValueColumn.setCellValueFactory(new PropertyValueFactory<>("colorValue"));

        colorNameColumn.setCellValueFactory(new PropertyValueFactory<>("colorName"));
        colorNameColumn.setCellFactory(TableAutoCommitCell.forTableColumn());
        colorNameColumn.setOnEditCommit((TableColumn.CellEditEvent<ColorData, String> t) -> {
            if (t == null) {
                return;
            }
            ColorData row = t.getRowValue();
            row.setColorName(t.getNewValue());
            TableColorData.setName(row.getRgba(), t.getNewValue());
        });
        colorNameColumn.getStyleClass().add("editable-column");

        colorColumn.setCellValueFactory(new PropertyValueFactory<>("color"));
        colorColumn.setCellFactory(new TableColorCell<>());

        inPaletteColumn.setCellValueFactory(new PropertyValueFactory<>("inPalette"));
        inPaletteColumn.setCellFactory((TableColumn<ColorData, Boolean> p) -> {
            CheckBoxTableCell<ColorData, Boolean> cell = new CheckBoxTableCell<>();
            cell.setSelectedStateCallback((Integer index) -> tableData.get(index).getInPaletteProperty());
            return cell;
        });
        inPaletteColumn.getStyleClass().add("editable-column");

        rgbaColumn.setCellValueFactory(new PropertyValueFactory<>("rgba"));
        rgbColumn.setCellValueFactory(new PropertyValueFactory<>("rgb"));
        sRGBColumn.setCellValueFactory(new PropertyValueFactory<>("srgb"));
        HSBColumn.setCellValueFactory(new PropertyValueFactory<>("hsb"));
        AdobeRGBColumn.setCellValueFactory(new PropertyValueFactory<>("adobeRGB"));
        AppleRGBColumn.setCellValueFactory(new PropertyValueFactory<>("appleRGB"));
        ECIRGBColumn.setCellValueFactory(new PropertyValueFactory<>("eciRGB"));
        sRGBLinearColumn.setCellValueFactory(new PropertyValueFactory<>("SRGBLinear"));
        AdobeRGBLinearColumn.setCellValueFactory(new PropertyValueFactory<>("adobeRGBLinear"));
        AppleRGBLinearColumn.setCellValueFactory(new PropertyValueFactory<>("appleRGBLinear"));
        CalculatedCMYKColumn.setCellValueFactory(new PropertyValueFactory<>("calculatedCMYK"));
        ECICMYKColumn.setCellValueFactory(new PropertyValueFactory<>("eciCMYK"));
        AdobeCMYKColumn.setCellValueFactory(new PropertyValueFactory<>("adobeCMYK"));
        XYZColumn.setCellValueFactory(new PropertyValueFactory<>("xyz"));
        CIELabColumn.setCellValueFactory(new PropertyValueFactory<>("cieLab"));
        LCHabColumn.setCellValueFactory(new PropertyValueFactory<>("lchab"));
        CIELuvColumn.setCellValueFactory(new PropertyValueFactory<>("cieLuv"));
        LCHuvColumn.setCellValueFactory(new PropertyValueFactory<>("lchuv"));

    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example #13
Source File: RightListViewInit.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
/**
 * 展开字段
 */
public void expandTableViewColumns(VBox selectedVBox) {
    HBox hBox = new HBox();
    hBox.setAlignment(Pos.CENTER);

    String tableName = ((Label) (((HBox) selectedVBox.getChildren().get(0))).getChildren().get(0)).getText();
    TableView<Column> columnTableView = new TableView<>(FXCollections.observableArrayList(BaseConstants.selectedTableNameTableMap.get(tableName).getColumns()));
    columnTableView.setEditable(true);
    columnTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    ReadOnlyDoubleProperty widthBind = hBox.widthProperty();

    TableColumn<Column, String> tcColumnNam = new TableColumn<>("字段名");
    tcColumnNam.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnName()));
    tcColumnNam.setSortable(false);
    tcColumnNam.prefWidthProperty().bind(widthBind.multiply(0.16));
    tcColumnNam.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> tcType = new TableColumn<>("类型");
    tcType.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getType()));
    tcType.setSortable(false);
    tcType.prefWidthProperty().bind(widthBind.multiply(0.16));
    tcType.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> property = new TableColumn<>("property");
    property.setCellFactory(TextFieldTableCell.forTableColumn());
    property.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnOverride().getProperty()));
    property.setOnEditCommit(event -> {
        event.getRowValue().getColumnOverride().setProperty(event.getNewValue());
        BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
    });
    property.setSortable(false);
    property.prefWidthProperty().bind(widthBind.multiply(0.16));
    property.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> javaType = new TableColumn<>("java type");
    javaType.setCellFactory(TextFieldTableCell.forTableColumn());
    javaType.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnOverride().getJavaType()));
    javaType.setOnEditCommit(event -> {
        event.getRowValue().getColumnOverride().setJavaType(event.getNewValue());
        BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
    });
    javaType.setSortable(false);
    javaType.prefWidthProperty().bind(widthBind.multiply(0.2));
    javaType.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> typeHandler = new TableColumn<>("type handler");
    typeHandler.setCellFactory(TextFieldTableCell.forTableColumn());
    typeHandler.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnOverride().getTypeHandler()));
    typeHandler.setOnEditCommit(event -> {
        event.getRowValue().getColumnOverride().setTypeHandler(event.getNewValue());
        BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
    });
    typeHandler.setSortable(false);
    typeHandler.prefWidthProperty().bind(widthBind.multiply(0.22));
    typeHandler.getStyleClass().setAll("myColumn");

    TableColumn<Column, Boolean> ignoreCheckBox = new TableColumn<>("是否忽略");
    ignoreCheckBox.setCellFactory(CheckBoxTableCell.forTableColumn(param -> {
        final Column column = columnTableView.getItems().get(param);
        column.ignoreProperty().addListener((observable, oldValue, newValue) -> {
            column.setIgnore(newValue);
            BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
        });
        return column.ignoreProperty();
    }));
    ignoreCheckBox.setSortable(false);
    ignoreCheckBox.prefWidthProperty().bind(widthBind.multiply(0.1));
    ignoreCheckBox.getStyleClass().setAll("myColumn");

    columnTableView.getColumns().add(tcColumnNam);
    columnTableView.getColumns().add(tcType);
    columnTableView.getColumns().add(ignoreCheckBox);
    columnTableView.getColumns().add(property);
    columnTableView.getColumns().add(javaType);
    columnTableView.getColumns().add(typeHandler);

    columnTableView.setFixedCellSize(30);
    columnTableView.prefHeightProperty().bind(columnTableView.fixedCellSizeProperty().multiply(Bindings.size(columnTableView.getItems()).add(1.3)));
    columnTableView.prefWidthProperty().bind(hBox.widthProperty());

    hBox.getChildren().add(columnTableView);
    selectedVBox.getChildren().add(hBox);
}
 
Example #14
Source File: OptionsController.java    From CPUSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Initializes the Highlighting tab.
 */
private void initializeHighlightingTab() {

    // Disable tab if there is nothing to show.
    if (registers.size() < 1 || RAMs.size() < 1) {
        highlightingTab.setDisable(true);
        return;
    }

    // Making column widths adjust properly
    highlightingTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    // updates selectedSet, disables/enables buttons
    highlightingTable.getSelectionModel().selectedItemProperty().addListener(
            new ChangeListener<RegisterRAMPair>() {
                @Override
                public void changed(ObservableValue<? extends RegisterRAMPair> selected,
                                    RegisterRAMPair oldSet, RegisterRAMPair newSet) {
                    highlightingSelectedSet = newSet;
                    updateHighlightingClickables();
                }
            });

    // Accounts for width changes.
    highlightingTable.widthProperty().addListener(
            new ChangeListener<Number>() {
                @Override
                public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
                    Double newWidth = (Double) newValue;
                    Double sum = registerColumn.getWidth()
                            + RAMColumn.getWidth()
                            + dynamicColumn.getWidth();
                    Double perc = sum / oldValue.doubleValue() * .94;

                    registerColumn.setPrefWidth(newWidth * perc *
                            registerColumn.getWidth() / sum);
                    RAMColumn.setPrefWidth(newWidth * perc *
                            RAMColumn.getWidth() / sum);
                    dynamicColumn.setPrefWidth(newWidth * perc *
                            dynamicColumn.getWidth() / sum);
                }
            });

    // Callbacks
    Callback<TableColumn<RegisterRAMPair, Register>, TableCell<RegisterRAMPair, Register>>
            cellComboRegisterFactory =
            new Callback<TableColumn<RegisterRAMPair, Register>, TableCell<RegisterRAMPair, Register>>() {
                @Override
                public TableCell<RegisterRAMPair, Register> call(
                        TableColumn<RegisterRAMPair, Register> setStringTableColumn) {
                    return new ComboBoxTableCell<>(registers);
                }
            };

    Callback<TableColumn<RegisterRAMPair, RAM>, TableCell<RegisterRAMPair, RAM>>
            cellComboRAMFactory = setStringTableColumn -> new ComboBoxTableCell<>(RAMs);

    Callback<TableColumn<RegisterRAMPair, Boolean>, TableCell<RegisterRAMPair, Boolean>>
            cellCheckBoxFactory = setStringTableColumn -> {
                CheckBoxTableCell<RegisterRAMPair, Boolean> cbtc =
                        new CheckBoxTableCell<>();
                cbtc.setAlignment(Pos.CENTER);
                return cbtc;
            };

    // SetCellValueFactories
    registerColumn.setCellValueFactory(new PropertyValueFactory<>("register"));
    RAMColumn.setCellValueFactory(new PropertyValueFactory<>("ram"));
    dynamicColumn.setCellValueFactory(new PropertyValueFactory<>("dynamic"));

    // Register Factories and setOnEditCommits
    registerColumn.setCellFactory(cellComboRegisterFactory);
    registerColumn.setOnEditCommit(text -> text.getRowValue().setRegister(
            text.getNewValue()));

    RAMColumn.setCellFactory(cellComboRAMFactory);
    RAMColumn.setOnEditCommit(text -> text.getRowValue().setRam(
            text.getNewValue()));

    dynamicColumn.setCellFactory(cellCheckBoxFactory);
    dynamicColumn.setOnEditCommit(text -> text.getRowValue().setDynamic(
            text.getNewValue()));

    // Load in Rows
    ObservableList<RegisterRAMPair> data = highlightingTable.getItems();
    ObservableList<RegisterRAMPair> regRamPairs = mediator.getRegisterRAMPairs();
    for (RegisterRAMPair rrp : regRamPairs) {
        data.add(rrp.clone());
    }
    highlightingTable.setItems(data);
}
 
Example #15
Source File: EditFieldsController.java    From CPUSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Initializes the controller class.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);
    name.prefWidthProperty().bind(table.widthProperty().subtract(2).multiply(.15));
    type.prefWidthProperty().bind(table.widthProperty().subtract(2).multiply(.16));
    numBits.prefWidthProperty().bind(table.widthProperty().subtract(2).multiply(.17));
    defaultValue.prefWidthProperty().bind(table.widthProperty().subtract(2).multiply(.20));
    relativity.prefWidthProperty().bind(table.widthProperty().subtract(2).multiply(.18));
    signed.prefWidthProperty().bind(table.widthProperty().subtract(2).multiply(.14));

    selectedField = null;
    deleteButton.setDisable(true);
    duplicateButton.setDisable(true);
    valuesButton.setDisable(true);

    final ObservableList<Field.Relativity> relBoxOptions = FXCollections.observableArrayList();
    
    relBoxOptions.addAll(Field.Relativity.absolute, Field.Relativity.pcRelativePreIncr,
            Field.Relativity.pcRelativePostIncr);
    
    final ObservableList<Field.Type> typeBoxOptions = FXCollections.observableArrayList();
    
    typeBoxOptions.addAll(Field.Type.required, Field.Type.optional, Field.Type.ignored);
    
    Callback<TableColumn<Field, String>, TableCell<Field, String>> cellStrFactory =
            setStringTableColumn -> new cpusim.gui.util.EditingStrCell<>();
    Callback<TableColumn<Field,Integer>, TableCell<Field,Integer>> cellIntFactory =
            setIntegerTableColumn -> new EditingNonNegativeIntCell<>();
    Callback<TableColumn<Field,Long>, TableCell<Field,Long>> cellLongFactory =
            setLongTableColumn -> new EditingLongCell<>();
    Callback<TableColumn<Field,Field.Relativity>,
            TableCell<Field,Field.Relativity>> cellRelFactory =
            setStringTableColumn -> new ComboBoxTableCell<>(relBoxOptions);
    Callback<TableColumn<Field,Boolean>,TableCell<Field, Boolean>> cellBoolFactory =
            booleanTableColumn -> new CheckBoxTableCell<>();
    Callback<TableColumn<Field,Field.Type>,
            TableCell<Field, Field.Type>> cellTypeFactory =
            setStringTableColumn -> new ComboBoxTableCell<>(typeBoxOptions);

    name.setCellValueFactory(new PropertyValueFactory<>("name"));
    type.setCellValueFactory(new PropertyValueFactory<>("type"));
    numBits.setCellValueFactory(new PropertyValueFactory<>("numBits"));
    defaultValue.setCellValueFactory(new PropertyValueFactory<>("defaultValue"));
    relativity.setCellValueFactory(new PropertyValueFactory<>("relativity"));
    signed.setCellValueFactory(new PropertyValueFactory<>("signed"));
    
    //Add for Editable Cell of each field, in String or in Integer
    name.setCellFactory(cellStrFactory);
    name.setOnEditCommit(
            text -> {
                String newName = text.getNewValue();
                String oldName = text.getOldValue();
                ( text.getRowValue()).setName(newName);
                try{
                    Validate.namedObjectsAreUniqueAndNonempty(table.getItems().toArray());
                } catch (ValidationException ex) {
                    (text.getRowValue()).setName(oldName);
                }
                updateTable();
            }
    );

    type.setCellFactory(cellTypeFactory);
    type.setOnEditCommit(text -> text.getRowValue().setType(text.getNewValue()));

    numBits.setCellFactory(cellIntFactory);
    numBits.setOnEditCommit(text -> text.getRowValue().setNumBits(text.getNewValue
            ()));

    defaultValue.setCellFactory(cellLongFactory);
    defaultValue.setOnEditCommit(text ->
            text.getRowValue().setDefaultValue(text.getNewValue()));

    relativity.setCellFactory(cellRelFactory);
    relativity.setOnEditCommit(text -> text.getRowValue().setRelativity(text.getNewValue()));

    signed.setCellFactory(cellBoolFactory);
    signed.setOnEditCommit(text -> text.getRowValue().setSigned(text.getNewValue()));

    table.getSelectionModel().selectedItemProperty().addListener((ov, t, t1) -> {
        deleteButton.setDisable(false);
        duplicateButton.setDisable(false);
        valuesButton.setDisable(false);
        selectedField = t1;
    });
            
    table.setItems(allFields);
}
 
Example #16
Source File: ObjectTableView.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
public ObjectTableView() {
    super(null);
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/ObjectTableView.fxml"), bundle);
    loader.setRoot(this);
    loader.setController(this);

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

    getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

    showAllCheckBox.setAllowIndeterminate(true);

    visibleColumn.setCellFactory(CheckBoxTableCell.forTableColumn(visibleColumn));
    visibleColumn.setCellValueFactory(cell -> cell.getValue().visibleProperty());

    thumbColumn.setCellFactory(param -> new ImageViewTableCell<>());
    thumbColumn.setCellValueFactory(cell -> cell.getValue().thumbProperty());

    List<String> names = IteratorUtils.toList(Settings.recentNamesProperty.stream().map(NameColor::getName).iterator());
    nameColumn.setCellFactory(ComboBoxTableCell.forTableColumn(FXCollections.observableList(names)));
    nameColumn.setCellValueFactory(cell -> cell.getValue().nameProperty());

    itemsProperty().addListener((observable, oldValue, newValue) -> {
        ObservableList<ObservableValue<Boolean>> visibles = EasyBind.map(newValue, ObjectTag::visibleProperty);
        visibleCount = EasyBind.combine(visibles, stream -> stream.filter(b -> b).count());
        visibleCount.addListener((obs, oldCount, newCount) -> {
            if (newCount == 0) {
                showAllCheckBox.setIndeterminate(false);
                showAllCheckBox.setSelected(false);
            }
            else if (newCount < getItems().size()) {
                showAllCheckBox.setIndeterminate(true);
            }
            else {
                showAllCheckBox.setIndeterminate(false);
                showAllCheckBox.setSelected(true);
            }
        });
    });
}
 
Example #17
Source File: ChromatogramLayersDialogController.java    From old-mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
public void initialize() {

    colorColumn.setCellFactory(column -> new ColorTableCell<ChromatogramPlotDataSet>(column));

    lineThicknessColumn
        .setCellFactory(column -> new SpinnerTableCell<ChromatogramPlotDataSet>(column, 1, 5));

    intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn(
        new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat())));

    showDataPointsColumn
        .setCellFactory(column -> new CheckBoxTableCell<ChromatogramPlotDataSet, Boolean>());

  }