List of usage examples for javafx.event ActionEvent getSource
public Object getSource()
From source file:memoryaid.GalleryController.java
@FXML private void uploadImageAction(ActionEvent event) throws IOException { String imgPath = imagePathText.getText(); String baseName = FilenameUtils.getBaseName(imgPath); String destinationPath = "/Users/madhaviunnam/NetBeansProjects/MemoryAid/src/GalleryImages"; File destinationPathObject = new File(destinationPath + "/" + baseName + ".png"); File sourceFilePathObject = new File(imgPath); FileUtils.copyFile(sourceFilePathObject, destinationPathObject); Parent Gallery = FXMLLoader.load(getClass().getResource("Gallery1.fxml")); Scene Gallery_scene = new Scene(Gallery); Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); app_stage.hide();//w w w. j a v a 2 s . c o m app_stage.setScene(Gallery_scene); app_stage.show(); }
From source file:memoryaid.SetReminderController.java
@FXML private void handleUploadImageAction(ActionEvent event) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open Resource File"); File selectedImage = fileChooser.showOpenDialog((Stage) ((Node) event.getSource()).getScene().getWindow()); imagePathText.setText(selectedImage.getAbsolutePath()); }
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
private void handleSaveButton(ActionEvent event) { System.out.println("Event: " + event.getSource()); @SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) this.getTab().getUserData(); String path = map.get("path"); try {/*from w w w . j a va 2 s . co m*/ FileUtils.writeStringToFile(new File(path), caCodeArea.getText()); } catch (IOException e) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Unable to save file."); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Oeps an error occured"); alert.setHeaderText("Cannot save file. There went something wrong writing the file."); alert.setContentText( "Please verify that your file is not read only, is not locked by other user or program, you have enough diskspace."); alert.showAndWait(); } }
From source file:com.bekwam.resignator.SettingsController.java
@FXML public void save(ActionEvent evt) { if (logger.isDebugEnabled()) { logger.debug("[SAVE] saving configuration; jarsignerExec={}", activeConfiguration.jdkHomeProperty()); }//w w w .j a v a 2 s.com try { piSettings.setProgress(0.0d); piSettings.setVisible(true); piSettings.setProgress(0.3d); if (validateJDKHome(activeConfiguration.getJDKHome())) { piSettings.setProgress(0.4d); configurationDS.saveConfiguration(); piSettings.setProgress(0.6d); ((Button) evt.getSource()).getScene().getWindow().hide(); } else { // report error lblErrJDKHome.setVisible(true); // still dirty } piSettings.setVisible(false); } catch (IOException exc) { logger.error("error saving or setting jarsignerexec, exc"); String msg = exc.getMessage(); Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.setHeaderText("Can't save configuration"); alert.showAndWait(); } }
From source file:com.bekwam.resignator.PasswordController.java
@FXML public void ok(ActionEvent evt) { if (logger.isDebugEnabled()) { logger.debug("[OK]"); }//w w w.j a v a 2 s.c o m String tmpHash = hashUtils.hash(pfPassword.getText()); if (StringUtils.equalsIgnoreCase(tmpHash, activeConfiguration.getHashedPassword())) { if (logger.isDebugEnabled()) { logger.debug("[OK] password matches"); } exitCode = ExitCodeType.OK; passwordMatches.setValue(true); synchronized (this) { this.notify(); } ((Button) evt.getSource()).getScene().getWindow().hide(); } else { if (logger.isDebugEnabled()) { logger.debug("[OK] password does not match; numretries={}", numRetries); } if (numRetries >= MAX_NUM_RETRIES) { numRetries = 1; // reset the counter exitCode = ExitCodeType.MAX_RETRIES; passwordMatches.setValue(false); synchronized (this) { this.notify(); } ((Button) evt.getSource()).getScene().getWindow().hide(); } else { // allow for another attempt numRetries++; passwordMatches.setValue(false); if (!vboxContents.getChildren().contains(vboxErr)) { vboxContents.getChildren().add(vboxErr); } ((Button) evt.getSource()).getScene().getWindow().sizeToScene(); } } }
From source file:com.exalttech.trex.ui.views.PacketTableView.java
/** * Handle stream button click event//from w ww .ja v a 2s.c o m * * @param event */ @Override public void handle(ActionEvent event) { StreamTableButton source = (StreamTableButton) event.getSource(); handleStreamTableAction(source.getButtonActionType()); }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXEnumTagPickerPane.java
public CFBamJavaFXEnumTagPickerPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamEnumTagObj argFocus, ICFBamEnumDefObj argContainer, Collection<ICFBamEnumTagObj> argDataCollection, ICFBamJavaFXEnumTagChosen whenChosen) { super();// w w w .j a va2s .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"); } if (whenChosen == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 6, "whenChosen"); } invokeWhenChosen = whenChosen; // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. javafxSchema = argSchema; javaFXFocus = argFocus; javafxContainer = argContainer; setJavaFXDataCollection(argDataCollection); dataTable = new TableView<ICFBamEnumTagObj>(); tableColumnId = new TableColumn<ICFBamEnumTagObj, Long>("Id"); tableColumnId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamEnumTagObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamEnumTagObj, Long> p) { ICFBamEnumTagObj 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<ICFBamEnumTagObj, Long>, TableCell<ICFBamEnumTagObj, Long>>() { @Override public TableCell<ICFBamEnumTagObj, Long> call(TableColumn<ICFBamEnumTagObj, Long> arg) { return new CFInt64TableCell<ICFBamEnumTagObj>(); } }); dataTable.getColumns().add(tableColumnId); tableColumnEnumCode = new TableColumn<ICFBamEnumTagObj, Short>("EnumCode"); tableColumnEnumCode.setCellValueFactory( new Callback<CellDataFeatures<ICFBamEnumTagObj, Short>, ObservableValue<Short>>() { public ObservableValue<Short> call(CellDataFeatures<ICFBamEnumTagObj, Short> p) { ICFBamEnumTagObj obj = p.getValue(); if (obj == null) { return (null); } else { Short value = obj.getOptionalEnumCode(); ReadOnlyObjectWrapper<Short> observable = new ReadOnlyObjectWrapper<Short>(); observable.setValue(value); return (observable); } } }); tableColumnEnumCode.setCellFactory( new Callback<TableColumn<ICFBamEnumTagObj, Short>, TableCell<ICFBamEnumTagObj, Short>>() { @Override public TableCell<ICFBamEnumTagObj, Short> call(TableColumn<ICFBamEnumTagObj, Short> arg) { return new CFInt16TableCell<ICFBamEnumTagObj>(); } }); dataTable.getColumns().add(tableColumnEnumCode); tableColumnName = new TableColumn<ICFBamEnumTagObj, String>("Name"); tableColumnName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamEnumTagObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamEnumTagObj, String> p) { ICFBamEnumTagObj 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<ICFBamEnumTagObj, String>, TableCell<ICFBamEnumTagObj, String>>() { @Override public TableCell<ICFBamEnumTagObj, String> call(TableColumn<ICFBamEnumTagObj, String> arg) { return new CFStringTableCell<ICFBamEnumTagObj>(); } }); dataTable.getColumns().add(tableColumnName); tableColumnLookupDefSchema = new TableColumn<ICFBamEnumTagObj, ICFBamSchemaDefObj>( "Defining Schema Definition"); tableColumnLookupDefSchema.setCellValueFactory( new Callback<CellDataFeatures<ICFBamEnumTagObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() { public ObservableValue<ICFBamSchemaDefObj> call( CellDataFeatures<ICFBamEnumTagObj, ICFBamSchemaDefObj> p) { ICFBamEnumTagObj 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<ICFBamEnumTagObj, ICFBamSchemaDefObj>, TableCell<ICFBamEnumTagObj, ICFBamSchemaDefObj>>() { @Override public TableCell<ICFBamEnumTagObj, ICFBamSchemaDefObj> call( TableColumn<ICFBamEnumTagObj, ICFBamSchemaDefObj> arg) { return new CFReferenceTableCell<ICFBamEnumTagObj, ICFBamSchemaDefObj>(); } }); dataTable.getColumns().add(tableColumnLookupDefSchema); dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamEnumTagObj>() { @Override public void changed(ObservableValue<? extends ICFBamEnumTagObj> observable, ICFBamEnumTagObj oldValue, ICFBamEnumTagObj newValue) { setJavaFXFocus(newValue); if (buttonChooseSelected != null) { if (newValue != null) { buttonChooseSelected.setDisable(false); } else { buttonChooseSelected.setDisable(true); } } } }); hboxMenu = new CFHBox(10); buttonCancel = new CFButton(); buttonCancel.setMinWidth(200); buttonCancel.setText("Cancel"); buttonCancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonCancel); buttonChooseNone = new CFButton(); buttonChooseNone.setMinWidth(200); buttonChooseNone.setText("ChooseNone"); buttonChooseNone.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"); } invokeWhenChosen.choseEnumTag(null); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseNone); buttonChooseSelected = new CFButton(); buttonChooseSelected.setMinWidth(200); buttonChooseSelected.setText("ChooseSelected"); buttonChooseSelected.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"); } ICFBamEnumTagObj selectedInstance = getJavaFXFocusAsEnumTag(); invokeWhenChosen.choseEnumTag(selectedInstance); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseSelected); if (argFocus != null) { dataTable.getSelectionModel().select(argFocus); } setTop(hboxMenu); setCenter(dataTable); }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXDelTopDepPickerPane.java
public CFBamJavaFXDelTopDepPickerPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamDelTopDepObj argFocus, ICFBamTableObj argContainer, Collection<ICFBamDelTopDepObj> argDataCollection, ICFBamJavaFXDelTopDepChosen whenChosen) { super();/* w w w . j av a 2 s. co 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"); } if (whenChosen == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 6, "whenChosen"); } invokeWhenChosen = whenChosen; // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. javafxSchema = argSchema; javaFXFocus = argFocus; javafxContainer = argContainer; setJavaFXDataCollection(argDataCollection); dataTable = new TableView<ICFBamDelTopDepObj>(); tableColumnId = new TableColumn<ICFBamDelTopDepObj, Long>("Id"); tableColumnId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamDelTopDepObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamDelTopDepObj, Long> p) { ICFBamScopeObj 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<ICFBamDelTopDepObj, Long>, TableCell<ICFBamDelTopDepObj, Long>>() { @Override public TableCell<ICFBamDelTopDepObj, Long> call(TableColumn<ICFBamDelTopDepObj, Long> arg) { return new CFInt64TableCell<ICFBamDelTopDepObj>(); } }); dataTable.getColumns().add(tableColumnId); tableColumnName = new TableColumn<ICFBamDelTopDepObj, String>("Name"); tableColumnName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamDelTopDepObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamDelTopDepObj, String> p) { ICFBamDelTopDepObj 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<ICFBamDelTopDepObj, String>, TableCell<ICFBamDelTopDepObj, String>>() { @Override public TableCell<ICFBamDelTopDepObj, String> call(TableColumn<ICFBamDelTopDepObj, String> arg) { return new CFStringTableCell<ICFBamDelTopDepObj>(); } }); dataTable.getColumns().add(tableColumnName); tableColumnLookupRelation = new TableColumn<ICFBamDelTopDepObj, ICFBamRelationObj>("Relation"); tableColumnLookupRelation.setCellValueFactory( new Callback<CellDataFeatures<ICFBamDelTopDepObj, ICFBamRelationObj>, ObservableValue<ICFBamRelationObj>>() { public ObservableValue<ICFBamRelationObj> call( CellDataFeatures<ICFBamDelTopDepObj, ICFBamRelationObj> p) { ICFBamDelTopDepObj obj = p.getValue(); if (obj == null) { return (null); } else { ICFBamRelationObj ref = obj.getRequiredLookupRelation(); ReadOnlyObjectWrapper<ICFBamRelationObj> observable = new ReadOnlyObjectWrapper<ICFBamRelationObj>(); observable.setValue(ref); return (observable); } } }); tableColumnLookupRelation.setCellFactory( new Callback<TableColumn<ICFBamDelTopDepObj, ICFBamRelationObj>, TableCell<ICFBamDelTopDepObj, ICFBamRelationObj>>() { @Override public TableCell<ICFBamDelTopDepObj, ICFBamRelationObj> call( TableColumn<ICFBamDelTopDepObj, ICFBamRelationObj> arg) { return new CFReferenceTableCell<ICFBamDelTopDepObj, ICFBamRelationObj>(); } }); dataTable.getColumns().add(tableColumnLookupRelation); tableColumnLookupDefSchema = new TableColumn<ICFBamDelTopDepObj, ICFBamSchemaDefObj>( "Defining Schema Definition"); tableColumnLookupDefSchema.setCellValueFactory( new Callback<CellDataFeatures<ICFBamDelTopDepObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() { public ObservableValue<ICFBamSchemaDefObj> call( CellDataFeatures<ICFBamDelTopDepObj, ICFBamSchemaDefObj> p) { ICFBamDelTopDepObj 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<ICFBamDelTopDepObj, ICFBamSchemaDefObj>, TableCell<ICFBamDelTopDepObj, ICFBamSchemaDefObj>>() { @Override public TableCell<ICFBamDelTopDepObj, ICFBamSchemaDefObj> call( TableColumn<ICFBamDelTopDepObj, ICFBamSchemaDefObj> arg) { return new CFReferenceTableCell<ICFBamDelTopDepObj, ICFBamSchemaDefObj>(); } }); dataTable.getColumns().add(tableColumnLookupDefSchema); dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamDelTopDepObj>() { @Override public void changed(ObservableValue<? extends ICFBamDelTopDepObj> observable, ICFBamDelTopDepObj oldValue, ICFBamDelTopDepObj newValue) { setJavaFXFocus(newValue); if (buttonChooseSelected != null) { if (newValue != null) { buttonChooseSelected.setDisable(false); } else { buttonChooseSelected.setDisable(true); } } } }); hboxMenu = new CFHBox(10); buttonCancel = new CFButton(); buttonCancel.setMinWidth(200); buttonCancel.setText("Cancel"); buttonCancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonCancel); buttonChooseNone = new CFButton(); buttonChooseNone.setMinWidth(200); buttonChooseNone.setText("ChooseNone"); buttonChooseNone.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"); } invokeWhenChosen.choseDelTopDep(null); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseNone); buttonChooseSelected = new CFButton(); buttonChooseSelected.setMinWidth(200); buttonChooseSelected.setText("ChooseSelected"); buttonChooseSelected.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"); } ICFBamDelTopDepObj selectedInstance = getJavaFXFocusAsDelTopDep(); invokeWhenChosen.choseDelTopDep(selectedInstance); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseSelected); if (argFocus != null) { dataTable.getSelectionModel().select(argFocus); } setTop(hboxMenu); setCenter(dataTable); }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXPopTopDepPickerPane.java
public CFBamJavaFXPopTopDepPickerPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamPopTopDepObj argFocus, ICFBamRelationObj argContainer, Collection<ICFBamPopTopDepObj> argDataCollection, ICFBamJavaFXPopTopDepChosen whenChosen) { super();//from ww w.ja v a 2 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"); } if (whenChosen == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 6, "whenChosen"); } invokeWhenChosen = whenChosen; // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. javafxSchema = argSchema; javaFXFocus = argFocus; javafxContainer = argContainer; setJavaFXDataCollection(argDataCollection); dataTable = new TableView<ICFBamPopTopDepObj>(); tableColumnId = new TableColumn<ICFBamPopTopDepObj, Long>("Id"); tableColumnId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamPopTopDepObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamPopTopDepObj, Long> p) { ICFBamScopeObj 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<ICFBamPopTopDepObj, Long>, TableCell<ICFBamPopTopDepObj, Long>>() { @Override public TableCell<ICFBamPopTopDepObj, Long> call(TableColumn<ICFBamPopTopDepObj, Long> arg) { return new CFInt64TableCell<ICFBamPopTopDepObj>(); } }); dataTable.getColumns().add(tableColumnId); tableColumnName = new TableColumn<ICFBamPopTopDepObj, String>("Name"); tableColumnName.setCellValueFactory( new Callback<CellDataFeatures<ICFBamPopTopDepObj, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ICFBamPopTopDepObj, String> p) { ICFBamPopTopDepObj 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<ICFBamPopTopDepObj, String>, TableCell<ICFBamPopTopDepObj, String>>() { @Override public TableCell<ICFBamPopTopDepObj, String> call(TableColumn<ICFBamPopTopDepObj, String> arg) { return new CFStringTableCell<ICFBamPopTopDepObj>(); } }); dataTable.getColumns().add(tableColumnName); tableColumnLookupRelation = new TableColumn<ICFBamPopTopDepObj, ICFBamRelationObj>("Relation"); tableColumnLookupRelation.setCellValueFactory( new Callback<CellDataFeatures<ICFBamPopTopDepObj, ICFBamRelationObj>, ObservableValue<ICFBamRelationObj>>() { public ObservableValue<ICFBamRelationObj> call( CellDataFeatures<ICFBamPopTopDepObj, ICFBamRelationObj> p) { ICFBamPopTopDepObj obj = p.getValue(); if (obj == null) { return (null); } else { ICFBamRelationObj ref = obj.getRequiredLookupRelation(); ReadOnlyObjectWrapper<ICFBamRelationObj> observable = new ReadOnlyObjectWrapper<ICFBamRelationObj>(); observable.setValue(ref); return (observable); } } }); tableColumnLookupRelation.setCellFactory( new Callback<TableColumn<ICFBamPopTopDepObj, ICFBamRelationObj>, TableCell<ICFBamPopTopDepObj, ICFBamRelationObj>>() { @Override public TableCell<ICFBamPopTopDepObj, ICFBamRelationObj> call( TableColumn<ICFBamPopTopDepObj, ICFBamRelationObj> arg) { return new CFReferenceTableCell<ICFBamPopTopDepObj, ICFBamRelationObj>(); } }); dataTable.getColumns().add(tableColumnLookupRelation); tableColumnLookupDefSchema = new TableColumn<ICFBamPopTopDepObj, ICFBamSchemaDefObj>( "Defining Schema Definition"); tableColumnLookupDefSchema.setCellValueFactory( new Callback<CellDataFeatures<ICFBamPopTopDepObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() { public ObservableValue<ICFBamSchemaDefObj> call( CellDataFeatures<ICFBamPopTopDepObj, ICFBamSchemaDefObj> p) { ICFBamPopTopDepObj 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<ICFBamPopTopDepObj, ICFBamSchemaDefObj>, TableCell<ICFBamPopTopDepObj, ICFBamSchemaDefObj>>() { @Override public TableCell<ICFBamPopTopDepObj, ICFBamSchemaDefObj> call( TableColumn<ICFBamPopTopDepObj, ICFBamSchemaDefObj> arg) { return new CFReferenceTableCell<ICFBamPopTopDepObj, ICFBamSchemaDefObj>(); } }); dataTable.getColumns().add(tableColumnLookupDefSchema); dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamPopTopDepObj>() { @Override public void changed(ObservableValue<? extends ICFBamPopTopDepObj> observable, ICFBamPopTopDepObj oldValue, ICFBamPopTopDepObj newValue) { setJavaFXFocus(newValue); if (buttonChooseSelected != null) { if (newValue != null) { buttonChooseSelected.setDisable(false); } else { buttonChooseSelected.setDisable(true); } } } }); hboxMenu = new CFHBox(10); buttonCancel = new CFButton(); buttonCancel.setMinWidth(200); buttonCancel.setText("Cancel"); buttonCancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonCancel); buttonChooseNone = new CFButton(); buttonChooseNone.setMinWidth(200); buttonChooseNone.setText("ChooseNone"); buttonChooseNone.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"); } invokeWhenChosen.chosePopTopDep(null); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseNone); buttonChooseSelected = new CFButton(); buttonChooseSelected.setMinWidth(200); buttonChooseSelected.setText("ChooseSelected"); buttonChooseSelected.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"); } ICFBamPopTopDepObj selectedInstance = getJavaFXFocusAsPopTopDep(); invokeWhenChosen.chosePopTopDep(selectedInstance); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseSelected); if (argFocus != null) { dataTable.getSelectionModel().select(argFocus); } setTop(hboxMenu); setCenter(dataTable); }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXClearDepPickerPane.java
public CFBamJavaFXClearDepPickerPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamClearDepObj argFocus, ICFLibAnyObj argContainer, Collection<ICFBamClearDepObj> argDataCollection, ICFBamJavaFXClearDepChosen whenChosen) { super();//from ww w. j a 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"); } if (whenChosen == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 6, "whenChosen"); } invokeWhenChosen = whenChosen; // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. javafxSchema = argSchema; javaFXFocus = argFocus; javafxContainer = argContainer; setJavaFXDataCollection(argDataCollection); dataTable = new TableView<ICFBamClearDepObj>(); tableColumnObjKind = new TableColumn<ICFBamClearDepObj, String>("Class Code"); tableColumnObjKind.setCellValueFactory( new Callback<CellDataFeatures<ICFBamClearDepObj, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ICFBamClearDepObj, String> p) { ICFBamClearDepObj 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<ICFBamClearDepObj, String>, TableCell<ICFBamClearDepObj, String>>() { @Override public TableCell<ICFBamClearDepObj, String> call(TableColumn<ICFBamClearDepObj, String> arg) { return new CFStringTableCell<ICFBamClearDepObj>(); } }); dataTable.getColumns().add(tableColumnObjKind); tableColumnId = new TableColumn<ICFBamClearDepObj, Long>("Id"); tableColumnId.setCellValueFactory( new Callback<CellDataFeatures<ICFBamClearDepObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamClearDepObj, Long> p) { ICFBamScopeObj 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<ICFBamClearDepObj, Long>, TableCell<ICFBamClearDepObj, Long>>() { @Override public TableCell<ICFBamClearDepObj, Long> call(TableColumn<ICFBamClearDepObj, Long> arg) { return new CFInt64TableCell<ICFBamClearDepObj>(); } }); dataTable.getColumns().add(tableColumnId); tableColumnLookupRelation = new TableColumn<ICFBamClearDepObj, ICFBamRelationObj>("Relation"); tableColumnLookupRelation.setCellValueFactory( new Callback<CellDataFeatures<ICFBamClearDepObj, ICFBamRelationObj>, ObservableValue<ICFBamRelationObj>>() { public ObservableValue<ICFBamRelationObj> call( CellDataFeatures<ICFBamClearDepObj, ICFBamRelationObj> p) { ICFBamClearDepObj obj = p.getValue(); if (obj == null) { return (null); } else { ICFBamRelationObj ref = obj.getRequiredLookupRelation(); ReadOnlyObjectWrapper<ICFBamRelationObj> observable = new ReadOnlyObjectWrapper<ICFBamRelationObj>(); observable.setValue(ref); return (observable); } } }); tableColumnLookupRelation.setCellFactory( new Callback<TableColumn<ICFBamClearDepObj, ICFBamRelationObj>, TableCell<ICFBamClearDepObj, ICFBamRelationObj>>() { @Override public TableCell<ICFBamClearDepObj, ICFBamRelationObj> call( TableColumn<ICFBamClearDepObj, ICFBamRelationObj> arg) { return new CFReferenceTableCell<ICFBamClearDepObj, ICFBamRelationObj>(); } }); dataTable.getColumns().add(tableColumnLookupRelation); tableColumnLookupDefSchema = new TableColumn<ICFBamClearDepObj, ICFBamSchemaDefObj>( "Defining Schema Definition"); tableColumnLookupDefSchema.setCellValueFactory( new Callback<CellDataFeatures<ICFBamClearDepObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() { public ObservableValue<ICFBamSchemaDefObj> call( CellDataFeatures<ICFBamClearDepObj, ICFBamSchemaDefObj> p) { ICFBamClearDepObj 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<ICFBamClearDepObj, ICFBamSchemaDefObj>, TableCell<ICFBamClearDepObj, ICFBamSchemaDefObj>>() { @Override public TableCell<ICFBamClearDepObj, ICFBamSchemaDefObj> call( TableColumn<ICFBamClearDepObj, ICFBamSchemaDefObj> arg) { return new CFReferenceTableCell<ICFBamClearDepObj, ICFBamSchemaDefObj>(); } }); dataTable.getColumns().add(tableColumnLookupDefSchema); dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamClearDepObj>() { @Override public void changed(ObservableValue<? extends ICFBamClearDepObj> observable, ICFBamClearDepObj oldValue, ICFBamClearDepObj newValue) { setJavaFXFocus(newValue); if (buttonChooseSelected != null) { if (newValue != null) { buttonChooseSelected.setDisable(false); } else { buttonChooseSelected.setDisable(true); } } } }); hboxMenu = new CFHBox(10); buttonCancel = new CFButton(); buttonCancel.setMinWidth(200); buttonCancel.setText("Cancel"); buttonCancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { final String S_ProcName = "handle"; try { cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonCancel); buttonChooseNone = new CFButton(); buttonChooseNone.setMinWidth(200); buttonChooseNone.setText("ChooseNone"); buttonChooseNone.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"); } invokeWhenChosen.choseClearDep(null); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseNone); buttonChooseSelected = new CFButton(); buttonChooseSelected.setMinWidth(200); buttonChooseSelected.setText("ChooseSelected"); buttonChooseSelected.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"); } ICFBamClearDepObj selectedInstance = getJavaFXFocusAsClearDep(); invokeWhenChosen.choseClearDep(selectedInstance); cfFormManager.closeCurrentForm(); } catch (Throwable t) { CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t); } } }); hboxMenu.getChildren().add(buttonChooseSelected); if (argFocus != null) { dataTable.getSelectionModel().select(argFocus); } setTop(hboxMenu); setCenter(dataTable); }