Java Code Examples for javafx.scene.control.TableColumn#setCellFactory()
The following examples show how to use
javafx.scene.control.TableColumn#setCellFactory() .
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 |
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: PVList.java From phoebus with Eclipse Public License 1.0 | 7 votes |
private void createTableColumns() { final TableColumn<PVInfo, Boolean> conn_col = new TableColumn<>(Messages.PVListTblConnected); conn_col.setCellFactory(col -> new ConnectedCell()); conn_col.setCellValueFactory(cell -> cell.getValue().connected); conn_col.setMinWidth(20.0); conn_col.setPrefWidth(300.0); conn_col.setMaxWidth(500.0); table.getColumns().add(conn_col); final TableColumn<PVInfo, String> name_col = new TableColumn<>(Messages.PVListTblPVName); name_col.setCellValueFactory(cell -> cell.getValue().name); table.getColumns().add(name_col); final TableColumn<PVInfo, Number> ref_col = new TableColumn<>(Messages.PVListTblReferences); ref_col.setCellValueFactory(cell -> cell.getValue().references); ref_col.setMaxWidth(500.0); table.getColumns().add(ref_col); }
Example 3
Source File: JFXTable.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public void setColumns(int count) { if( count >= 0 ) { List<TableColumn<UITableItem<T>, ?>> columns = this.getControl().getColumns(); while(columns.size() < count) { TableColumn<UITableItem<T>, JFXTableCellValue<T>> tableColumn = new TableColumn<UITableItem<T>, JFXTableCellValue<T>>(); tableColumn.setCellFactory(this.cellFactory); tableColumn.setCellValueFactory(this.cellValueFactory); columns.add(tableColumn); } while(columns.size() > count) { columns.remove(columns.size() - 1); } } }
Example 4
Source File: WidgetInfoDialog.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private Tab createMacros(final Macros orig_macros) { final Macros macros = (orig_macros == null) ? new Macros() : orig_macros; // Use text field to allow copying the name and value // Table uses list of macro names as input // Name column just displays the macro name,.. final TableColumn<String, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name); name.setCellFactory(col -> new ReadOnlyTextCell<>()); name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue())); // .. value column fetches the macro value final TableColumn<String, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value); value.setCellFactory(col -> new ReadOnlyTextCell<>()); value.setCellValueFactory(param -> new ReadOnlyStringWrapper(macros.getValue(param.getValue()))); final TableView<String> table = new TableView<>(FXCollections.observableArrayList(macros.getNames())); table.getColumns().add(name); table.getColumns().add(value); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); return new Tab(Messages.WidgetInfoDialog_TabMacros, table); }
Example 5
Source File: ReverseColumn.java From pdfsam with GNU Affero General Public License v3.0 | 6 votes |
@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 6
Source File: StringTable.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @param index Column index, -1 to add to end * @param header Header text */ private void createTableColumn(final int index, final String header) { final TableColumn<List<ObservableCellValue>, CellValue> table_column = new TableColumn<>(header); table_column.setCellValueFactory(VALUE_FACTORY); // Prevent column re-ordering // (handled via moveColumn which also re-orders the data) table_column.setReorderable(false); // By default, use text field editor. setColumnOptions() can replace table_column.setCellFactory(list -> new StringTextCell()); table_column.setOnEditStart(event -> editing = true); table_column.setOnEditCommit(event -> { editing = false; final int col = event.getTablePosition().getColumn(); List<ObservableCellValue> row = event.getRowValue(); if (row == MAGIC_LAST_ROW) { // Entered in last row? Create new row row = createEmptyRow(); final List<List<ObservableCellValue>> data = table.getItems(); data.add(data.size()-1, row); } row.get(col).setValue(event.getNewValue()); fireDataChanged(); // Automatically edit the next row, same column editCell(event.getTablePosition().getRow() + 1, table_column); }); table_column.setOnEditCancel(event -> editing = false); table_column.setSortable(false); if (index >= 0) table.getColumns().add(index, table_column); else table.getColumns().add(table_column); }
Example 7
Source File: ConnectionView.java From erlyberly with GNU General Public License v3.0 | 5 votes |
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 8
Source File: EventDetectionUI.java From SONDY with GNU General Public License v3.0 | 5 votes |
public final void initializeEventTable(){ eventTable = new TableView<>(); eventTable.setItems(eventList.observableList); UIUtils.setSize(eventTable, Main.columnWidthRIGHT, 247); TableColumn textualDescription = new TableColumn("Textual desc."); textualDescription.setMinWidth(Main.columnWidthRIGHT/2); TableColumn temporalDescription = new TableColumn("Temporal desc."); temporalDescription.setMinWidth(Main.columnWidthRIGHT/2-1); textualDescription.setCellValueFactory(new PropertyValueFactory<>("textualDescription")); temporalDescription.setCellValueFactory(new PropertyValueFactory<>("temporalDescription")); EventTableContextMenu tableCellFactory = new EventTableContextMenu(createSelectedEventHandler(), new ContextMenu()); textualDescription.setCellFactory(tableCellFactory); eventTable.getColumns().addAll(textualDescription,temporalDescription); }
Example 9
Source File: FilterGridController.java From VocabHunter with Apache License 2.0 | 5 votes |
private TableColumn<GridLine, GridCell> buildColumn(final FilterGridModel filterModel, final int index) { TableColumn<GridLine, GridCell> column = new TableColumn<>(columnNameTool.columnName(index)); column.setSortable(false); column.setCellValueFactory(features -> extractValue(features, index)); column.setCellFactory(c -> new FilterGridWordTableCell(filterModel.getColumnSelections().get(index))); if (isScrollableColumnList(filterModel)) { column.setPrefWidth(PREFERRED_COLUMN_WIDTH); } return column; }
Example 10
Source File: LoadingColumn.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Override public TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> getTableColumn() { TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> tableColumn = new TableColumn<>(getColumnTitle()); tableColumn.setCellFactory(cellFactory()); tableColumn.setCellValueFactory(cellValueFactory()); tableColumn.setComparator(null); tableColumn.setSortable(false); tableColumn.setMaxWidth(26); tableColumn.setMinWidth(26); return tableColumn; }
Example 11
Source File: CChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public TableColumn<ObjectTableRow, CChoiceFieldValue> getTableColumn( PageActionManager pageactionmanager, boolean largedisplay, int rowheight, String actionkeyforupdate) { TableColumn< ObjectTableRow, CChoiceFieldValue> thiscolumn = new TableColumn<ObjectTableRow, CChoiceFieldValue>(this.getLabel()); if ((actionkeyforupdate != null) && (this.isEditable())) { thiscolumn.setEditable(true); thiscolumn.setOnEditCommit(new TableColumnOnEditCommit(this)); } else { thiscolumn.setEditable(false); } int length = this.maxcharlength * 7; if (length > 300) length = 300; if (this.prefereddisplaysizeintable >= 0) { length = this.prefereddisplaysizeintable * 7; } double pixellength = ((new Text(this.label)).getBoundsInLocal().getWidth() + 10) * 1.05; for (int i = 0; i < this.values.size(); i++) { double valuelength = ((new Text(values.get(i).getDisplayvalue()).getBoundsInLocal().getWidth()) + 10) * 1.05; if (valuelength > pixellength) pixellength = valuelength; } int pixellengthi = (int) pixellength; thiscolumn.setMinWidth(pixellengthi); thiscolumn.setPrefWidth(pixellengthi); logger.fine(" --**-- length for field" + this.getLabel() + " maxcharlength:" + maxcharlength + " pref display in table " + this.prefereddisplaysizeintable + " final length = " + length + " - pixel length" + pixellengthi); thiscolumn.setCellValueFactory(new TableCellValueFactory(this)); thiscolumn.setCellFactory(new TableCellFactory(helper, values)); return thiscolumn; }
Example 12
Source File: TagEditorPane.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public TagEditorPane(Map<String, String> tags) { tagTable.setEditable(true); tagTable.setPrefHeight(200); tagTable.setPrefWidth(200); final TableColumn<Tag, String> nameCol = new TableColumn<>("Name"); nameCol.setCellValueFactory(new PropertyValueFactory<Tag, String>("name")); nameCol.setCellFactory(TextFieldTableCell.<Tag> forTableColumn()); nameCol.setOnEditCommit((t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setName(t.getNewValue()); }); final TableColumn<Tag, String> valueCol = new TableColumn<>("Value"); valueCol.setCellFactory(TextFieldTableCell.<Tag> forTableColumn()); valueCol.setCellValueFactory(new PropertyValueFactory<Tag, String>("value")); valueCol.setOnEditCommit((t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setValue(t.getNewValue()); }); tagTable.getColumns().addAll(nameCol, valueCol); final ObservableList<Tag> data = FXCollections.observableArrayList(); for (final Entry<String, String> entry : tags.entrySet()) data.add(new Tag(entry.getKey(), entry.getValue())); tagTable.setItems(data); tagTable.setOnMouseClicked((event) -> { if (event.getClickCount() == 2) { data.add(new Tag("", "")); } }); getChildren().add(tagTable); }
Example 13
Source File: StringTableDemo.java From phoebus with Eclipse Public License 1.0 | 4 votes |
@Override public void start(Stage stage) throws Exception { TableColumn<List<StringProperty>, String> tc = new TableColumn<>("A"); tc.setCellValueFactory(param -> param.getValue().get(0)); tc.setCellFactory(TextFieldTableCell.forTableColumn()); tc.setOnEditCommit(event -> { final int col = event.getTablePosition().getColumn(); event.getRowValue().get(col).set(event.getNewValue()); }); tc.setEditable(true); table.getColumns().add(tc); tc = new TableColumn<>("B"); tc.setCellValueFactory(param -> param.getValue().get(1)); tc.setCellFactory(TextFieldTableCell.forTableColumn()); tc.setEditable(true); table.getColumns().add(tc); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); table.setEditable(true); final Scene scene = new Scene(table, 800, 600); stage.setScene(scene); stage.show(); List<StringProperty> row = new ArrayList<>(); row.add(new SimpleStringProperty("One")); row.add(new SimpleStringProperty("Another")); data.add(row); row = new ArrayList<>(); row.add(new SimpleStringProperty("Two")); row.add(new SimpleStringProperty("Something")); data.add(row); final Thread change_cell = new Thread(() -> { while (true) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } Platform.runLater(() -> updateCell(1, 0, LocalDateTime.now().toString().replace('T', ' '))); } }); change_cell.setDaemon(true); change_cell.start(); }
Example 14
Source File: PVTable.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void createTableColumns() { // Selected column final TableColumn<TableItemProxy, Boolean> sel_col = new TableColumn<>(Messages.Selected); sel_col.setCellValueFactory(cell -> cell.getValue().selected); sel_col.setCellFactory(column -> new BooleanTableCell()); table.getColumns().add(sel_col); // PV Name TableColumn<TableItemProxy, String> col = new TableColumn<>(Messages.PV); col.setPrefWidth(250); col.setCellValueFactory(cell_data_features -> cell_data_features.getValue().name); col.setCellFactory(column -> new PVNameTableCell()); col.setOnEditCommit(event -> { final String new_name = event.getNewValue().trim(); final TableItemProxy proxy = event.getRowValue(); if (proxy == TableItemProxy.NEW_ITEM) { if (!new_name.isEmpty()) model.addItem(new_name); // else: No name entered, do nothing } else { // Set name, even if empty, assuming user wants to continue // editing the existing row. // To remove row, use context menu. proxy.getItem().updateName(new_name); proxy.update(proxy.getItem()); // Content of model changed. // Triggers full table update. model.fireModelChange(); } }); // Use natural order for PV name col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); // Description if (Settings.show_description) { col = new TableColumn<>(Messages.Description); col.setCellValueFactory(cell -> cell.getValue().desc_value); table.getColumns().add(col); } // Time Stamp col = new TableColumn<>(Messages.Time); col.setCellValueFactory(cell -> cell.getValue().time); table.getColumns().add(col); // Editable value col = new TableColumn<>(Messages.Value); col.setCellValueFactory(cell -> cell.getValue().value); col.setCellFactory(column -> new ValueTableCell(model)); col.setOnEditCommit(event -> { event.getRowValue().getItem().setValue(event.getNewValue()); // Since updates were suppressed, refresh table model.performPendingUpdates(); }); col.setOnEditCancel(event -> { // Since updates were suppressed, refresh table model.performPendingUpdates(); }); // Use natural order for value col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); // Alarm col = new TableColumn<>(Messages.Alarm); col.setCellValueFactory(cell -> cell.getValue().alarm); col.setCellFactory(column -> new AlarmTableCell()); table.getColumns().add(col); // Saved value col = new TableColumn<>(Messages.Saved); col.setCellValueFactory(cell -> cell.getValue().saved); // Use natural order for saved value col.setComparator(CompareNatural.INSTANCE); saved_value_col = col; table.getColumns().add(col); // Saved value's timestamp col = new TableColumn<>(Messages.Saved_Value_TimeStamp); col.setCellValueFactory(cell -> cell.getValue().time_saved); saved_time_col = col; table.getColumns().add(col); // Completion checkbox final TableColumn<TableItemProxy, Boolean> compl_col = new TableColumn<>(Messages.Completion); compl_col.setCellValueFactory(cell -> cell.getValue().use_completion); compl_col.setCellFactory(column -> new BooleanTableCell()); completion_col = compl_col; table.getColumns().add(compl_col); }
Example 15
Source File: DataTable.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void updateTable(final ScanDataIterator iterator) { // A previous data set could have been for "Time, ypos" // while the new one is for "Time, xpos, ypos". // So not only is a new column added, the data that used to be in the // second column moved to the 3rd one. // --> If the column count changes, re-populate all rows. final ObservableList<TableColumn<DataRow, ?>> columns = table.getColumns(); if (columns.size() != iterator.getDevices().size() + 1) rows.clear(); // 'Time' column is already present // Create or update columns for devices int i = 1; for (String device : iterator.getDevices()) { if (columns.size() <= i) { final TableColumn<DataRow, String> col = new TableColumn<>(device); final int col_index = i; col.setCellFactory(c -> new DataCell(col_index)); col.setCellValueFactory(cell -> { final DataRow row = cell.getValue(); if (col_index < row.size()) { return row.getDataValue(col_index); } return EMPTY; }); columns.add(col); } else columns.get(i).setText(device); ++i; } // Data rows i = -1; while (iterator.hasNext()) { ++i; // Keep existing rows if (i < rows.size()) continue; rows.add(new DataRow(iterator.getTimestamp(), iterator.getSamples())); } }
Example 16
Source File: WidgetInfoDialog.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private Tab createPVs(final Collection<NameStateValue> pvs) { // Use text field to allow users to copy the name, value to clipboard final TableColumn<NameStateValue, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name); name.setCellFactory(col -> new ReadOnlyTextCell<>()); name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().name)); final TableColumn<NameStateValue, String> state = new TableColumn<>(Messages.WidgetInfoDialog_State); state.setCellFactory(col -> new ReadOnlyTextCell<>()); state.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().state)); final TableColumn<NameStateValue, String> path = new TableColumn<>(Messages.WidgetInfoDialog_Path); path.setCellFactory(col -> new ReadOnlyTextCell<>()); path.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().path)); final TableColumn<NameStateValue, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value); value.setCellFactory(col -> new AlarmColoredCell()); value.setCellValueFactory(param -> { String text; final VType vtype = param.getValue().value; if (vtype == null) text = Messages.WidgetInfoDialog_Disconnected; else { // Formatting arrays can be very slow, // so only show the basic type info if (vtype instanceof VNumberArray) text = vtype.toString(); else text = VTypeUtil.getValueString(vtype, true); final Alarm alarm = Alarm.alarmOf(vtype); if (alarm != null && alarm.getSeverity() != AlarmSeverity.NONE) text = text + " [" + alarm.getSeverity().toString() + ", " + alarm.getName() + "]"; } return new ReadOnlyStringWrapper(text); }); final ObservableList<NameStateValue> pv_data = FXCollections.observableArrayList(pvs); pv_data.sort((a, b) -> a.name.compareTo(b.name)); final TableView<NameStateValue> table = new TableView<>(pv_data); table.getColumns().add(name); table.getColumns().add(state); table.getColumns().add(value); table.getColumns().add(path); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); return new Tab(Messages.WidgetInfoDialog_TabPVs, table); }
Example 17
Source File: ImagePanel.java From marathonv5 with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) private void createRightPane() { annotationTable.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<Annotation>() { @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends Annotation> c) { drawGraphics(); markSelected(); } }); annotationTable.setEditable(edit); annotationTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); annotationTable.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> { if (event.getCode() == KeyCode.DELETE || event.getCode() == KeyCode.BACK_SPACE) { removeAnnotation(); } }); TableColumn<Annotation, String> messageColumn = new TableColumn<Annotation, String>("Annotation"); PropertyValueFactory<Annotation, String> value = new PropertyValueFactory<>("text"); messageColumn.setCellValueFactory(value); messageColumn.setCellFactory(new Callback<TableColumn<Annotation, String>, TableCell<Annotation, String>>() { @Override public TableCell<Annotation, String> call(TableColumn<Annotation, String> param) { return new TextAreaTableCell(); } }); messageColumn.prefWidthProperty().bind(annotationTable.widthProperty().subtract(25)); TableColumn<Annotation, String> numCol = new TableColumn<>("#"); numCol.setCellFactory(new Callback<TableColumn<Annotation, String>, TableCell<Annotation, String>>() { @Override public TableCell<Annotation, String> call(TableColumn<Annotation, String> p) { return new TableCell() { @Override protected void updateItem(Object item, boolean empty) { super.updateItem(item, empty); setGraphic(null); setText(empty ? null : getIndex() + 1 + ""); } }; } }); numCol.setPrefWidth(25); annotationTable.setItems(annotations); annotationTable.getColumns().addAll(numCol, messageColumn); }
Example 18
Source File: AlarmTableUI.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private TableView<AlarmInfoRow> createTable(final ObservableList<AlarmInfoRow> rows, final boolean active) { final SortedList<AlarmInfoRow> sorted = new SortedList<>(rows); final TableView<AlarmInfoRow> table = new TableView<>(sorted); // Ensure that the sorted rows are always updated as the column sorting // of the TableView is changed by the user clicking on table headers. sorted.comparatorProperty().bind(table.comparatorProperty()); TableColumn<AlarmInfoRow, SeverityLevel> sevcol = new TableColumn<>(/* Icon */); sevcol.setPrefWidth(25); sevcol.setReorderable(false); sevcol.setResizable(false); sevcol.setCellValueFactory(cell -> cell.getValue().severity); sevcol.setCellFactory(c -> new SeverityIconCell()); table.getColumns().add(sevcol); final TableColumn<AlarmInfoRow, String> pv_col = new TableColumn<>("PV"); pv_col.setPrefWidth(240); pv_col.setReorderable(false); pv_col.setCellValueFactory(cell -> cell.getValue().pv); pv_col.setCellFactory(c -> new DragPVCell()); pv_col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(pv_col); TableColumn<AlarmInfoRow, String> col = new TableColumn<>("Description"); col.setPrefWidth(400); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().description); col.setCellFactory(c -> new DragPVCell()); col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); sevcol = new TableColumn<>("Alarm Severity"); sevcol.setPrefWidth(130); sevcol.setReorderable(false); sevcol.setCellValueFactory(cell -> cell.getValue().severity); sevcol.setCellFactory(c -> new SeverityLevelCell()); table.getColumns().add(sevcol); col = new TableColumn<>("Alarm Status"); col.setPrefWidth(130); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().status); col.setCellFactory(c -> new DragPVCell()); table.getColumns().add(col); TableColumn<AlarmInfoRow, Instant> timecol = new TableColumn<>("Alarm Time"); timecol.setPrefWidth(200); timecol.setReorderable(false); timecol.setCellValueFactory(cell -> cell.getValue().time); timecol.setCellFactory(c -> new TimeCell()); table.getColumns().add(timecol); col = new TableColumn<>("Alarm Value"); col.setPrefWidth(100); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().value); col.setCellFactory(c -> new DragPVCell()); table.getColumns().add(col); sevcol = new TableColumn<>("PV Severity"); sevcol.setPrefWidth(130); sevcol.setReorderable(false); sevcol.setCellValueFactory(cell -> cell.getValue().pv_severity); sevcol.setCellFactory(c -> new SeverityLevelCell()); table.getColumns().add(sevcol); col = new TableColumn<>("PV Status"); col.setPrefWidth(130); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().pv_status); col.setCellFactory(c -> new DragPVCell()); table.getColumns().add(col); // Initially, sort on PV name // - restore(Memento) might change that table.getSortOrder().setAll(List.of(pv_col)); pv_col.setSortType(SortType.ASCENDING); table.setPlaceholder(new Label(active ? "No active alarms" : "No acknowledged alarms")); table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); createContextMenu(table, active); // Double-click to acknowledge or un-acknowledge table.setRowFactory(tv -> { final TableRow<AlarmInfoRow> row = new TableRow<>(); row.setOnMouseClicked(event -> { if (event.getClickCount() == 2 && !row.isEmpty()) JobManager.schedule("ack", monitor -> client.acknowledge(row.getItem().item, active)); }); return row; }); return table; }
Example 19
Source File: SQLColumnSettingsComponent.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public SQLColumnSettingsComponent() { columnsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); value = new SQLColumnSettings(); TableColumn<SQLRowObject,String> columnName=new TableColumn<SQLRowObject,String> (value.getColumnName(0)); TableColumn<SQLRowObject,SQLExportDataType> columnType=new TableColumn<SQLRowObject,SQLExportDataType> (value.getColumnName(1)); TableColumn<SQLRowObject,String> columnValue= new TableColumn<SQLRowObject,String> (value.getColumnName(2)); columnName.setCellValueFactory(new PropertyValueFactory<>("Name")); //this is needed during connection to a database columnType.setCellValueFactory(new PropertyValueFactory<>("Type")); columnValue.setCellValueFactory(new PropertyValueFactory<>("Value")); columnsTable.getColumns().addAll(columnName,columnType,columnValue); //added all the columns in the table setValue(value); columnsTable.setStyle("-fx-selection-bar: #3399FF; -fx-selection-bar-non-focused: #E3E3E3;"); //CSS color change on selection of row columnsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); columnName.setSortable(false); columnValue.setSortable(false); columnType.setSortable(false); columnName.setReorderable(false); columnValue.setReorderable(false); columnType.setReorderable(false); columnsTable.setPrefSize(550, 220); columnsTable.setFixedCellSize(columnsTable.getFixedCellSize()+20); columnsTable.setStyle("-fx-font: 10 \"Plain\""); //Setting action event on cells columnsTable.getSelectionModel().setCellSelectionEnabled(true); //individual cell selection enabled columnsTable.setEditable(true); //Editors on each cell columnName.setCellFactory(TextFieldTableCell.<SQLRowObject>forTableColumn()); columnName.setOnEditCommit(event -> { getValue().setValueAt(event.getNewValue(), event.getTablePosition().getRow(), 0); setValue(getValue()); //refresh the table }); columnValue.setCellFactory(TextFieldTableCell.<SQLRowObject>forTableColumn()); columnValue.setOnEditCommit(event -> { getValue().setValueAt(event.getNewValue().toUpperCase(), event.getTablePosition().getRow(), 2); setValue(getValue()); //refresh the table }); ArrayList<SQLExportDataType> exportDataTypeValues=new ArrayList<SQLExportDataType>(Arrays.asList(SQLExportDataType.values())); columnType.setCellFactory(ComboBoxTableCell.forTableColumn(FXCollections.observableArrayList(SQLExportDataType.values()))); columnType.setOnEditCommit(event -> { boolean selected = event.getNewValue().isSelectableValue(); if(!selected){ //case of invalid(Title) datatype selection getValue().setValueAt(exportDataTypeValues.get(exportDataTypeValues.indexOf(event.getNewValue())+1),event.getTablePosition().getRow(),1); } else { getValue().setValueAt(event.getNewValue(), event.getTablePosition().getRow(), 1); } setValue(getValue()); }); // Add buttons VBox buttonsPanel=new VBox(20); addColumnButton=new Button("Add"); removeColumnButton=new Button("Remove"); addColumnButton.setOnAction(this::actionPerformed); removeColumnButton.setOnAction(this::actionPerformed); buttonsPanel.getChildren().addAll(addColumnButton,removeColumnButton); this.setRight(buttonsPanel); this.setCenter(columnsTable); BorderPane.setMargin(buttonsPanel, new Insets(10)); }
Example 20
Source File: OpenAbout.java From phoebus with Eclipse Public License 1.0 | 4 votes |
@Override public Void call() { dialog = new Alert(AlertType.INFORMATION); dialog.setTitle(Messages.HelpAboutTitle); dialog.setHeaderText(Messages.HelpAboutHdr); // Table with Name, Value columns final ObservableList<List<String>> infos = FXCollections.observableArrayList(); // Start with most user-specific to most generic: User location, install, JDK, ... // Note that OpenFileBrowserCell is hard-coded to add a "..." button for the first few rows. infos.add(Arrays.asList(Messages.HelpAboutUser, Locations.user().toString())); infos.add(Arrays.asList(Messages.HelpAboutInst, Locations.install().toString())); infos.add(Arrays.asList(Messages.HelpAboutUserDir, System.getProperty("user.dir"))); infos.add(Arrays.asList(Messages.HelpJavaHome, System.getProperty("java.home"))); infos.add(Arrays.asList(Messages.AppVersionHeader, Messages.AppVersion)); infos.add(Arrays.asList(Messages.HelpAboutJava, System.getProperty("java.specification.vendor") + " " + System.getProperty("java.runtime.version"))); infos.add(Arrays.asList(Messages.HelpAboutJfx, System.getProperty("javafx.runtime.version"))); infos.add(Arrays.asList(Messages.HelpAboutPID, Long.toString(ProcessHandle.current().pid()))); // Display in TableView final TableView<List<String>> info_table = new TableView<>(infos); info_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); info_table.setPrefHeight(290.0); final TableColumn<List<String>, String> name_col = new TableColumn<>(Messages.HelpAboutColName); name_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(0))); info_table.getColumns().add(name_col); final TableColumn<List<String>, String> value_col = new TableColumn<>(Messages.HelpAboutColValue); value_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1))); value_col.setCellFactory(col -> new ReadOnlyTextCell<>()); info_table.getColumns().add(value_col); final TableColumn<List<String>, String> link_col = new TableColumn<>(); link_col.setMinWidth(50); link_col.setMaxWidth(50); link_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1))); link_col.setCellFactory(col -> new OpenFileBrowserCell()); info_table.getColumns().add(link_col); dialog.getDialogPane().setContent(info_table); // Info for expandable "Show Details" section dialog.getDialogPane().setExpandableContent(createDetailSection()); dialog.setResizable(true); dialog.getDialogPane().setPrefWidth(800); DialogHelper.positionDialog(dialog, DockPane.getActiveDockPane(), -400, -300); dialog.showAndWait(); // Indicate that dialog is closed; allow GC dialog = null; return null; }