Java tutorial
// Description: Java 8 JavaFX List of Obj Pane implementation for BoolType. /* * CFBam * * Copyright (c) 2014-2016 Mark Sobkow * * This program is available as free software under the GNU GPL v3, or * under a commercial license from Mark Sobkow. For commercial licensing * details, please contact msobkow@sasktel.net. * * Under the terms of the GPL: * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ package net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX; import java.math.*; import java.util.*; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Parent; import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane.ScrollBarPolicy; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn.CellDataFeatures; import javafx.scene.control.TableView; import javafx.util.Callback; import net.sourceforge.msscodefactory.cflib.v2_7.CFLib.*; import net.sourceforge.msscodefactory.cflib.v2_7.CFLib.JavaFX.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cfsecurity.v2_7.CFSecurity.*; import net.sourceforge.msscodefactory.cfinternet.v2_7.CFInternet.*; import net.sourceforge.msscodefactory.cfbam.v2_7.CFBam.*; import net.sourceforge.msscodefactory.cfsecurity.v2_7.CFSecurityObj.*; import net.sourceforge.msscodefactory.cfinternet.v2_7.CFInternetObj.*; import net.sourceforge.msscodefactory.cfbam.v2_7.CFBamObj.*; import net.sourceforge.msscodefactory.cfsecurity.v2_7.CFSecurityJavaFX.*; import net.sourceforge.msscodefactory.cfinternet.v2_7.CFInternetJavaFX.*; /** * CFBamJavaFXBoolTypeListPane JavaFX List of Obj Pane implementation * for BoolType. */ public class CFBamJavaFXBoolTypeListPane extends CFBorderPane implements ICFBamJavaFXBoolTypePaneList { public static String S_FormName = "List BoolType"; protected ICFBamJavaFXSchema javafxSchema = null; protected Collection<ICFBamBoolTypeObj> javafxDataCollection = null; protected ObservableList<ICFBamBoolTypeObj> observableListOfBoolType = null; protected ScrollPane scrollMenu = null; protected CFHBox hboxMenu = null; protected CFButton buttonAddBoolType = null; protected CFButton buttonViewSelected = null; protected CFButton buttonEditSelected = null; protected CFButton buttonDeleteSelected = null; protected TableView<ICFBamBoolTypeObj> dataTable = null; protected TableColumn<ICFBamBoolTypeObj, Long> tableColumnId = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnName = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnShortName = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnLabel = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnShortDescription = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnDescription = null; protected TableColumn<ICFBamBoolTypeObj, Boolean> tableColumnIsNullable = null; protected TableColumn<ICFBamBoolTypeObj, Boolean> tableColumnGenerateId = null; protected TableColumn<ICFBamBoolTypeObj, Boolean> tableColumnDefaultVisibility = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnDbName = null; protected TableColumn<ICFBamBoolTypeObj, Boolean> tableColumnInitValue = null; protected TableColumn<ICFBamBoolTypeObj, Boolean> tableColumnDefaultValue = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnFalseString = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnTrueString = null; protected TableColumn<ICFBamBoolTypeObj, String> tableColumnNullString = null; protected TableColumn<ICFBamBoolTypeObj, ICFBamSchemaDefObj> tableColumnLookupDefSchema = null; public final String S_ColumnNames[] = { "Name" }; protected ICFFormManager cfFormManager = null; protected boolean javafxIsInitializing = true; protected boolean javafxSortByChain = false; protected ICFBamSchemaDefObj javafxContainer = null; protected ICFRefreshCallback javafxRefreshCallback = null; class ViewEditClosedCallback implements ICFFormClosedCallback { public ViewEditClosedCallback() { } public void formClosed(ICFLibAnyObj affectedObject) { if (affectedObject != null) { refreshMe(); } } } protected ViewEditClosedCallback viewEditClosedCallback = null; public ICFFormClosedCallback getViewEditClosedCallback() { if (viewEditClosedCallback == null) { viewEditClosedCallback = new ViewEditClosedCallback(); } return (viewEditClosedCallback); } class DeleteCallback implements ICFDeleteCallback { public DeleteCallback() { } public void deleted(ICFLibAnyObj deletedObject) { if (deletedObject != null) { refreshMe(); } } public void formClosed(ICFLibAnyObj affectedObject) { if (affectedObject != null) { refreshMe(); } } } protected DeleteCallback deleteCallback = null; public ICFDeleteCallback getDeleteCallback() { if (deleteCallback == null) { deleteCallback = new DeleteCallback(); } return (deleteCallback); } public CFBamJavaFXBoolTypeListPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamSchemaDefObj argContainer, ICFBamBoolTypeObj argFocus, Collection<ICFBamBoolTypeObj> argDataCollection, ICFRefreshCallback refreshCallback, boolean sortByChain) { super(); final String S_ProcName = "construct-schema-focus"; if (formManager == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "formManager"); } cfFormManager = formManager; if (argSchema == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 2, "argSchema"); } // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. javafxSchema = argSchema; javaFXFocus = argFocus; javafxContainer = argContainer; javafxRefreshCallback = refreshCallback; javafxSortByChain = sortByChain; setJavaFXDataCollection(argDataCollection); dataTable = new TableView<ICFBamBoolTypeObj>(); tableColumnId = new TableColumn<ICFBamBoolTypeObj, Long>("Id"); tableColumnId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamBoolTypeObj, Long> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { long value = obj.getRequiredId(); Long wrapped = new Long(value); ReadOnlyObjectWrapper<Long> observable = new ReadOnlyObjectWrapper<Long>(); observable.setValue(wrapped); return (observable); } } }); tableColumnId.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, Long>, TableCell<ICFBamBoolTypeObj, Long>>() { @Override public TableCell<ICFBamBoolTypeObj, Long> call(TableColumn<ICFBamBoolTypeObj, Long> arg) { return new CFInt64TableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnId); tableColumnName = new TableColumn<ICFBamBoolTypeObj, String>("Name"); tableColumnName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getRequiredName(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnName.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnName); tableColumnShortName = new TableColumn<ICFBamBoolTypeObj, String>("Short Name"); tableColumnShortName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalShortName(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnShortName.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnShortName); tableColumnLabel = new TableColumn<ICFBamBoolTypeObj, String>("Label"); tableColumnLabel.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalLabel(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnLabel.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnLabel); tableColumnShortDescription = new TableColumn<ICFBamBoolTypeObj, String>("Short Description"); tableColumnShortDescription.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalShortDescription(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnShortDescription.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnShortDescription); tableColumnDescription = new TableColumn<ICFBamBoolTypeObj, String>("Description"); tableColumnDescription.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalDescription(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnDescription.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnDescription); tableColumnIsNullable = new TableColumn<ICFBamBoolTypeObj, Boolean>("Is Nullable"); tableColumnIsNullable.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamBoolTypeObj, Boolean> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { boolean value = obj.getRequiredIsNullable(); Boolean wrapped = new Boolean(value); ReadOnlyObjectWrapper<Boolean> observable = new ReadOnlyObjectWrapper<Boolean>(); observable.setValue(wrapped); return (observable); } } }); tableColumnIsNullable.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, Boolean>, TableCell<ICFBamBoolTypeObj, Boolean>>() { @Override public TableCell<ICFBamBoolTypeObj, Boolean> call(TableColumn<ICFBamBoolTypeObj, Boolean> arg) { return new CFBoolTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnIsNullable); tableColumnGenerateId = new TableColumn<ICFBamBoolTypeObj, Boolean>("Generate Id"); tableColumnGenerateId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamBoolTypeObj, Boolean> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { Boolean value = obj.getOptionalGenerateId(); ReadOnlyObjectWrapper<Boolean> observable = new ReadOnlyObjectWrapper<Boolean>(); observable.setValue(value); return (observable); } } }); tableColumnGenerateId.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, Boolean>, TableCell<ICFBamBoolTypeObj, Boolean>>() { @Override public TableCell<ICFBamBoolTypeObj, Boolean> call(TableColumn<ICFBamBoolTypeObj, Boolean> arg) { return new CFBoolTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnGenerateId); tableColumnDefaultVisibility = new TableColumn<ICFBamBoolTypeObj, Boolean>("Default Visibility"); tableColumnDefaultVisibility.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamBoolTypeObj, Boolean> p) { ICFBamValueObj obj = p.getValue(); if (obj == null) { return (null); } else { boolean value = obj.getRequiredDefaultVisibility(); Boolean wrapped = new Boolean(value); ReadOnlyObjectWrapper<Boolean> observable = new ReadOnlyObjectWrapper<Boolean>(); observable.setValue(wrapped); return (observable); } } }); tableColumnDefaultVisibility.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, Boolean>, TableCell<ICFBamBoolTypeObj, Boolean>>() { @Override public TableCell<ICFBamBoolTypeObj, Boolean> call(TableColumn<ICFBamBoolTypeObj, Boolean> arg) { return new CFBoolTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnDefaultVisibility); tableColumnDbName = new TableColumn<ICFBamBoolTypeObj, String>("Db Name"); tableColumnDbName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamAtomObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalDbName(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnDbName.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnDbName); tableColumnInitValue = new TableColumn<ICFBamBoolTypeObj, Boolean>("Init. Value"); tableColumnInitValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamBoolTypeObj, Boolean> p) { ICFBamBoolDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Boolean value = obj.getOptionalInitValue(); ReadOnlyObjectWrapper<Boolean> observable = new ReadOnlyObjectWrapper<Boolean>(); observable.setValue(value); return (observable); } } }); tableColumnInitValue.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, Boolean>, TableCell<ICFBamBoolTypeObj, Boolean>>() { @Override public TableCell<ICFBamBoolTypeObj, Boolean> call(TableColumn<ICFBamBoolTypeObj, Boolean> arg) { return new CFBoolTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnInitValue); tableColumnDefaultValue = new TableColumn<ICFBamBoolTypeObj, Boolean>("Default Value"); tableColumnDefaultValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamBoolTypeObj, Boolean> p) { ICFBamBoolDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Boolean value = obj.getOptionalDefaultValue(); ReadOnlyObjectWrapper<Boolean> observable = new ReadOnlyObjectWrapper<Boolean>(); observable.setValue(value); return (observable); } } }); tableColumnDefaultValue.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, Boolean>, TableCell<ICFBamBoolTypeObj, Boolean>>() { @Override public TableCell<ICFBamBoolTypeObj, Boolean> call(TableColumn<ICFBamBoolTypeObj, Boolean> arg) { return new CFBoolTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnDefaultValue); tableColumnFalseString = new TableColumn<ICFBamBoolTypeObj, String>("FalseString"); tableColumnFalseString.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamBoolDefObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalFalseString(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnFalseString.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnFalseString); tableColumnTrueString = new TableColumn<ICFBamBoolTypeObj, String>("TrueString"); tableColumnTrueString.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamBoolDefObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalTrueString(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnTrueString.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnTrueString); tableColumnNullString = new TableColumn<ICFBamBoolTypeObj, String>("NullString"); tableColumnNullString.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamBoolTypeObj, String> p) { ICFBamBoolDefObj obj = p.getValue(); if (obj == null) { return (null); } else { String value = obj.getOptionalNullString(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(value); return (observable); } } }); tableColumnNullString.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, String>, TableCell<ICFBamBoolTypeObj, String>>() { @Override public TableCell<ICFBamBoolTypeObj, String> call(TableColumn<ICFBamBoolTypeObj, String> arg) { return new CFStringTableCell<ICFBamBoolTypeObj>(); } }); dataTable.getColumns().add(tableColumnNullString); tableColumnLookupDefSchema = new TableColumn<ICFBamBoolTypeObj, ICFBamSchemaDefObj>( "Defining Schema Definition"); tableColumnLookupDefSchema.setCellValueFactory( new Callback<CellDataFeatures<ICFBamBoolTypeObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() { public ObservableValue<ICFBamSchemaDefObj> call( CellDataFeatures<ICFBamBoolTypeObj, ICFBamSchemaDefObj> p) { ICFBamBoolTypeObj obj = p.getValue(); if (obj == null) { return (null); } else { ICFBamSchemaDefObj ref = obj.getOptionalLookupDefSchema(); ReadOnlyObjectWrapper<ICFBamSchemaDefObj> observable = new ReadOnlyObjectWrapper<ICFBamSchemaDefObj>(); observable.setValue(ref); return (observable); } } }); tableColumnLookupDefSchema.setCellFactory( new Callback<TableColumn<ICFBamBoolTypeObj, ICFBamSchemaDefObj>, TableCell<ICFBamBoolTypeObj, ICFBamSchemaDefObj>>() { @Override public TableCell<ICFBamBoolTypeObj, ICFBamSchemaDefObj> call( TableColumn<ICFBamBoolTypeObj, ICFBamSchemaDefObj> arg) { return new CFReferenceTableCell<ICFBamBoolTypeObj, ICFBamSchemaDefObj>(); } }); dataTable.getColumns().add(tableColumnLookupDefSchema); dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamBoolTypeObj>() { @Override public void changed(ObservableValue<? extends ICFBamBoolTypeObj> observable, ICFBamBoolTypeObj oldValue, ICFBamBoolTypeObj newValue) { setJavaFXFocus(newValue); } }); scrollMenu = new ScrollPane(); scrollMenu.setVbarPolicy(ScrollBarPolicy.NEVER); scrollMenu.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollMenu.setFitToHeight(true); scrollMenu.setContent(getPanelHBoxMenu()); setTop(scrollMenu); setCenter(dataTable); javafxIsInitializing = false; if (observableListOfBoolType != null) { dataTable.setItems(observableListOfBoolType); } adjustListButtons(); } public ICFFormManager getCFFormManager() { return (cfFormManager); } public void setCFFormManager(ICFFormManager value) { final String S_ProcName = "setCFFormManager"; if (value == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "value"); } cfFormManager = value; } public ICFBamJavaFXSchema getJavaFXSchema() { return (javafxSchema); } public void setPaneMode(CFPane.PaneMode value) { super.setPaneMode(value); adjustListButtons(); } public void setJavaFXFocus(ICFLibAnyObj value) { final String S_ProcName = "setJavaFXFocus"; if ((value == null) || (value instanceof ICFBamBoolTypeObj)) { super.setJavaFXFocus(value); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "value", value, "ICFBamBoolTypeObj"); } adjustListButtons(); } public ICFBamBoolTypeObj getJavaFXFocusAsBoolType() { return ((ICFBamBoolTypeObj) getJavaFXFocus()); } public void setJavaFXFocusAsBoolType(ICFBamBoolTypeObj value) { setJavaFXFocus(value); } public class BoolTypeByQualNameComparator implements Comparator<ICFBamBoolTypeObj> { public BoolTypeByQualNameComparator() { } public int compare(ICFBamBoolTypeObj lhs, ICFBamBoolTypeObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { String lhsValue = lhs.getObjQualifiedName(); String rhsValue = rhs.getObjQualifiedName(); if (lhsValue == null) { if (rhsValue == null) { return (0); } else { return (-1); } } else if (rhsValue == null) { return (1); } else { return (lhsValue.compareTo(rhsValue)); } } } } protected BoolTypeByQualNameComparator compareBoolTypeByQualName = new BoolTypeByQualNameComparator(); public Collection<ICFBamBoolTypeObj> getJavaFXDataCollection() { return (javafxDataCollection); } public void setJavaFXDataCollection(Collection<ICFBamBoolTypeObj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value; observableListOfBoolType = FXCollections.observableArrayList(); if (javafxDataCollection != null) { Iterator<ICFBamBoolTypeObj> iter = javafxDataCollection.iterator(); while (iter.hasNext()) { observableListOfBoolType.add(iter.next()); } observableListOfBoolType.sort(compareBoolTypeByQualName); } if (dataTable != null) { dataTable.setItems(observableListOfBoolType); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } } protected class CompareCFButtonByText implements Comparator<CFButton> { public CompareCFButtonByText() { } @Override public int compare(CFButton lhs, CFButton rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { int retval = lhs.getText().compareTo(rhs.getText()); return (retval); } } } public CFHBox getPanelHBoxMenu() { if (hboxMenu == null) { hboxMenu = new CFHBox(10); buttonAddBoolType = new CFButton(); buttonAddBoolType.setMinWidth(200); buttonAddBoolType.setText("Add BoolType"); buttonAddBoolType.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { ICFBamSchemaObj schemaObj = (ICFBamSchemaObj) javafxSchema.getSchema(); ICFBamBoolTypeObj obj = (ICFBamBoolTypeObj) schemaObj.getBoolTypeTableObj().newInstance(); ICFBamBoolTypeEditObj edit = (ICFBamBoolTypeEditObj) (obj.beginEdit()); if (edit == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "edit"); } ICFSecurityTenantObj secTenant = schemaObj.getSecTenant(); edit.setRequiredOwnerTenant(secTenant); ICFBamSchemaDefObj container = (ICFBamSchemaDefObj) (getJavaFXContainer()); if (container == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "JavaFXContainer"); } edit.setRequiredContainerSchemaDef(container); CFBorderPane frame = javafxSchema.getBoolTypeFactory().newAddForm(cfFormManager, obj, getViewEditClosedCallback(), true); ICFBamJavaFXBoolTypePaneCommon jpanelCommon = (ICFBamJavaFXBoolTypePaneCommon) frame; jpanelCommon.setJavaFXFocus(obj); jpanelCommon.setPaneMode(CFPane.PaneMode.Add); cfFormManager.pushForm(frame); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonAddBoolType); buttonViewSelected = new CFButton(); buttonViewSelected.setMinWidth(200); buttonViewSelected.setText("View Selected"); buttonViewSelected.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { ICFBamSchemaObj schemaObj = (ICFBamSchemaObj) javafxSchema.getSchema(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj"); } ICFBamBoolTypeObj selectedInstance = getJavaFXFocusAsBoolType(); if (selectedInstance != null) { String classCode = selectedInstance.getClassCode(); if ("BOLT".equals(classCode)) { CFBorderPane frame = javafxSchema.getBoolTypeFactory().newViewEditForm( cfFormManager, selectedInstance, getViewEditClosedCallback(), false); ((ICFBamJavaFXBoolTypePaneCommon) frame).setPaneMode(CFPane.PaneMode.View); cfFormManager.pushForm(frame); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "selectedInstance", selectedInstance, "ICFBamBoolTypeObj"); } } } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonViewSelected); buttonEditSelected = new CFButton(); buttonEditSelected.setMinWidth(200); buttonEditSelected.setText("Edit Selected"); buttonEditSelected.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { ICFBamSchemaObj schemaObj = (ICFBamSchemaObj) javafxSchema.getSchema(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj"); } ICFBamBoolTypeObj selectedInstance = getJavaFXFocusAsBoolType(); if (selectedInstance != null) { String classCode = selectedInstance.getClassCode(); if ("BOLT".equals(classCode)) { CFBorderPane frame = javafxSchema.getBoolTypeFactory().newViewEditForm( cfFormManager, selectedInstance, getViewEditClosedCallback(), false); ((ICFBamJavaFXBoolTypePaneCommon) frame).setPaneMode(CFPane.PaneMode.Edit); cfFormManager.pushForm(frame); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "selectedInstance", selectedInstance, "ICFBamBoolTypeObj"); } } } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonEditSelected); buttonDeleteSelected = new CFButton(); buttonDeleteSelected.setMinWidth(200); buttonDeleteSelected.setText("Delete Selected"); buttonDeleteSelected.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { ICFBamSchemaObj schemaObj = (ICFBamSchemaObj) javafxSchema.getSchema(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj"); } ICFBamBoolTypeObj selectedInstance = getJavaFXFocusAsBoolType(); if (selectedInstance != null) { String classCode = selectedInstance.getClassCode(); if ("BOLT".equals(classCode)) { CFBorderPane frame = javafxSchema.getBoolTypeFactory() .newAskDeleteForm(cfFormManager, selectedInstance, getDeleteCallback()); ((ICFBamJavaFXBoolTypePaneCommon) frame).setPaneMode(CFPane.PaneMode.View); cfFormManager.pushForm(frame); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "selectedInstance", selectedInstance, "ICFBamBoolTypeObj"); } } } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonDeleteSelected); } return (hboxMenu); } public ICFBamSchemaDefObj getJavaFXContainer() { return (javafxContainer); } public void setJavaFXContainer(ICFBamSchemaDefObj value) { javafxContainer = value; } public void refreshMe() { if (javafxRefreshCallback != null) { javafxRefreshCallback.refreshMe(); } } public void adjustListButtons() { boolean enableState; boolean inEditState; boolean allowAdds; boolean inAddMode = false; ICFBamBoolTypeObj selectedObj = getJavaFXFocusAsBoolType(); CFPane.PaneMode mode = getPaneMode(); if (mode == CFPane.PaneMode.Edit) { inEditState = true; allowAdds = false; } else { inEditState = false; if (getJavaFXContainer() != null) { if (getLeft() != null) { allowAdds = false; inAddMode = true; } else { allowAdds = true; } } else { allowAdds = false; } } if (selectedObj == null) { enableState = false; } else { if ((!inAddMode) && (!inEditState)) { enableState = true; } else { enableState = false; } } if (buttonViewSelected != null) { buttonViewSelected.setDisable(!enableState); } if (buttonEditSelected != null) { if (inEditState) { buttonEditSelected.setDisable(true); } else { buttonEditSelected.setDisable(!enableState); } } if (buttonDeleteSelected != null) { buttonDeleteSelected.setDisable(!enableState); } if (buttonAddBoolType != null) { buttonAddBoolType.setDisable(!allowAdds); } } }