List of usage examples for javafx.event EventHandler EventHandler
EventHandler
From source file:org.yccheok.jstock.gui.news.StockNewsJFrame.java
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setAlwaysOnTop(true);/*from w w w. j a v a 2 s . c om*/ setAutoRequestFocus(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { } public void windowClosing(java.awt.event.WindowEvent evt) { NewsTask task = StockNewsJFrame.this.newsTask; if (task != null) { task.cancel(true); } } public void windowDeiconified(java.awt.event.WindowEvent evt) { } public void windowIconified(java.awt.event.WindowEvent evt) { } }); Platform.runLater(new Runnable() { @Override public void run() { // JFXPanel => Scene => SplitPane: // Left (news List) => StackPane => ListView / ProgressIndicator // Right (HTML content) => TabPane => Tab => StackPane => WebView / ProgressBar splitPane = new SplitPane(); scene = new Scene(splitPane); scene.getStylesheets() .add(StockNewsJFrame.class.getResource("StockNewsJFrame.css").toExternalForm()); jfxPanel.setScene(scene); // Left component: News List messages_o = FXCollections.observableArrayList(); newsListView = new ListView<>(messages_o); newsListView.setId("news-listview"); stackPane.setId("parent-stackPane"); stackPane.getChildren().addAll(newsListView, progressIn); splitPane.getItems().add(stackPane); SplitPane.setResizableWithParent(stackPane, Boolean.FALSE); // show progress indicator when loading progressIn.setMaxWidth(100); progressIn.setMaxHeight(100); progressIn.setVisible(true); newsListView.setVisible(true); newsListView.setCellFactory(new Callback<ListView<FeedItem>, ListCell<FeedItem>>() { @Override public ListCell<FeedItem> call(ListView<FeedItem> list) { return new DisplayNewsCard(); } }); // register event listener: add tab for news HTML content newsListView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() >= 1) { final FeedItem msg = newsListView.getSelectionModel().getSelectedItem(); if (msg == null) { return; } final URL link = msg.getLink(); if (link == null || link.getHost() == null) { return; } if (stockNewsContent == null) { stackPane.setPrefWidth(stackPane.getWidth()); stackPane.setMaxWidth(stackPane.getWidth()); stackPane.setMinWidth(stackPane.getWidth() / 5); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // resize JFrame first StockNewsJFrame.this.setSize(fullSize.width, fullSize.height); java.awt.Insets in = StockNewsJFrame.this.getInsets(); jfxPanel.setSize(StockNewsJFrame.this.getWidth() - in.left - in.right, jfxPanel.getHeight()); java.awt.Insets in2 = jfxPanel.getInsets(); // calculate width & height, but not resize in AWT event dispatching thread // javafx.scene.control.SplitPane should only be accessed from JavaFX Application Thread splitPaneWidth = jfxPanel.getWidth() - in2.left - in2.right; splitPaneHeight = jfxPanel.getHeight() - in2.top - in2.bottom; } }); } catch (InterruptedException | InvocationTargetException ex) { log.error(null, ex); } // resize to full screen size of jfxPanel splitPane.resize(splitPaneWidth, splitPaneHeight); stockNewsContent = new StockNewsContent(); splitPane.getItems().add(stockNewsContent.tabPane); splitPane.setDividerPositions(0.5f); stockNewsContent.tabPane.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<Tab>() { @Override public void changed(ObservableValue<? extends Tab> observable, Tab oldTab, Tab newTab) { int i = stockNewsContent.tabPane.getSelectionModel() .getSelectedIndex(); if (i < 0) { return; } jFrameTitle = stockNewsContent.tabsInfo.get(i).second; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { StockNewsJFrame.this.setTitle(jFrameTitle); } }); } }); } stockNewsContent.addNewsTab(link, StringEscapeUtils.unescapeHtml(msg.getTitle())); } } }); retrieveNewsInBackground(); } }); this.add(jfxPanel, BorderLayout.CENTER); this.setVisible(true); }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;/*from w ww. j av a2s .c o m*/ final GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); TableView tv = new TableView(); final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name"); final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount"); final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove"); firstDataColumn.setMinWidth(130); secondDataColumn.setMinWidth(130); thirdDataColumn.setMinWidth(130); if (!pfname.equals("")) { firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey)); rows = 0; tv = new TableView<>(generateDataInMap(pfname, addPairs)); } tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn); // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn()); ScrollPane sp = new ScrollPane(); sp.setMinWidth(400); sp.setHbarPolicy(ScrollBarPolicy.NEVER); sp.setContent(tv); grid.add(sp, 0, 3); final ComboBox comboBox = new ComboBox(); HBox hb1 = new HBox(); comboBox.setValue("FILE"); comboBox.getItems().addAll("Save this file", "Load a new file"); Button btnOk = new Button(); btnOk.setText("OK"); hb1.getChildren().addAll(comboBox, btnOk); hb1.setSpacing(10); grid.add(hb1, 0, 1); Label label1 = new Label("Title:"); final TextField tfFilename = new TextField(); tfFilename.setText(getTitle(pfname)); HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); grid.add(hb, 0, 2); final Stage ps = new Stage(); final TableView tv1 = tv; btnOk.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (comboBox.getValue().equals("Load a new file")) { first(ps); st.close(); } else { PrintWriter pw = null; try { pw = new PrintWriter("abc.json"); BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false)); bw.write("{title:\"" + tfFilename.getText() + "\""); bw.write(",fruits:["); for (int i = 0; i < rows; i++) { bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:" + String.valueOf(secondDataColumn.getCellData(i)) + "}"); if (i != rows - 1) bw.write(","); } bw.write("]}"); bw.close(); } catch (Exception e) { System.out.println(e.toString()); } } } }); Button btn = new Button(); btn.setText("New Fruit"); grid.add(btn, 1, 2); // TableView tv=new TableView(); // TableColumn Col1 = new TableColumn("Name"); // TableColumn Col2 = new TableColumn("Amount"); // TableColumn Col3 = new TableColumn("Remove"); // tv.getColumns().addAll(Col1, Col2, Col3); //sp.setFitToWidth(true); Image img = new Image("file:music.jpg"); ImageView iv2 = new ImageView(); iv2.setImage(img); iv2.setFitWidth(200); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); grid.add(iv2, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); System.out.println(comboBox.valueProperty()); st.close(); third(pfname); } }); scene = new Scene(grid, 700, 450); st.setScene(scene); st.show(); }
From source file:io.uploader.drive.DriveUploader.java
private static void authorize(final Browser browser, final Callback<Credential> callback) { try {/*from www.jav a 2s . co m*/ // load client secrets GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(AuthenticationSettingsImpl.getClientSecretJson())); if (clientSecrets.getDetails().getClientId().startsWith("Enter") || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { System.out.println( "Overwrite the src/main/resources/client_secrets.json file with the client secrets file " + "you downloaded from the Quickstart tool or manually enter your Client ID and Secret " + "from https://code.google.com/apis/console/?api=drive#project:94720202188 " + "into src/main/resources/client_secrets.json"); System.exit(1); } Configuration.INSTANCE.setAuthenticationSettingsImpl(new AuthenticationSettingsImpl(clientSecrets)); // Set up authorization code flow. Set<String> scopes = new HashSet<String>(); scopes.add(DriveScopes.DRIVE); // old api for large file support (where upload takes more than one hour) scopes.add("https://docs.google.com/feeds"); final GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, JSON_FACTORY, clientSecrets, scopes).setDataStoreFactory(dataStoreFactory) .setAccessType("offline").setApprovalPrompt("force").build(); // authorize final VerificationCodeReceiver receiver = new LocalServerReceiver(); ObserverService<Credential> service = new ObserverService<Credential>() { private volatile DriveUploaderAuthorizationCodeInstalledApp driveUploaderAuthorizationCodeInstalledApp = null; @Override protected Task<Credential> createTask() { Task<Credential> task = new Task<Credential>() { @Override protected Credential call() throws Exception { driveUploaderAuthorizationCodeInstalledApp = new DriveUploaderAuthorizationCodeInstalledApp( flow, receiver, browser); Credential credential = driveUploaderAuthorizationCodeInstalledApp.authorize("user"); return credential; } }; return task; } }; service.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { logger.info("Login success"); Credential ret = (Credential) t.getSource().getValue(); callback.onSuccess(ret); } }); appEvent.addObserver(service); service.start(); } catch (Exception e) { callback.onFailure(e); } }
From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignView.java
@PostConstruct public void onPostConstructComponent(FXComponentLayout layout, ResourceBundle resourceBundle) { // Set model and controller setModel(new DessignModel()); setController(new DessignController()); getController().setResourcebundle(bundle); // Add input types if (comboChoice.getItems().size() < 2) { comboChoice.setCursor(Cursor.HAND); comboChoice.setPrefWidth(10.0);//from w ww . ja v a 2 s . c o m comboChoice.setMaxWidth(10.0); comboChoice.setMinWidth(10.0); comboChoice.getItems().add(bundle.getString("comboFile")); comboChoice.getItems().add(bundle.getString("comboFolder")); comboChoice.getItems().add(bundle.getString("comboTreeview")); comboChoice.setValue(bundle.getString("comboFile")); } NodeUtil.hideNode(recursiveCheck); // Add TreeView addTreeView(); NodeUtil.hideNode(treeViewHBox); NodeUtil.hideNode(reloadButton); // Loading available conformances available = false; NodeUtil.hideNode(vboxAvailable); comboChoice.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { comboChoice.requestFocus(); } }); // Label label = new Label(bundle.getString("loadingAvailableCC")); // label.getStyleClass().add("lightgrey"); // flowPane.getChildren().add(label); }
From source file:com.github.technosf.posterer.controllers.impl.RequestController.java
/** * {@inheritDoc}/*from w w w .j a v a2 s . c o m*/ * * @see com.github.technosf.posterer.controllers.Controller#initialize() */ @Override public void initialize() { logger.debug("Initialization starts"); statusController = StatusController.loadController(statusWindow.textProperty()); certificateFileChooser.setRoot(getRoot()); certificateFileChooser.getChosenFileProperty().addListener(new ChangeListener<File>() { @Override public void changed(ObservableValue<? extends File> arg0, File oldValue, File newValue) { setCertificateFile(newValue); } }); propertiesTable.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() > 1 && event.getButton().ordinal() == 1) { loadRequest(propertiesTable.getSelectionModel().getSelectedItem()); } } }); propertiesTable.setItems(properties); endpointColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("endpoint")); payloadColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("payload")); methodColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("method")); contentTypeColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("contentType")); base64Column.setCellValueFactory(new PropertyValueFactory<RequestData, Boolean>("base64")); httpUserColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("httpUser")); httpPasswordColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("httpPassword")); processProperties(); /* * Bindings */ timeoutText.textProperty().bind(timeout.asString("%d")); timeout.bind(timeoutSlider.valueProperty()); useProxy.bindBidirectional(proxyToggle1.selectedProperty()); useProxy.bindBidirectional(proxyToggle2.selectedProperty()); useProxy.bindBidirectional(proxyToggle3.selectedProperty()); useProxy.bindBidirectional(proxyToggle4.selectedProperty()); useProxy.bindBidirectional(proxyToggle5.selectedProperty()); proxyToggle1.textProperty().bind(useProxyText); proxyToggle2.textProperty().bind(useProxyText); proxyToggle3.textProperty().bind(useProxyText); proxyToggle4.textProperty().bind(useProxyText); proxyToggle5.textProperty().bind(useProxyText); proxyportlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxyuserlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxypasswordlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxyhost.disableProperty().bind(useProxy.not()); proxyport.disableProperty().bind(useProxy.not()); proxyuser.disableProperty().bind(useProxy.not()); proxypassword.disableProperty().bind(useProxy.not()); /* * Preferences */ proxyhost.textProperty().set(requestModel.getProxyHost()); proxyport.textProperty().set(requestModel.getProxyPort()); proxyuser.textProperty().set(requestModel.getProxyUser()); proxypassword.textProperty().set(requestModel.getProxyPass()); try { homedir.textProperty().set(propertiesModel.getPropertiesDir()); } catch (IOException e) { store.setDisable(true); statusController.setStatus(INFO_PROPERTIES, e.getMessage()); } logger.debug("Initialization complete"); }
From source file:statos2_0.StatOS2_0.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); GridPane root = new GridPane(); Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); root.setAlignment(Pos.CENTER);/*from www . j a v a 2s. c o m*/ root.setHgap(10); root.setVgap(10); root.setPadding(new Insets(25, 25, 25, 25)); Text scenetitle = new Text(""); root.add(scenetitle, 0, 0, 2, 1); scenetitle.setId("welcome-text"); Label userName = new Label(":"); //userName.setId("label"); root.add(userName, 0, 1); TextField userTextField = new TextField(); root.add(userTextField, 1, 1); Label pw = new Label(":"); root.add(pw, 0, 2); PasswordField pwBox = new PasswordField(); root.add(pwBox, 1, 2); ComboBox store = new ComboBox(); store.setItems(GetByTag()); root.add(store, 1, 3); Button btn = new Button(""); //btn.setPrefSize(100, 20); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); root.add(hbBtn, 1, 4); Button btn2 = new Button(""); //btn2.setPrefSize(100, 20); HBox hbBtn2 = new HBox(10); hbBtn2.setAlignment(Pos.BOTTOM_RIGHT); hbBtn2.getChildren().add(btn2); root.add(hbBtn2, 1, 5); final Text actiontarget = new Text(); root.add(actiontarget, 1, 6); btn2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.exit(0); } }); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (userTextField.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (pwBox.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (store.getSelectionModel().getSelectedIndex() < 0) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { try { String[] resu = checkpas(userTextField.getText(), pwBox.getText()); if (resu[0].equals("-1")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !" + "\n - "); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } else { // ... user chose CANCEL or closed the dialog } } else { // idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } } catch (NoSuchAlgorithmException ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } } /** * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){ * actiontarget.setId("acttrue"); * actiontarget.setText(" !"); * MainA ma = new MainA(); * ma.m=1; * try { * ma.m=1; * ma.MT="m1"; * ma.start(primaryStage); * } catch (Exception ex) { * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); * } * }else{ * actiontarget.setId("actfalse"); * actiontarget.setText(" !"); * } **/ } }); //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); //sSize.getHeight(); Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight()); primaryStage.setScene(scene); scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm()); primaryStage.show(); }
From source file:com.exalttech.trex.ui.views.PacketTableView.java
/** * Build component UI/*from w ww .jav a 2 s . c o m*/ */ private void buildUI(boolean addExportToYamlBtn) { setTopAnchor(this, 0d); setLeftAnchor(this, 0d); setBottomAnchor(this, 0d); setRightAnchor(this, 0d); // build btn bar HBox buttonContainer = new HBox(); buttonContainer.setSpacing(5); addPacketBtn = new StreamTableButton(StreamTableAction.ADD); initializeStreamButtons(addPacketBtn, false); buttonContainer.getChildren().add(addPacketBtn); // add build stream btn buildPacketBtn = new StreamTableButton(StreamTableAction.BUILD); buildPacketBtn.setId("buildStreamBtn"); initializeStreamButtons(buildPacketBtn, false); buttonContainer.getChildren().add(buildPacketBtn); editPacketBtn = new StreamTableButton(StreamTableAction.EDIT); editPacketBtn.setId("editStreanBtn"); initializeStreamButtons(editPacketBtn, true); buttonContainer.getChildren().add(editPacketBtn); deleteButtonBtn = new StreamTableButton(StreamTableAction.DELETE); initializeStreamButtons(deleteButtonBtn, true); buttonContainer.getChildren().add(deleteButtonBtn); importPcapButton = new StreamTableButton(StreamTableAction.IMPORT_PCAP); initializeStreamButtons(importPcapButton, false); buttonContainer.getChildren().add(importPcapButton); exportPcapButton = new StreamTableButton(StreamTableAction.EXPORT_TO_PCAP); initializeStreamButtons(exportPcapButton, true); buttonContainer.getChildren().add(exportPcapButton); if (addExportToYamlBtn) { exportToYaml = new StreamTableButton(StreamTableAction.EXPORT_TO_YAML); initializeStreamButtons(exportToYaml, false); buttonContainer.getChildren().add(exportToYaml); } getChildren().add(buttonContainer); setTopAnchor(buttonContainer, 5d); rightClickMenu = new ContextMenu(); addMenuItem(StreamTableAction.EDIT); addMenuItem(StreamTableAction.DELETE); addMenuItem(StreamTableAction.EXPORT_TO_PCAP); addMenuItem(StreamTableAction.EXPORT_TO_YAML); // add table view streamPacketTableView = new TableView<>(); streamPacketTableView.setId("streamTableView"); streamPacketTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); streamPacketTableView.setFixedCellSize(32); streamPacketTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); streamPacketTableView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { handleTableRowClick(event); } }); streamPacketTableView.getSelectionModel().selectedItemProperty() .addListener((ObservableValue<? extends TableProfileStream> observable, TableProfileStream oldValue, TableProfileStream newValue) -> { boolean notSelected = !(newValue != null); exportPcapButton.setDisable(notSelected); editPacketBtn.setDisable(notSelected); deleteButtonBtn.setDisable(notSelected); }); streamPacketTableView.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> { if (copyCombination.match(event)) { selectedProfile = tabledata.getProfiles() .get(streamPacketTableView.getSelectionModel().getSelectedIndex()); } else if (pasteCombination.match(event)) { handleDuplicateStream(); } else if (event.getCode() == KeyCode.DELETE) { handleDeletePacket(); } }); streamPacketTableView.setEditable(true); initializeTableColumn(); // disable table reordering streamPacketTableView.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> source, Number oldWidth, Number newWidth) { TableHeaderRow header = (TableHeaderRow) streamPacketTableView.lookup("TableHeaderRow"); header.reorderingProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { header.setReordering(false); } }); } }); getChildren().add(streamPacketTableView); setTopAnchor(streamPacketTableView, 35d); setBottomAnchor(streamPacketTableView, 5d); setLeftAnchor(streamPacketTableView, 0d); setRightAnchor(streamPacketTableView, 0d); }
From source file:ch.unibas.fittingwizard.presentation.fitting.FitResultPage.java
@Override protected void fillButtonBar() { backButton = ButtonFactory.createButtonBarButton("Go back to molecule list", new EventHandler<ActionEvent>() { @Override//from w w w .j av a2 s . c o m public void handle(ActionEvent actionEvent) { logger.info("Going back to molecule list."); navigateTo(MoleculeListPage.class); } }); addButtonToButtonBar(backButton); exportButton = ButtonFactory.createButtonBarButton("Export data", new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { logger.info("Exporting data."); exportFitData(); } }); // exportButton.setDisable(true); addButtonToButtonBar(exportButton); Settings settings = Settings.loadConfig(); if (settings.getValue("mocks.enabled").equals("false") && VmdRunner.isAvailable() /*&& FieldcompRunner.isAvailable(settings.getScriptsDir())*/) { vmdButton = ButtonFactory.createButtonBarButton("Show in VMD", new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { logger.info("Show in VMD."); showInVmd(); } }); addButtonToButtonBar(vmdButton); } anotherFit = ButtonFactory.createButtonBarButton("Do another fit", new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { logger.info("Going for another fit."); navigateTo(FittingParameterPage.class); } }); addButtonToButtonBar(anotherFit); // gotoCharmmFit = ButtonFactory.createButtonBarButton("Go to CHARMM section", new EventHandler<ActionEvent>() { // @Override // public void handle(ActionEvent actionEvent) { // logger.info("Now switching to the CHARMM Lennard-Jones fit section."); // goToCHARMM_Fit(); // } // }); // addButtonToButtonBar(gotoCharmmFit); // gotoCharmmFit.setDisable(true); }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXScopePickerPane.java
public CFBamJavaFXScopePickerPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema, ICFBamScopeObj argFocus, ICFLibAnyObj argContainer, Collection<ICFBamScopeObj> argDataCollection, ICFBamJavaFXScopeChosen whenChosen) { super();/*from w w w .j a v a2s .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<ICFBamScopeObj>(); tableColumnObjKind = new TableColumn<ICFBamScopeObj, String>("Class Code"); tableColumnObjKind.setCellValueFactory( new Callback<CellDataFeatures<ICFBamScopeObj, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ICFBamScopeObj, String> p) { ICFBamScopeObj 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<ICFBamScopeObj, String>, TableCell<ICFBamScopeObj, String>>() { @Override public TableCell<ICFBamScopeObj, String> call(TableColumn<ICFBamScopeObj, String> arg) { return new CFStringTableCell<ICFBamScopeObj>(); } }); dataTable.getColumns().add(tableColumnObjKind); tableColumnId = new TableColumn<ICFBamScopeObj, Long>("Id"); tableColumnId .setCellValueFactory(new Callback<CellDataFeatures<ICFBamScopeObj, Long>, ObservableValue<Long>>() { public ObservableValue<Long> call(CellDataFeatures<ICFBamScopeObj, 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<ICFBamScopeObj, Long>, TableCell<ICFBamScopeObj, Long>>() { @Override public TableCell<ICFBamScopeObj, Long> call(TableColumn<ICFBamScopeObj, Long> arg) { return new CFInt64TableCell<ICFBamScopeObj>(); } }); dataTable.getColumns().add(tableColumnId); dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamScopeObj>() { @Override public void changed(ObservableValue<? extends ICFBamScopeObj> observable, ICFBamScopeObj oldValue, ICFBamScopeObj 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.choseScope(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"); } ICFBamScopeObj selectedInstance = getJavaFXFocusAsScope(); invokeWhenChosen.choseScope(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.rptools.tokentool.controller.ManageOverlays_Controller.java
private void loadImages(File dir) { // Clear Details panel clearDetails();// ww w . ja va 2 s . c o m currentDirectory = dir; File[] files = dir.listFiles(ImageUtil.SUPPORTED_FILENAME_FILTER); Task<Void> task = new Task<Void>() { @Override public Void call() { for (File file : files) { Path filePath = file.toPath(); if (loadOverlaysThread.isInterrupted()) { Platform.runLater(() -> overlayViewFlowPane.getChildren().clear()); break; } try { ToggleButton overlayButton = new ToggleButton(); ImageView imageViewNode = ImageUtil.getOverlayThumb(new ImageView(), filePath); overlayButton.getStyleClass().add("overlay-toggle-button"); overlayButton.setGraphic(imageViewNode); overlayButton.setUserData(file); overlayButton.setToggleGroup(overlayToggleGroup); overlayButton.addEventHandler(ActionEvent.ACTION, event -> { // No modifier keys used so add toggle group back to all buttons resetToggleGroup(); // Also set button to selected due to resetting toggle groups & no unselecting needed, makes for better interface IMO overlayButton.setSelected(true); // Update the Details panel with the last selected overlay File overlayFile = (File) overlayButton.getUserData(); updateDetails(overlayFile, (ImageView) overlayButton.getGraphic(), overlayButton.isSelected()); // Consume the event, no more logic needed event.consume(); }); overlayButton.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { // Allow multiple selections if shortcutKey+left_mouse is pressed if (event.getButton().equals(MouseButton.PRIMARY) && event.isShortcutDown()) { // Update the Details panel with the last selected overlay File overlayFile = (File) overlayButton.getUserData(); updateDetails(overlayFile, (ImageView) overlayButton.getGraphic(), true); // Remove the toggle group to allow multiple toggle button selection overlayButton.setToggleGroup(null); // Select the button overlayButton.setSelected(true); // Consume the event, no more logic needed event.consume(); } } }); Platform.runLater(() -> overlayViewFlowPane.getChildren().add(overlayButton)); } catch (IOException e) { log.error("Loading image: " + filePath.getFileName(), e); } } return null; } }; loadOverlaysThread.interrupt(); executorService.execute(task); }