Java Code Examples for javafx.scene.control.TreeTableColumn#setPrefWidth()
The following examples show how to use
javafx.scene.control.TreeTableColumn#setPrefWidth() .
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: DefaultTreeTable.java From xframium-java with GNU General Public License v3.0 | 5 votes |
protected void addColumnString (String heading, int width, Justification justification, String propertyName) { TreeTableColumn<T, String> column = new TreeTableColumn<> (heading); column.setPrefWidth (width); column .setCellValueFactory (new TreeItemPropertyValueFactory<T, String> (propertyName)); getColumns ().add (column); if (justification == Justification.CENTER) column.setStyle ("-fx-alignment: CENTER;"); }
Example 2
Source File: DefaultTreeTable.java From xframium-java with GNU General Public License v3.0 | 5 votes |
protected void addColumnNumber (String heading, int width, String propertyName) { TreeTableColumn<T, Number> column = new TreeTableColumn<> (heading); column.setPrefWidth (width); column .setCellValueFactory (new TreeItemPropertyValueFactory<T, Number> (propertyName)); getColumns ().add (column); column.setStyle ("-fx-alignment: CENTER-RIGHT;"); }
Example 3
Source File: DefaultTreeTable.java From dm3270 with Apache License 2.0 | 5 votes |
protected void addColumnString (String heading, int width, Justification justification, String propertyName) { TreeTableColumn<T, String> column = new TreeTableColumn<> (heading); column.setPrefWidth (width); column .setCellValueFactory (new TreeItemPropertyValueFactory<T, String> (propertyName)); getColumns ().add (column); if (justification == Justification.CENTER) column.setStyle ("-fx-alignment: CENTER;"); }
Example 4
Source File: DefaultTreeTable.java From dm3270 with Apache License 2.0 | 5 votes |
protected void addColumnNumber (String heading, int width, String propertyName) { TreeTableColumn<T, Number> column = new TreeTableColumn<> (heading); column.setPrefWidth (width); column .setCellValueFactory (new TreeItemPropertyValueFactory<T, Number> (propertyName)); getColumns ().add (column); column.setStyle ("-fx-alignment: CENTER-RIGHT;"); }
Example 5
Source File: CMultipleChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, ?> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, String> thiscolumn = new TreeTableColumn<ObjectDataElt, String>(this.getLabel()); thiscolumn.setEditable(true); int length = (this.maxcharlength * 7); if (length > 300) length = 300; if (this.prefereddisplayintable >= 0) { length = this.prefereddisplayintable * 7; } logger.fine(" --**-- length for field" + this.getLabel() + " maxcharlength:" + maxcharlength + " pref display in table " + this.prefereddisplayintable + " final length = " + length); thiscolumn.setMinWidth(length); thiscolumn.setPrefWidth(length); CMultipleChoiceField thischoicefield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, String>, ObservableValue<String>>() { @SuppressWarnings("unchecked") @Override public ObservableValue<String> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, String> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thischoicefield.getFieldname(); if (line == null) return new SimpleStringProperty(""); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) { return new SimpleStringProperty("Field Not found !" + fieldname); } if (!(lineelement instanceof MultipleChoiceDataElt)) return new SimpleStringProperty("Invalid type " + lineelement.getType()); return new SimpleStringProperty(thischoicefield .displayMultiValue((MultipleChoiceDataElt<CChoiceFieldValue>) lineelement)); } }); return thiscolumn; }
Example 6
Source File: CTimePeriodField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, ?> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, String> thiscolumn = new TreeTableColumn<ObjectDataElt, String>(this.getLabel()); thiscolumn.setEditable(true); int length = 20 * 7; if (this.prefereddisplayintable >= 0) { length = this.prefereddisplayintable * 7; } thiscolumn.setMinWidth(length); thiscolumn.setPrefWidth(length); CTimePeriodField thistimeperiodfield = this; thiscolumn.setCellValueFactory(new javafx.util.Callback< TreeTableColumn.CellDataFeatures<ObjectDataElt, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, String> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thistimeperiodfield.getFieldname(); if (line == null) return new SimpleStringProperty(""); SimpleDataElt lineelement = line.lookupEltByName(fieldname); String displayasstring = "Field Not found or bad type: " + fieldname + "/" + (lineelement != null ? lineelement.getClass() : "NULL"); if (lineelement != null) if (lineelement instanceof TimePeriodDataElt) { TimePeriodDataElt tpelement = (TimePeriodDataElt) lineelement; return new SimpleStringProperty( tpelement.getPayload() != null ? tpelement.getPayload().toString() : ""); } if (lineelement != null) if (lineelement instanceof TextDataElt) { TextDataElt text = (TextDataElt) lineelement; TimePeriod tp = TimePeriod.generateFromString(text.getPayload()); return new SimpleStringProperty(tp != null ? tp.toString() : ""); } return new SimpleStringProperty(displayasstring); } }); return thiscolumn; }
Example 7
Source File: CChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, String> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, String> thiscolumn = new TreeTableColumn<ObjectDataElt, String>(this.getLabel()); thiscolumn.setEditable(true); int length = (this.maxcharlength * 7); if (length > 300) length = 300; if (this.prefereddisplaysizeintable >= 0) { length = this.prefereddisplaysizeintable * 7; } logger.fine(" --**-- length for field" + this.getLabel() + " maxcharlength:" + maxcharlength + " pref display in table " + this.prefereddisplaysizeintable + " final length = " + length); thiscolumn.setMinWidth(length); thiscolumn.setPrefWidth(length); CChoiceField thischoicefield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, String> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thischoicefield.getFieldname(); if (line == null) return new SimpleStringProperty(""); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) { return new SimpleStringProperty("Field Not found !" + fieldname); } String code = lineelement.defaultTextRepresentation(); String displaystring = "Invalid code: " + code; // by default code is invalid if (code.length() == 0) displaystring = ""; // or empty CChoiceFieldValue displayvalue = valuesbycode.get(code); // try to get display value if (displayvalue != null) displaystring = displayvalue.getDisplayvalue(); return new SimpleStringProperty(displaystring); } }); return thiscolumn; }
Example 8
Source File: CTextField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, ?> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, String> thiscolumn = new TreeTableColumn<ObjectDataElt, String>(this.getLabel()); if (actionkeyforupdate != null) thiscolumn.setEditable(true); int length = 20 + this.maxlength * 6; if (length > 150) length = 150; if (this.prefereddisplaysizeintable >= 0) { logger.severe( "dirty log: prefereddisplayintable " + this.prefereddisplaysizeintable + "," + this.getLabel()); length = this.prefereddisplaysizeintable * 5; } if (length > MAXROWWIDTH) { length = MAXROWWIDTH; LOGGER.finer("for column " + this.getFieldname() + ", reduced max row width to " + length); } thiscolumn.setMinWidth(length); thiscolumn.setPrefWidth(length); CTextField thistextfield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<ObjectDataElt, String> p) { try { ObjectDataElt line = p.getValue().getValue(); String fieldname = thistextfield.getFieldname(); if (line == null) return new SimpleStringProperty(""); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) return new SimpleStringProperty("Field Not found !" + fieldname); if (!richtextedit) return new SimpleStringProperty(lineelement.defaultTextRepresentation()); String text = lineelement.defaultTextRepresentation(); RichText richtext = new RichText(text); return new SimpleStringProperty(richtext.generatePlainString()); } catch (Exception e) { logger.warning("Exception while building observable value " + e.getMessage()); for (int i = 0; i < e.getStackTrace().length; i++) logger.warning(" " + e.getStackTrace()[i]); pageactionmanager.getClientSession().getActiveClientDisplay() .updateStatusBar("Error in building cell value " + e.getMessage(), true); return new SimpleStringProperty("ERROR"); } } }); return thiscolumn; }
Example 9
Source File: FileBrowserController.java From phoebus with Eclipse Public License 1.0 | 4 votes |
@FXML public void initialize() { treeView.setShowRoot(false); treeView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); // Create table columns final TreeTableColumn<FileInfo, File> name_col = new TreeTableColumn<>(Messages.ColName); name_col.setPrefWidth(200); name_col.setCellValueFactory(p -> new ReadOnlyObjectWrapper<>(p.getValue().getValue().file)); name_col.setCellFactory(info -> new FileTreeCell()); name_col.setComparator(FileTreeItem.fileTreeItemComparator); treeView.getColumns().add(name_col); // Linux (Gnome) and Mac file browsers list size before time final TreeTableColumn<FileInfo, Number> size_col = new TreeTableColumn<>(Messages.ColSize); size_col.setCellValueFactory(p -> p.getValue().getValue().size); size_col.setCellFactory(info -> new FileSizeCell()); treeView.getColumns().add(size_col); final TreeTableColumn<FileInfo, String> time_col = new TreeTableColumn<>(Messages.ColTime); time_col.setCellValueFactory(p -> p.getValue().getValue().time); treeView.getColumns().add(time_col); // This would cause columns to fill table width, // but _always_ does that, not allowing us to restore // saved widths from memento: // treeView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY); // Last column fills remaining space final InvalidationListener resize = prop -> { // Available with, less space used for the TableMenuButton '+' on the right // so that the up/down column sort markers remain visible double available = treeView.getWidth() - 10; if (name_col.isVisible()) { // Only name visible? Use the space! if (!size_col.isVisible() && !time_col.isVisible()) name_col.setPrefWidth(available); else available -= name_col.getWidth(); } if (size_col.isVisible()) { if (! time_col.isVisible()) size_col.setPrefWidth(available); else available -= size_col.getWidth(); } if (time_col.isVisible()) time_col.setPrefWidth(available); }; treeView.widthProperty().addListener(resize); name_col.widthProperty().addListener(resize); size_col.widthProperty().addListener(resize); name_col.visibleProperty().addListener(resize); size_col.visibleProperty().addListener(resize); time_col.visibleProperty().addListener(resize); // Allow users to show/hide columns treeView.setTableMenuButtonVisible(true); // Prepare ContextMenu items open.setOnAction(event -> openSelectedResources()); contextMenu.getItems().addAll(open, openWith); treeView.setOnKeyPressed(this::handleKeys); }