List of usage examples for javafx.util Callback Callback
Callback
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXTZTimestampDefListPane.java
public CFBamJavaFXTZTimestampDefListPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamScopeObj argContainer, ICFBamTZTimestampDefObj argFocus, Collection<ICFBamTZTimestampDefObj> argDataCollection, ICFRefreshCallback refreshCallback, boolean sortByChain) { super();//from ww w .ja v a2 s .c o m 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<ICFBamTZTimestampDefObj>(); tableColumnObjKind = new TableColumn<ICFBamTZTimestampDefObj, String>("Class Code"); tableColumnObjKind.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ICFBamTZTimestampDefObj, String> p) { ICFBamTZTimestampDefObj obj = p.getValue(); if (obj == null) { return (null); } else { String classCode = obj.getClassCode(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(classCode); return (observable); } } }); tableColumnObjKind.setCellFactory( new Callback<TableColumn<ICFBamTZTimestampDefObj, String>, TableCell<ICFBamTZTimestampDefObj, String>>() { @Override public TableCell<ICFBamTZTimestampDefObj, String> call( TableColumn<ICFBamTZTimestampDefObj, String> arg) { return new CFStringTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnObjKind); tableColumnId = new TableColumn<ICFBamTZTimestampDefObj, Long>("Id"); tableColumnId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, Long>, TableCell<ICFBamTZTimestampDefObj, Long>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Long> call( TableColumn<ICFBamTZTimestampDefObj, Long> arg) { return new CFInt64TableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnId); tableColumnName = new TableColumn<ICFBamTZTimestampDefObj, String>("Name"); tableColumnName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, String>, TableCell<ICFBamTZTimestampDefObj, String>>() { @Override public TableCell<ICFBamTZTimestampDefObj, String> call( TableColumn<ICFBamTZTimestampDefObj, String> arg) { return new CFStringTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnName); tableColumnShortName = new TableColumn<ICFBamTZTimestampDefObj, String>("Short Name"); tableColumnShortName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, String>, TableCell<ICFBamTZTimestampDefObj, String>>() { @Override public TableCell<ICFBamTZTimestampDefObj, String> call( TableColumn<ICFBamTZTimestampDefObj, String> arg) { return new CFStringTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnShortName); tableColumnLabel = new TableColumn<ICFBamTZTimestampDefObj, String>("Label"); tableColumnLabel.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, String>, TableCell<ICFBamTZTimestampDefObj, String>>() { @Override public TableCell<ICFBamTZTimestampDefObj, String> call( TableColumn<ICFBamTZTimestampDefObj, String> arg) { return new CFStringTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnLabel); tableColumnShortDescription = new TableColumn<ICFBamTZTimestampDefObj, String>("Short Description"); tableColumnShortDescription.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, String>, TableCell<ICFBamTZTimestampDefObj, String>>() { @Override public TableCell<ICFBamTZTimestampDefObj, String> call( TableColumn<ICFBamTZTimestampDefObj, String> arg) { return new CFStringTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnShortDescription); tableColumnDescription = new TableColumn<ICFBamTZTimestampDefObj, String>("Description"); tableColumnDescription.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, String>, TableCell<ICFBamTZTimestampDefObj, String>>() { @Override public TableCell<ICFBamTZTimestampDefObj, String> call( TableColumn<ICFBamTZTimestampDefObj, String> arg) { return new CFStringTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnDescription); tableColumnIsNullable = new TableColumn<ICFBamTZTimestampDefObj, Boolean>("Is Nullable"); tableColumnIsNullable.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, Boolean>, TableCell<ICFBamTZTimestampDefObj, Boolean>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Boolean> call( TableColumn<ICFBamTZTimestampDefObj, Boolean> arg) { return new CFBoolTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnIsNullable); tableColumnGenerateId = new TableColumn<ICFBamTZTimestampDefObj, Boolean>("Generate Id"); tableColumnGenerateId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, Boolean>, TableCell<ICFBamTZTimestampDefObj, Boolean>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Boolean> call( TableColumn<ICFBamTZTimestampDefObj, Boolean> arg) { return new CFBoolTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnGenerateId); tableColumnDefaultVisibility = new TableColumn<ICFBamTZTimestampDefObj, Boolean>("Default Visibility"); tableColumnDefaultVisibility.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, Boolean>, TableCell<ICFBamTZTimestampDefObj, Boolean>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Boolean> call( TableColumn<ICFBamTZTimestampDefObj, Boolean> arg) { return new CFBoolTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnDefaultVisibility); tableColumnDbName = new TableColumn<ICFBamTZTimestampDefObj, String>("Db Name"); tableColumnDbName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamTZTimestampDefObj, 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<ICFBamTZTimestampDefObj, String>, TableCell<ICFBamTZTimestampDefObj, String>>() { @Override public TableCell<ICFBamTZTimestampDefObj, String> call( TableColumn<ICFBamTZTimestampDefObj, String> arg) { return new CFStringTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnDbName); tableColumnInitValue = new TableColumn<ICFBamTZTimestampDefObj, Calendar>("Init. Value"); tableColumnInitValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Calendar>, ObservableValue<Calendar>>() { public ObservableValue<Calendar> call(CellDataFeatures<ICFBamTZTimestampDefObj, Calendar> p) { ICFBamTZTimestampDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Calendar value = obj.getOptionalInitValue(); ReadOnlyObjectWrapper<Calendar> observable = new ReadOnlyObjectWrapper<Calendar>(); observable.setValue(value); return (observable); } } }); tableColumnInitValue.setCellFactory( new Callback<TableColumn<ICFBamTZTimestampDefObj, Calendar>, TableCell<ICFBamTZTimestampDefObj, Calendar>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Calendar> call( TableColumn<ICFBamTZTimestampDefObj, Calendar> arg) { return new CFTZTimestampTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnInitValue); tableColumnDefaultValue = new TableColumn<ICFBamTZTimestampDefObj, Calendar>("Default Value"); tableColumnDefaultValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Calendar>, ObservableValue<Calendar>>() { public ObservableValue<Calendar> call(CellDataFeatures<ICFBamTZTimestampDefObj, Calendar> p) { ICFBamTZTimestampDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Calendar value = obj.getOptionalDefaultValue(); ReadOnlyObjectWrapper<Calendar> observable = new ReadOnlyObjectWrapper<Calendar>(); observable.setValue(value); return (observable); } } }); tableColumnDefaultValue.setCellFactory( new Callback<TableColumn<ICFBamTZTimestampDefObj, Calendar>, TableCell<ICFBamTZTimestampDefObj, Calendar>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Calendar> call( TableColumn<ICFBamTZTimestampDefObj, Calendar> arg) { return new CFTZTimestampTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnDefaultValue); tableColumnMinValue = new TableColumn<ICFBamTZTimestampDefObj, Calendar>("Min. Value"); tableColumnMinValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Calendar>, ObservableValue<Calendar>>() { public ObservableValue<Calendar> call(CellDataFeatures<ICFBamTZTimestampDefObj, Calendar> p) { ICFBamTZTimestampDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Calendar value = obj.getOptionalMinValue(); ReadOnlyObjectWrapper<Calendar> observable = new ReadOnlyObjectWrapper<Calendar>(); observable.setValue(value); return (observable); } } }); tableColumnMinValue.setCellFactory( new Callback<TableColumn<ICFBamTZTimestampDefObj, Calendar>, TableCell<ICFBamTZTimestampDefObj, Calendar>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Calendar> call( TableColumn<ICFBamTZTimestampDefObj, Calendar> arg) { return new CFTZTimestampTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnMinValue); tableColumnMaxValue = new TableColumn<ICFBamTZTimestampDefObj, Calendar>("Max. Value"); tableColumnMaxValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Calendar>, ObservableValue<Calendar>>() { public ObservableValue<Calendar> call(CellDataFeatures<ICFBamTZTimestampDefObj, Calendar> p) { ICFBamTZTimestampDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Calendar value = obj.getOptionalMaxValue(); ReadOnlyObjectWrapper<Calendar> observable = new ReadOnlyObjectWrapper<Calendar>(); observable.setValue(value); return (observable); } } }); tableColumnMaxValue.setCellFactory( new Callback<TableColumn<ICFBamTZTimestampDefObj, Calendar>, TableCell<ICFBamTZTimestampDefObj, Calendar>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Calendar> call( TableColumn<ICFBamTZTimestampDefObj, Calendar> arg) { return new CFTZTimestampTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnMaxValue); tableColumnNullValue = new TableColumn<ICFBamTZTimestampDefObj, Calendar>("Null Value"); tableColumnNullValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Calendar>, ObservableValue<Calendar>>() { public ObservableValue<Calendar> call(CellDataFeatures<ICFBamTZTimestampDefObj, Calendar> p) { ICFBamTZTimestampDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Calendar value = obj.getOptionalNullValue(); ReadOnlyObjectWrapper<Calendar> observable = new ReadOnlyObjectWrapper<Calendar>(); observable.setValue(value); return (observable); } } }); tableColumnNullValue.setCellFactory( new Callback<TableColumn<ICFBamTZTimestampDefObj, Calendar>, TableCell<ICFBamTZTimestampDefObj, Calendar>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Calendar> call( TableColumn<ICFBamTZTimestampDefObj, Calendar> arg) { return new CFTZTimestampTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnNullValue); tableColumnUnknownValue = new TableColumn<ICFBamTZTimestampDefObj, Calendar>("Unknown Value"); tableColumnUnknownValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, Calendar>, ObservableValue<Calendar>>() { public ObservableValue<Calendar> call(CellDataFeatures<ICFBamTZTimestampDefObj, Calendar> p) { ICFBamTZTimestampDefObj obj = p.getValue(); if (obj == null) { return (null); } else { Calendar value = obj.getOptionalUnknownValue(); ReadOnlyObjectWrapper<Calendar> observable = new ReadOnlyObjectWrapper<Calendar>(); observable.setValue(value); return (observable); } } }); tableColumnUnknownValue.setCellFactory( new Callback<TableColumn<ICFBamTZTimestampDefObj, Calendar>, TableCell<ICFBamTZTimestampDefObj, Calendar>>() { @Override public TableCell<ICFBamTZTimestampDefObj, Calendar> call( TableColumn<ICFBamTZTimestampDefObj, Calendar> arg) { return new CFTZTimestampTableCell<ICFBamTZTimestampDefObj>(); } }); dataTable.getColumns().add(tableColumnUnknownValue); tableColumnLookupDefSchema = new TableColumn<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj>( "Defining Schema Definition"); tableColumnLookupDefSchema.setCellValueFactory( new Callback<CellDataFeatures<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() { public ObservableValue<ICFBamSchemaDefObj> call( CellDataFeatures<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj> p) { ICFBamTZTimestampDefObj 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<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj>, TableCell<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj>>() { @Override public TableCell<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj> call( TableColumn<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj> arg) { return new CFReferenceTableCell<ICFBamTZTimestampDefObj, ICFBamSchemaDefObj>(); } }); dataTable.getColumns().add(tableColumnLookupDefSchema); dataTable.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<ICFBamTZTimestampDefObj>() { @Override public void changed(ObservableValue<? extends ICFBamTZTimestampDefObj> observable, ICFBamTZTimestampDefObj oldValue, ICFBamTZTimestampDefObj 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 (observableListOfTZTimestampDef != null) { dataTable.setItems(observableListOfTZTimestampDef); } adjustListButtons(); }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXNumberDefListPane.java
public CFBamJavaFXNumberDefListPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamScopeObj argContainer, ICFBamNumberDefObj argFocus, Collection<ICFBamNumberDefObj> argDataCollection, ICFRefreshCallback refreshCallback, boolean sortByChain) { super();/* www . j a va2s .c om*/ 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<ICFBamNumberDefObj>(); tableColumnObjKind = new TableColumn<ICFBamNumberDefObj, String>("Class Code"); tableColumnObjKind.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ICFBamNumberDefObj, String> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { String classCode = obj.getClassCode(); ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>(); observable.setValue(classCode); return (observable); } } }); tableColumnObjKind.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, String>, TableCell<ICFBamNumberDefObj, String>>() { @Override public TableCell<ICFBamNumberDefObj, String> call(TableColumn<ICFBamNumberDefObj, String> arg) { return new CFStringTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnObjKind); tableColumnId = new TableColumn<ICFBamNumberDefObj, Long>("Id"); tableColumnId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, Long>, TableCell<ICFBamNumberDefObj, Long>>() { @Override public TableCell<ICFBamNumberDefObj, Long> call(TableColumn<ICFBamNumberDefObj, Long> arg) { return new CFInt64TableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnId); tableColumnName = new TableColumn<ICFBamNumberDefObj, String>("Name"); tableColumnName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, String>, TableCell<ICFBamNumberDefObj, String>>() { @Override public TableCell<ICFBamNumberDefObj, String> call(TableColumn<ICFBamNumberDefObj, String> arg) { return new CFStringTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnName); tableColumnShortName = new TableColumn<ICFBamNumberDefObj, String>("Short Name"); tableColumnShortName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, String>, TableCell<ICFBamNumberDefObj, String>>() { @Override public TableCell<ICFBamNumberDefObj, String> call(TableColumn<ICFBamNumberDefObj, String> arg) { return new CFStringTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnShortName); tableColumnLabel = new TableColumn<ICFBamNumberDefObj, String>("Label"); tableColumnLabel.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, String>, TableCell<ICFBamNumberDefObj, String>>() { @Override public TableCell<ICFBamNumberDefObj, String> call(TableColumn<ICFBamNumberDefObj, String> arg) { return new CFStringTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnLabel); tableColumnShortDescription = new TableColumn<ICFBamNumberDefObj, String>("Short Description"); tableColumnShortDescription.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, String>, TableCell<ICFBamNumberDefObj, String>>() { @Override public TableCell<ICFBamNumberDefObj, String> call(TableColumn<ICFBamNumberDefObj, String> arg) { return new CFStringTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnShortDescription); tableColumnDescription = new TableColumn<ICFBamNumberDefObj, String>("Description"); tableColumnDescription.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, String>, TableCell<ICFBamNumberDefObj, String>>() { @Override public TableCell<ICFBamNumberDefObj, String> call(TableColumn<ICFBamNumberDefObj, String> arg) { return new CFStringTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnDescription); tableColumnIsNullable = new TableColumn<ICFBamNumberDefObj, Boolean>("Is Nullable"); tableColumnIsNullable.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, Boolean>, TableCell<ICFBamNumberDefObj, Boolean>>() { @Override public TableCell<ICFBamNumberDefObj, Boolean> call( TableColumn<ICFBamNumberDefObj, Boolean> arg) { return new CFBoolTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnIsNullable); tableColumnGenerateId = new TableColumn<ICFBamNumberDefObj, Boolean>("Generate Id"); tableColumnGenerateId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, Boolean>, TableCell<ICFBamNumberDefObj, Boolean>>() { @Override public TableCell<ICFBamNumberDefObj, Boolean> call( TableColumn<ICFBamNumberDefObj, Boolean> arg) { return new CFBoolTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnGenerateId); tableColumnDefaultVisibility = new TableColumn<ICFBamNumberDefObj, Boolean>("Default Visibility"); tableColumnDefaultVisibility.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, Boolean>, ObservableValue<Boolean>>() { public ObservableValue<Boolean> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, Boolean>, TableCell<ICFBamNumberDefObj, Boolean>>() { @Override public TableCell<ICFBamNumberDefObj, Boolean> call( TableColumn<ICFBamNumberDefObj, Boolean> arg) { return new CFBoolTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnDefaultVisibility); tableColumnDbName = new TableColumn<ICFBamNumberDefObj, String>("Db Name"); tableColumnDbName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamNumberDefObj, 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<ICFBamNumberDefObj, String>, TableCell<ICFBamNumberDefObj, String>>() { @Override public TableCell<ICFBamNumberDefObj, String> call(TableColumn<ICFBamNumberDefObj, String> arg) { return new CFStringTableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnDbName); tableColumnDigits = new TableColumn<ICFBamNumberDefObj, Short>("Digits"); tableColumnDigits.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, Short>, ObservableValue<Short>>() { public ObservableValue<Short> call(CellDataFeatures<ICFBamNumberDefObj, Short> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { short value = obj.getRequiredDigits(); Short wrapped = new Short(value); ReadOnlyObjectWrapper<Short> observable = new ReadOnlyObjectWrapper<Short>(); observable.setValue(wrapped); return (observable); } } }); tableColumnDigits.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, Short>, TableCell<ICFBamNumberDefObj, Short>>() { @Override public TableCell<ICFBamNumberDefObj, Short> call(TableColumn<ICFBamNumberDefObj, Short> arg) { return new CFInt16TableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnDigits); tableColumnPrecis = new TableColumn<ICFBamNumberDefObj, Short>("Precision"); tableColumnPrecis.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, Short>, ObservableValue<Short>>() { public ObservableValue<Short> call(CellDataFeatures<ICFBamNumberDefObj, Short> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { short value = obj.getRequiredPrecis(); Short wrapped = new Short(value); ReadOnlyObjectWrapper<Short> observable = new ReadOnlyObjectWrapper<Short>(); observable.setValue(wrapped); return (observable); } } }); tableColumnPrecis.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, Short>, TableCell<ICFBamNumberDefObj, Short>>() { @Override public TableCell<ICFBamNumberDefObj, Short> call(TableColumn<ICFBamNumberDefObj, Short> arg) { return new CFInt16TableCell<ICFBamNumberDefObj>(); } }); dataTable.getColumns().add(tableColumnPrecis); tableColumnInitValue = new TableColumn<ICFBamNumberDefObj, BigDecimal>("Init. Value"); tableColumnInitValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, BigDecimal>, ObservableValue<BigDecimal>>() { public ObservableValue<BigDecimal> call(CellDataFeatures<ICFBamNumberDefObj, BigDecimal> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { BigDecimal value = obj.getOptionalInitValue(); ReadOnlyObjectWrapper<BigDecimal> observable = new ReadOnlyObjectWrapper<BigDecimal>(); observable.setValue(value); return (observable); } } }); tableColumnInitValue.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, BigDecimal>, TableCell<ICFBamNumberDefObj, BigDecimal>>() { @Override public TableCell<ICFBamNumberDefObj, BigDecimal> call( TableColumn<ICFBamNumberDefObj, BigDecimal> arg) { return new CFNumberTableCell<ICFBamNumberDefObj>(31, 5); } }); dataTable.getColumns().add(tableColumnInitValue); tableColumnDefaultValue = new TableColumn<ICFBamNumberDefObj, BigDecimal>("Default Value"); tableColumnDefaultValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, BigDecimal>, ObservableValue<BigDecimal>>() { public ObservableValue<BigDecimal> call(CellDataFeatures<ICFBamNumberDefObj, BigDecimal> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { BigDecimal value = obj.getOptionalDefaultValue(); ReadOnlyObjectWrapper<BigDecimal> observable = new ReadOnlyObjectWrapper<BigDecimal>(); observable.setValue(value); return (observable); } } }); tableColumnDefaultValue.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, BigDecimal>, TableCell<ICFBamNumberDefObj, BigDecimal>>() { @Override public TableCell<ICFBamNumberDefObj, BigDecimal> call( TableColumn<ICFBamNumberDefObj, BigDecimal> arg) { return new CFNumberTableCell<ICFBamNumberDefObj>(31, 5); } }); dataTable.getColumns().add(tableColumnDefaultValue); tableColumnMinValue = new TableColumn<ICFBamNumberDefObj, BigDecimal>("Min. Value"); tableColumnMinValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, BigDecimal>, ObservableValue<BigDecimal>>() { public ObservableValue<BigDecimal> call(CellDataFeatures<ICFBamNumberDefObj, BigDecimal> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { BigDecimal value = obj.getOptionalMinValue(); ReadOnlyObjectWrapper<BigDecimal> observable = new ReadOnlyObjectWrapper<BigDecimal>(); observable.setValue(value); return (observable); } } }); tableColumnMinValue.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, BigDecimal>, TableCell<ICFBamNumberDefObj, BigDecimal>>() { @Override public TableCell<ICFBamNumberDefObj, BigDecimal> call( TableColumn<ICFBamNumberDefObj, BigDecimal> arg) { return new CFNumberTableCell<ICFBamNumberDefObj>(31, 5); } }); dataTable.getColumns().add(tableColumnMinValue); tableColumnMaxValue = new TableColumn<ICFBamNumberDefObj, BigDecimal>("Max. Value"); tableColumnMaxValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, BigDecimal>, ObservableValue<BigDecimal>>() { public ObservableValue<BigDecimal> call(CellDataFeatures<ICFBamNumberDefObj, BigDecimal> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { BigDecimal value = obj.getOptionalMaxValue(); ReadOnlyObjectWrapper<BigDecimal> observable = new ReadOnlyObjectWrapper<BigDecimal>(); observable.setValue(value); return (observable); } } }); tableColumnMaxValue.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, BigDecimal>, TableCell<ICFBamNumberDefObj, BigDecimal>>() { @Override public TableCell<ICFBamNumberDefObj, BigDecimal> call( TableColumn<ICFBamNumberDefObj, BigDecimal> arg) { return new CFNumberTableCell<ICFBamNumberDefObj>(31, 5); } }); dataTable.getColumns().add(tableColumnMaxValue); tableColumnNullValue = new TableColumn<ICFBamNumberDefObj, BigDecimal>("Null Value"); tableColumnNullValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, BigDecimal>, ObservableValue<BigDecimal>>() { public ObservableValue<BigDecimal> call(CellDataFeatures<ICFBamNumberDefObj, BigDecimal> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { BigDecimal value = obj.getOptionalNullValue(); ReadOnlyObjectWrapper<BigDecimal> observable = new ReadOnlyObjectWrapper<BigDecimal>(); observable.setValue(value); return (observable); } } }); tableColumnNullValue.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, BigDecimal>, TableCell<ICFBamNumberDefObj, BigDecimal>>() { @Override public TableCell<ICFBamNumberDefObj, BigDecimal> call( TableColumn<ICFBamNumberDefObj, BigDecimal> arg) { return new CFNumberTableCell<ICFBamNumberDefObj>(31, 5); } }); dataTable.getColumns().add(tableColumnNullValue); tableColumnUnknownValue = new TableColumn<ICFBamNumberDefObj, BigDecimal>("Unknown Value"); tableColumnUnknownValue.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, BigDecimal>, ObservableValue<BigDecimal>>() { public ObservableValue<BigDecimal> call(CellDataFeatures<ICFBamNumberDefObj, BigDecimal> p) { ICFBamNumberDefObj obj = p.getValue(); if (obj == null) { return (null); } else { BigDecimal value = obj.getOptionalUnknownValue(); ReadOnlyObjectWrapper<BigDecimal> observable = new ReadOnlyObjectWrapper<BigDecimal>(); observable.setValue(value); return (observable); } } }); tableColumnUnknownValue.setCellFactory( new Callback<TableColumn<ICFBamNumberDefObj, BigDecimal>, TableCell<ICFBamNumberDefObj, BigDecimal>>() { @Override public TableCell<ICFBamNumberDefObj, BigDecimal> call( TableColumn<ICFBamNumberDefObj, BigDecimal> arg) { return new CFNumberTableCell<ICFBamNumberDefObj>(31, 5); } }); dataTable.getColumns().add(tableColumnUnknownValue); tableColumnLookupDefSchema = new TableColumn<ICFBamNumberDefObj, ICFBamSchemaDefObj>( "Defining Schema Definition"); tableColumnLookupDefSchema.setCellValueFactory( new Callback<CellDataFeatures<ICFBamNumberDefObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() { public ObservableValue<ICFBamSchemaDefObj> call( CellDataFeatures<ICFBamNumberDefObj, ICFBamSchemaDefObj> p) { ICFBamNumberDefObj 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<ICFBamNumberDefObj, ICFBamSchemaDefObj>, TableCell<ICFBamNumberDefObj, ICFBamSchemaDefObj>>() { @Override public TableCell<ICFBamNumberDefObj, ICFBamSchemaDefObj> call( TableColumn<ICFBamNumberDefObj, ICFBamSchemaDefObj> arg) { return new CFReferenceTableCell<ICFBamNumberDefObj, ICFBamSchemaDefObj>(); } }); dataTable.getColumns().add(tableColumnLookupDefSchema); dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamNumberDefObj>() { @Override public void changed(ObservableValue<? extends ICFBamNumberDefObj> observable, ICFBamNumberDefObj oldValue, ICFBamNumberDefObj 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 (observableListOfNumberDef != null) { dataTable.setItems(observableListOfNumberDef); } adjustListButtons(); }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java
@Override public Region getContent() { if (hBox == null) { VBox statedInferredToggleGroupVBox = new VBox(); statedInferredToggleGroupVBox.setSpacing(4.0); //Instantiate Everything pathComboBox = new ComboBox<>(); //Path statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred List<RadioButton> statedInferredOptionButtons = new ArrayList<>(); datePicker = new DatePicker(); //Date timeSelectCombo = new ComboBox<Long>(); //Time //Radio buttons for (StatedInferredOptions option : StatedInferredOptions.values()) { RadioButton optionButton = new RadioButton(); if (option == StatedInferredOptions.STATED) { optionButton.setText("Stated"); } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) { optionButton.setText("Inferred Then Stated"); } else if (option == StatedInferredOptions.INFERRED) { optionButton.setText("Inferred"); } else { throw new RuntimeException("oops"); }//from www.j a va 2 s . c om optionButton.setUserData(option); optionButton.setTooltip( new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption())); statedInferredToggleGroup.getToggles().add(optionButton); statedInferredToggleGroupVBox.getChildren().add(optionButton); statedInferredOptionButtons.add(optionButton); } statedInferredToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData()); } }); //Path Combo Box pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() { @Override public ListCell<UUID> call(ListView<UUID> param) { final ListCell<UUID> cell = new ListCell<UUID>() { @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }; return cell; } }); pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }); pathComboBox.setOnAction((event) -> { if (!pathComboFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); if (selectedPath != null) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); StampBdb stampDb = Bdb.getStampDb(); NidSet nidSet = new NidSet(); nidSet.add(path); //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE); pathDatesList.clear(); // disableTimeCombo(true); timeSelectCombo.setValue(Long.MAX_VALUE); for (Integer thisStamp : stamps.getAsSet()) { try { Position stampPosition = stampDb.getPosition(thisStamp); this.stampDate = new Date(stampPosition.getTime()); stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); this.pathDatesList.add(stampDateInstant); //Build DatePicker } catch (Exception e) { e.printStackTrace(); } } datePicker.setValue(LocalDate.now()); } } else { pathComboFirstRun = false; } }); pathComboBox.setTooltip( new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\"")); //Calendar Date Picker final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate thisDate, boolean empty) { super.updateItem(thisDate, empty); if (pathDatesList != null) { if (pathDatesList.contains(thisDate)) { setDisable(false); } else { setDisable(true); } } } }; } }; datePicker.setDayCellFactory(dayCellFactory); datePicker.setOnAction((event) -> { if (!datePickerFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault())); Long dateSelected = Date.from(instant).getTime(); if (selectedPath != null && dateSelected != 0) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); setTimeOptions(path, dateSelected); try { timeSelectCombo.setValue(times.first()); //Default Dropdown Value } catch (Exception e) { // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled // Right now, Sometimes Time Combo is disabled, so we catch this and eat it // Otherwise make a conditional from the Read Only Boolean Property to check first } } else { disableTimeCombo(false); logger.debug("The path isn't set or the date isn't set. Both are needed right now"); } } else { datePickerFirstRun = false; } }); //Commit-Time ComboBox timeSelectCombo.setMinWidth(200); timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() { @Override public ListCell<Long> call(ListView<Long> param) { final ListCell<Long> cell = new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }; return cell; } }); timeSelectCombo.setButtonCell(new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }); try { currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty()); } catch (Exception e) { e.printStackTrace(); } // DEFAULT VALUES UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); storedTimePref = loggedIn.getViewCoordinateTime(); storedPathPref = loggedIn.getViewCoordinatePath(); if (storedPathPref != null) { pathComboBox.getItems().clear(); //Set the path Dates by default pathComboBox.getItems().addAll(getPathOptions()); final UUID storedPath = getStoredPath(); if (storedPath != null) { pathComboBox.getSelectionModel().select(storedPath); } if (storedTimePref != null) { final Long storedTime = loggedIn.getViewCoordinateTime(); Calendar cal = Calendar.getInstance(); cal.setTime(new Date(storedTime)); cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds Long storedTruncTime = cal.getTimeInMillis(); if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid(); setTimeOptions(path, storedTimePref); timeSelectCombo.setValue(storedTruncTime); // timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work Date storedDate = new Date(storedTime); datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); } else { datePicker.setValue(LocalDate.now()); timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work timeSelectCombo.setValue(Long.MAX_VALUE); // disableTimeCombo(false); } } else { //Stored Time Pref == null logger.error("ERROR: Stored Time Preference = null"); } } else { //Stored Path Pref == null logger.error("We could not load a stored path, ISAAC cannot run"); throw new Error("No stored PATH could be found. ISAAC can't run without a path"); } GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Label pathLabel = new Label("View Coordinate Path"); gridPane.add(pathLabel, 0, 0); //Path Label - Row 0 GridPane.setHalignment(pathLabel, HPos.LEFT); gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2 gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2 GridPane.setValignment(pathComboBox, VPos.TOP); Label datePickerLabel = new Label("View Coordinate Dates"); gridPane.add(datePickerLabel, 0, 2); //Row 3 GridPane.setHalignment(datePickerLabel, HPos.LEFT); gridPane.add(datePicker, 0, 3); //Row 4 Label timeSelectLabel = new Label("View Coordinate Times"); gridPane.add(timeSelectLabel, 1, 2); //Row 3 GridPane.setHalignment(timeSelectLabel, HPos.LEFT); gridPane.add(timeSelectCombo, 1, 3); //Row 4 // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY /* UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy(); UUID chosenPathUuid = userProfile.getViewCoordinatePath(); Long chosenTime = userProfile.getViewCoordinateTime(); Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid)); gridPane.add(printSelectedPathLabel, 0, 4); GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT); Label printSelectedTimeLabel = null; if(chosenTime != getDefaultTime()) { printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime))); } else { printSelectedTimeLabel = new Label("Time: LONG MAX VALUE"); } gridPane.add(printSelectedTimeLabel, 1, 4); GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT); Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy); gridPane.add(printSelectedPolicyLabel, 2, 4); GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT); */ hBox = new HBox(); hBox.getChildren().addAll(gridPane); allValid_ = new ValidBooleanBinding() { { bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (currentStatedInferredOptionProperty.get() == null) { this.setInvalidReason("Null/unset/unselected StatedInferredOption"); for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.setTextErrorColor(button); } return false; } else { for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.clearTextErrorColor(button); } } if (currentPathProperty.get() == null) { this.setInvalidReason("Null/unset/unselected path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) { this.setInvalidReason("Invalid path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } // if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE) // { // this.setInvalidReason("View Coordinate Time is unselected"); // TextErrorColorHelper.setTextErrorColor(timeSelectCombo); // return false; // } this.clearInvalidReason(); return true; } }; } // createButton.disableProperty().bind(saveButtonValid.not())); // Reload persisted values every time final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption(); for (Toggle toggle : statedInferredToggleGroup.getToggles()) { if (toggle.getUserData() == storedStatedInferredOption) { toggle.setSelected(true); } } // pathComboBox.setButtonCell(new ListCell<UUID>() { // @Override // protected void updateItem(UUID c, boolean emptyRow) { // super.updateItem(c, emptyRow); // if (emptyRow) { // setText(""); // } else { // String desc = OTFUtility.getDescription(c); // setText(desc); // } // } // }); // timeSelectCombo.setButtonCell(new ListCell<Long>() { // @Override // protected void updateItem(Long item, boolean emptyRow) { // super.updateItem(item, emptyRow); // if (emptyRow) { // setText(""); // } else { // setText(timeFormatter.format(new Date(item))); // } // } // }); // datePickerFirstRun = false; // pathComboFirstRun = false; return hBox; }
From source file:com.QuarkLabs.BTCeClientJavaFX.MainController.java
@FXML void initialize() { assert clearLogButton != null : "fx:id=\"clearLogButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTable != null : "fx:id=\"fundsTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert logField != null : "fx:id=\"logField\" was not injected: check your FXML file 'mainlayout.fxml'."; assert buyButton != null : "fx:id=\"buyButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert sellButton != null : "fx:id=\"sellButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert showActiveOrdersButton != null : "fx:id=\"showActiveOrdersButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableLastColumn != null : "fx:id=\"tickerTableLastColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTablePairColumn != null : "fx:id=\"tickerTablePairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTable != null : "fx:id=\"tickersTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableBuyColumn != null : "fx:id=\"tickersTableBuyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableFeeColumn != null : "fx:id=\"tickersTableFeeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableSellColumn != null : "fx:id=\"tickersTableSellColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeAmountValue != null : "fx:id=\"tradeAmountValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceCurrencyType != null : "fx:id=\"tradeCurrencyPriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeCurrencyType != null : "fx:id=\"tradeCurrencyType\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceValue != null : "fx:id=\"tradePriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert updateFundsButton != null : "fx:id=\"updateFundsButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableCurrencyColumn != null : "fx:id=\"fundsTableCurrencyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableValueColumn != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTable != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersAmountColumn != null : "fx:id=\"activeOrdersAmountColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersPairColumn != null : "fx:id=\"activeOrdersPairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersRateColumn != null : "fx:id=\"activeOrdersRateColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTimeColumn != null : "fx:id=\"activeOrdersTimeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTypeColumn != null : "fx:id=\"activeOrdersTypeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersCancelColumn != null : "fx:id=\"activeOrdersCancelColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; //Holder for all main API methods of exchange app = new App(); //Loading configs loadExchangeConfig();/*from www . j av a2s. c o m*/ //Populate choiceboxes at the trading section tradeCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradeCurrencyType.setValue(currencies.get(0)); tradePriceCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradePriceCurrencyType.setValue(currencies.get(0)); //Active Orders table activeOrdersAmountColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("amount")); activeOrdersPairColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("pair")); activeOrdersRateColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("rate")); activeOrdersTimeColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<ActiveOrder, String> activeOrderStringCellDataFeatures) { ActiveOrder activeOrder = activeOrderStringCellDataFeatures.getValue(); DateFormat dateFormat = DateFormat.getDateTimeInstance(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(activeOrder.getTimestamp() * 1000); return new SimpleStringProperty(dateFormat.format(calendar.getTime())); } }); activeOrdersTypeColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("type")); activeOrdersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); activeOrdersCancelColumn .setCellFactory(new Callback<TableColumn<ActiveOrder, Boolean>, TableCell<ActiveOrder, Boolean>>() { @Override public TableCell<ActiveOrder, Boolean> call( TableColumn<ActiveOrder, Boolean> activeOrderBooleanTableColumn) { return new ButtonCell<>(activeOrdersTable); } }); activeOrdersCancelColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, Boolean>, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call( TableColumn.CellDataFeatures<ActiveOrder, Boolean> activeOrderBooleanCellDataFeatures) { return new SimpleBooleanProperty(true); } }); //Tickers Table MenuItem showOrdersBook = new MenuItem("Show Orders Book"); MenuItem showPublicTrades = new MenuItem("Show Public Trades"); ContextMenu contextMenu = new ContextMenu(showOrdersBook, showPublicTrades); tickersTable.setItems(tickers); tickersTable.setContextMenu(contextMenu); tickersTableBuyColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("buy")); tickersTableFeeColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("fee")); tickersTableSellColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("sell")); tickersTableLastColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("last")); tickersTablePairColumn.setCellValueFactory(new PropertyValueFactory<Ticker, String>("pair")); tickersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tickersTable.setRowFactory(new Callback<TableView<Ticker>, TableRow<Ticker>>() { @Override public TableRow<Ticker> call(TableView<Ticker> tickerTableView) { return new TableRow<Ticker>() { @Override protected void updateItem(Ticker ticker, boolean b) { super.updateItem(ticker, b); if (!b) { if (tickersData.containsKey(ticker.getPair())) { if (ticker.getLast() < tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(186, 0, 0, 0.5);"); } else if (ticker.getLast() == tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(215, 193, 44, 0.5);"); } else { setStyle("-fx-control-inner-background: rgba(0, 147, 0, 0.5);"); } } } } }; } }); //Menu item to show Orders Book showOrdersBook.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_ORDERS_BOOK_LAYOUT), resources); root = (Parent) fxmlLoader.load(); OrdersBookController ordersBookController = fxmlLoader.getController(); ordersBookController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Orders Book for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Menu item to show Public Trades showPublicTrades.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_TRADES_LAYOUT), resources); root = (Parent) fxmlLoader.load(); PublicTradesController publicTradesController = fxmlLoader.getController(); publicTradesController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Public Trades for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Funds Table fundsTableCurrencyColumn.setCellValueFactory(new PropertyValueFactory<Fund, String>("currency")); fundsTableValueColumn.setCellValueFactory(new PropertyValueFactory<Fund, Double>("value")); fundsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); fundsTable.setItems(fundsData); //Task to load tickers data from server final javafx.concurrent.Service loadTickersService = new javafx.concurrent.Service() { @Override protected Task createTask() { Task<JSONObject> loadTickers = new Task<JSONObject>() { @Override protected JSONObject call() throws Exception { String[] pairsArray = new String[pairs.size()]; pairsArray = pairs.toArray(pairsArray); return App.getPairInfo(pairsArray); } }; loadTickers.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { logField.appendText(workerStateEvent.getSource().getException().getMessage() + "\r\n"); } }); loadTickers.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { JSONObject jsonObject = (JSONObject) workerStateEvent.getSource().getValue(); //ugly hack to store old values //dump old values to tickersData //TODO think about better solution if (tickers.size() != 0) { for (Ticker x : tickers) { tickersData.put(x.getPair(), x); } } tickers.clear(); for (Iterator iterator = jsonObject.keys(); iterator.hasNext();) { String key = (String) iterator.next(); JSONObject data = jsonObject.getJSONObject(key); Ticker ticker = new Ticker(); ticker.setPair(key); ticker.setUpdated(data.optLong("updated")); ticker.setAvg(data.optDouble("avg")); ticker.setBuy(data.optDouble("buy")); ticker.setSell(data.optDouble("sell")); ticker.setHigh(data.optDouble("high")); ticker.setLast(data.optDouble("last")); ticker.setLow(data.optDouble("low")); ticker.setVol(data.optDouble("vol")); ticker.setVolCur(data.optDouble("vol_cur")); tickers.add(ticker); } } }); return loadTickers; } }; //Update tickers every 15 seconds //TODO better solution is required Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { loadTickersService.restart(); } }), new KeyFrame(Duration.seconds(15))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.playFromStart(); }
From source file:com.panemu.tiwulfx.table.TableControl.java
public TableControl(Class<R> recordClass) { this.recordClass = recordClass; initControls();//from w w w .ja v a2 s . co m tblView.getSortOrder().addListener(new ListChangeListener<TableColumn<R, ?>>() { @Override public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) { reload(); } }); btnAdd.disableProperty().bind(mode.isEqualTo(Mode.EDIT)); btnEdit.disableProperty().bind(mode.isNotEqualTo(Mode.READ)); btnSave.disableProperty().bind(mode.isEqualTo(Mode.READ)); btnDelete.disableProperty().bind(new BooleanBinding() { { super.bind(mode, tblView.getSelectionModel().selectedItemProperty(), lstChangedRow); } @Override protected boolean computeValue() { if ((mode.get() == Mode.INSERT && lstChangedRow.size() < 2) || tblView.getSelectionModel().selectedItemProperty().get() == null || mode.get() == Mode.EDIT) { return true; } return false; } }); tblView.editableProperty().bind(mode.isNotEqualTo(Mode.READ)); tblView.getSelectionModel().cellSelectionEnabledProperty().bind(tblView.editableProperty()); mode.addListener(new ChangeListener<Mode>() { @Override public void changed(ObservableValue<? extends Mode> ov, Mode t, Mode t1) { if (t1 == Mode.READ) { directEdit = false; } } }); tblView.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { lblRowIndex .setText(TiwulFXUtil.getLiteral("row.param", (page * maxResult.get() + t1.intValue() + 1))); } }); tblView.getFocusModel().focusedCellProperty().addListener(new ChangeListener<TablePosition>() { @Override public void changed(ObservableValue<? extends TablePosition> observable, TablePosition oldValue, TablePosition newValue) { if (tblView.isEditable() && directEdit && agileEditing.get()) { tblView.edit(newValue.getRow(), newValue.getTableColumn()); } } }); tblView.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ESCAPE) { directEdit = false; } else if (event.getCode() == KeyCode.ENTER && mode.get() == Mode.READ) { getController().doubleClick(getSelectionModel().getSelectedItem()); } } }); /** * Define policy for TAB key press */ tblView.addEventFilter(KeyEvent.KEY_PRESSED, tableKeyListener); /** * In INSERT mode, only inserted row that is focusable */ tblView.getFocusModel().focusedCellProperty().addListener(tableFocusListener); tblView.setOnMouseReleased(tableRightClickListener); if (Platform.isFxApplicationThread()) { cm = new ContextMenu(); cm.setAutoHide(true); setToolTips(); /** * create custom row factory that can intercept double click on grid row */ tblView.setRowFactory(new Callback<TableView<R>, TableRow<R>>() { @Override public TableRow<R> call(TableView<R> param) { return new TableRowControl(TableControl.this); } }); } columns.addListener(new ListChangeListener<TableColumn<R, ?>>() { @Override public void onChanged(ListChangeListener.Change<? extends TableColumn<R, ?>> change) { while (change.next()) { if (change.wasAdded()) { for (TableColumn<R, ?> column : change.getAddedSubList()) { initColumn(column); } } lastColumnIndex = getLeafColumns().size() - 1; } } }); attachWindowVisibilityListener(); }
From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java
private TableColumn<CSVRow, String> createColumn(int index) { TableColumn<CSVRow, String> col = new TableColumn<>((index + 1) + ""); col.setSortable(false);/*from w w w. j a va 2 s . co m*/ col.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<CSVRow, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(TableColumn.CellDataFeatures<CSVRow, String> param) { adjustColumns(param.getValue().getColumns()); return param.getValue().getColumns().get(index); } }); col.setCellFactory(TextFieldTableCell.forTableColumn()); col.setOnEditCommit(new EventHandler<CellEditEvent<CSVRow, String>>() { @Override public void handle(CellEditEvent<CSVRow, String> event) { adjustColumns(event.getRowValue().getColumns()); event.getRowValue().getColumns().get(index).set(event.getNewValue()); setNotSaved(); } }); col.setEditable(true); return col; }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
private void changeColumnTextColor(TableColumn column, Color color) { column.setCellFactory(new Callback<TableColumn, TableCell>() { public TableCell call(TableColumn param) { return new TableCell<ReportRow, String>() { @Override/* w w w . j av a 2 s. c o m*/ public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { this.setTextFill(color); setText(item); } } }; } }); }
From source file:frontend.GUIController.java
@Override public void initialize(URL url, ResourceBundle rb) throws IllegalArgumentException { at = new AnnotationTask(); comboBoxes = new ArrayList<ComboBox<String>>(); comboBoxes.add(combo1);//ww w . jav a 2s . c o m comboBoxes.add(combo3); comboBoxes.add(combo5); comboBoxes.add(combo7); comboBoxes.add(combo9); comboBoxes.add(combo2); comboBoxes.add(combo4); comboBoxes.add(combo6); comboBoxes.add(combo8); comboBoxes.add(combo10); for (int i = 0; i < comboBoxes.size(); i++) { comboBoxes.get(i).setPromptText("Choose one"); } predModel.getItems().add(MODELTYPE.SENTIMENT_WORD); predModel.getItems().add(MODELTYPE.CUSTOM); /* Handle ComboBox event. predModel.setOnAction((event) -> { if(predModel.getSelectionModel().getSelectedItem().equals(MODELTYPE.CUSTOM)){ System.out.println("ComboBox Action (selected: " + MODELTYPE.CUSTOM + ")"); try { this.selectModelFile(event); } catch (Exception e) { e.printStackTrace(); } } });//*/ //predModel.getItems().add(MODELTYPE.SENTIMENT); //predModel.getSelectionModel().selectFirst(); //progressBar = new ProgressIndicator(); // always use 'custom' config - what's in the config file! predModel.getSelectionModel().selectLast(); predModel.setDisable(true); // tabPane.prefWidthProperty().bind(scene.widthProperty()); // tabPane.prefHeightProperty().bind(scene.heightProperty()); tweetText.setCellValueFactory(new PropertyValueFactory<Tweet, String>("tweet")); tweetText.setCellFactory(new Callback<TableColumn<Tweet, String>, TableCell<Tweet, String>>() { @Override public TableCell<Tweet, String> call(TableColumn<Tweet, String> param) { final TableCell<Tweet, String> cell = new TableCell<Tweet, String>() { private Text text; @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { text = new Text(item.toString()); text.wrappingWidthProperty().bind(getTableColumn().widthProperty()); setGraphic(text); } } }; return cell; } }); tweetLabel.setCellValueFactory(new PropertyValueFactory<Tweet, LABEL>("label")); tweetLabel.setCellFactory(ComboBoxTableCell.<Tweet, LABEL>forTableColumn(LABEL.values())); tweetLabel.setEditable(true); // add here // // tweetLabel.setOnEditCommit( // (CellEditEvent<Tweet, LABEL> t) -> { // ((Tweet) t.getTableView().getItems().get( // t.getTablePosition().getRow()) // ).setLabel(t.getNewValue()); // }); tweetLabel.setOnEditCommit(event -> { @SuppressWarnings("rawtypes") final TableColumn.CellEditEvent _evn = (TableColumn.CellEditEvent) event; int rowId = _evn.getTablePosition().getRow(); String newVal = _evn.getNewValue().toString(); Tweet t = ((Tweet) _evn.getTableView().getItems().get(rowId)); t.setLabel(LABEL.getEnum(newVal)); System.out.println("Getting new value at row : " + rowId + " with label " + newVal); System.out.println("Tweet information : " + t.toString()); String[] meta = t.getMeta(); System.out.println(t.getTweet() + "\t" + meta[meta.length - 8]); System.out.println( personData.get(rowId).getTweet() + "\t" + personData.get(rowId).getMeta()[meta.length - 8]); }); tweetFeature.setCellValueFactory(new PropertyValueFactory<Tweet, String>("feature")); tweetProb.setCellValueFactory(new PropertyValueFactory<Tweet, Double>("probability")); dirChooser.setInitialDirectory(new File(System.getProperty("user.dir"))); /*tweetText.prefWidthProperty().bind(featureTable.widthProperty().divide(4)); // w * 2/4 tweetLabel.prefWidthProperty().bind(featureTable.widthProperty().divide(2)); // w * 1/4 tweetFeature.prefWidthProperty().bind(featureTable.widthProperty().divide(4)); // w * 1/4 */ }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addChartScore() { colScore.setCellFactory(new Callback<TableColumn<ReportRow, String>, TableCell<ReportRow, String>>() { @Override//from ww w.j a v a 2 s .co m public TableCell<ReportRow, String> call(TableColumn<ReportRow, String> param) { TableCell<ReportRow, String> cell = new TableCell<ReportRow, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { Double score = item.indexOf("%") < 0 || item.indexOf("?") >= 0 ? 0 : Double.parseDouble(item.substring(0, item.indexOf('%'))); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Correct", score), new PieChart.Data("Error", 100 - score)); PieChart chart = new PieChart(pieChartData); chart.setId("pie_chart"); chart.setMinSize(22, 22); chart.setMaxSize(22, 22); HBox box = new HBox(); box.setSpacing(8); box.setAlignment(Pos.CENTER_LEFT); Label score_label = new Label(item); score_label.setTextFill(Color.LIGHTGRAY); box.getChildren().add(chart); box.getChildren().add(score_label); setGraphic(box); } else { setGraphic(null); } } }; return cell; } }); }
From source file:Jigs_Desktop_Client.GUI.FXMLDocumentController.java
@Override public void initialize(URL url, ResourceBundle rb) { this.alert("resources/app_launch.mp3"); this.user_name.requestFocus(); this.btn_logout.setDisable(true); this.jc.setStatus(from_user, "online"); this.my_circle_list.setCellFactory(new Callback<ListView<UserStatus>, ListCell<UserStatus>>() { @Override/*from ww w. j a v a 2 s . c o m*/ public ListCell<UserStatus> call(ListView<UserStatus> userObj) { ListCell<UserStatus> cell = new ListCell<UserStatus>() { @Override protected void updateItem(UserStatus usrObj, boolean btnl) { super.updateItem(usrObj, btnl); if (usrObj != null) { String filename = usrObj.getStatus(); if (filename == null || filename.equals("") || filename.equals("null")) filename = "offline"; else System.out.println(filename); Image img = new Image( getClass().getResource("resources/" + filename + ".png").toExternalForm()); ImageView imv = new ImageView(img); setGraphic(imv); setText(usrObj.getUsername()); } } }; return cell; } }); this.main_panel.setBackground(Background.EMPTY); this.text_message.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { sendMessage(null); keyEvent.consume(); } } }); }