Java Code Examples for javafx.scene.control.TreeTableColumn#setMinWidth()
The following examples show how to use
javafx.scene.control.TreeTableColumn#setMinWidth() .
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: CIntegerField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public TreeTableColumn<ObjectDataElt, Integer> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn< ObjectDataElt, Integer> thiscolumn = new TreeTableColumn<ObjectDataElt, Integer>(this.getLabel()); if (actionkeyforupdate != null) thiscolumn.setEditable(true); int length = 110; thiscolumn.setMinWidth(length); CIntegerField thisdecimalfield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, Integer>, ObservableValue<Integer>>() { @Override public ObservableValue<Integer> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, Integer> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thisdecimalfield.getFieldname(); if (line == null) return new SimpleObjectProperty<Integer>(null); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) return new SimpleObjectProperty<Integer>(null); if (!(lineelement instanceof IntegerDataElt)) return new SimpleObjectProperty<Integer>(null); IntegerDataElt linedataelt = (IntegerDataElt) lineelement; return new SimpleObjectProperty<Integer>(linedataelt.getPayload()); } }); return thiscolumn; }
Example 2
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 3
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 4
Source File: CDecimalField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, LockableBigDecimal> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn< ObjectDataElt, LockableBigDecimal> thiscolumn = new TreeTableColumn<ObjectDataElt, LockableBigDecimal>( this.getLabel()); thiscolumn.setEditable(true); thiscolumn.setStyle("-fx-alignment: CENTER-RIGHT;"); int length = 110; thiscolumn.setMinWidth(length); CDecimalField thisdecimalfield = this; BigDecimalFormatValidator validator = new BigDecimalFormatValidator(precision, scale); // big display disabled as hardcoded thiscolumn.setCellFactory(column -> { return new LargeTextTreeTableCell<ObjectDataElt, LockableBigDecimal>( new NiceLockableBigDecimalStringConverter(precision, scale), validator, this.decimalformatter, false, true,1) { @Override public void updateItem(LockableBigDecimal decimal, boolean empty) { logger.fine("Updating field for decimal = " + decimal + " empty = " + empty); super.updateItem(decimal, empty); super.setMaxHeight(12); super.setPrefHeight(12); super.setMinHeight(12); if (decimal != null) { if (decimal.isLocked()) { logger.fine("set to lock"); super.setEditable(false); } else { logger.fine("set to unlock"); super.setEditable(true); } } } }; }); thiscolumn.setCellValueFactory(new Callback< TreeTableColumn.CellDataFeatures<ObjectDataElt, LockableBigDecimal>, ObservableValue<LockableBigDecimal>>() { @Override public ObservableValue<LockableBigDecimal> call( TreeTableColumn.CellDataFeatures<ObjectDataElt, LockableBigDecimal> p) { SimpleDataElt lineelement = p.getValue().getValue().lookupEltByName(thisdecimalfield.getFieldname()); if (lineelement == null) return new SimpleObjectProperty<LockableBigDecimal>(null); if (!(lineelement instanceof DecimalDataElt)) return new SimpleObjectProperty<LockableBigDecimal>(null); DecimalDataElt linedataelt = (DecimalDataElt) lineelement; boolean locked = true; logger.finest(" *-*-*-* processing DecimalDataElt " + Integer.toHexString(linedataelt.hashCode()) + " locked = " + linedataelt.islocked() + ", payload = " + linedataelt.getPayload() + " name = " + linedataelt.getName()); return new SimpleObjectProperty<LockableBigDecimal>( new LockableBigDecimal(locked, linedataelt.getPayload())); } }); return thiscolumn; }
Example 5
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 6
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 7
Source File: CObjectArrayColumnModel.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
/** * generate a tree table view * * @param actionmanager action manager * @return a tree table view model for the given column model */ public TreeTableView<ObjectDataElt> generateTreeTableViewModel(PageActionManager actionmanager) { // initializes the tree table TreeTableView<ObjectDataElt> treetable = new TreeTableView<ObjectDataElt>(); double totalwidth = 0; boolean firsttreecolumn = true; for (int i = 0; i < arraycolumns.size(); i++) { CBusinessField<?> thisfield = arraycolumns.get(i); if (!thisfield.isShowinbottomnotes()) { String actionkeyforupdate = updateactionfields.get(thisfield.getFieldname()); if (actionkeyforupdate != null) { logger.info("setting the column " + thisfield.getFieldname() + " to readwrite for action " + actionkeyforupdate); } TreeTableColumn< ObjectDataElt, ?> thiscolumn = thisfield.getTreeTableColumn(actionmanager, actionkeyforupdate); if (firsttreecolumn) { thiscolumn.setMinWidth(thiscolumn.getMinWidth() + 50); firsttreecolumn = false; } totalwidth += thiscolumn.getMinWidth(); treetable.getColumns().add(thiscolumn); thiscolumn.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { double currentwidth = treetable.getWidth(); double minwidth = treetable.getMinWidth(); double extrawidth = newValue.doubleValue() - oldValue.doubleValue(); treetable.setPrefWidth(currentwidth + extrawidth); treetable.setMinWidth(minwidth + extrawidth); } }); } else { columnstoshowintooltip.add(thisfield); } treetable.setRowFactory(tv -> new TreeTableRow<ObjectDataElt>() { private Tooltip tooltip = new Tooltip(); @Override public void updateItem(ObjectDataElt object, boolean empty) { super.updateItem(object, empty); if (object == null) { setTooltip(null); } else { tooltip.setText(generateTextForTooltip(columnstoshowintooltip, object)); this.setTooltip(tooltip); } } }); } // this is a hack to compensate for potential right scrollbar treetable.setMinWidth(totalwidth + 14); treetable.setPrefWidth(totalwidth + 14); return treetable; }
Example 8
Source File: CDateField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, Date> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, Date> thiscolumn = new TreeTableColumn<ObjectDataElt, Date>(this.getLabel()); thiscolumn.setEditable(true); int length = 110; thiscolumn.setMinWidth(length); thiscolumn.setCellFactory(column -> { return new TreeTableCell<ObjectDataElt, Date>() { @Override protected void updateItem(Date date, boolean empty) { super.updateItem(date, empty); if (date == null || empty) { setText(null); } else { setText(dateformat.format(date)); this.setTooltip(new Tooltip(fulldateformat.format(date))); } } }; }); CDateField thisdatefield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, Date>, ObservableValue<Date>>() { @Override public ObservableValue<Date> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, Date> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thisdatefield.getFieldname(); if (line == null) return new SimpleObjectProperty<Date>(null); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) return new SimpleObjectProperty<Date>(null); if (!(lineelement instanceof DateDataElt)) return new SimpleObjectProperty<Date>(null); DateDataElt linedataelt = (DateDataElt) lineelement; return new SimpleObjectProperty<Date>(linedataelt.getPayload()); } }); return thiscolumn; }