List of usage examples for javafx.event WeakEventHandler WeakEventHandler
public WeakEventHandler(final @NamedArg("eventHandler") EventHandler<T> eventHandler)
From source file:org.shiftedit.gui.preview.html.RemoteHTMLPreviewController.java
@Override public void initialize(URL url, ResourceBundle rb) { super.initialize(url, rb); if (started) { displayInfoDialog(getResourceBundle().getString("builtin.plugin.preview.remote_html.title"), getResourceBundle().getString("builtin.plugin.preview.remote_html.already_running.text")); Platform.runLater(() -> {//from www . j ava 2s . c o m close(); }); } else { // Start server startServer(); // URL click urlLinkActionEventHandler = (ActionEvent t) -> { ApplicationContext.getHostServices().showDocument(urlLink.getText()); }; urlLink.setOnAction(new WeakEventHandler<>(urlLinkActionEventHandler)); // Table view setup this.setupConnectionTable(); // Bind tracking button state trackActiveFileChangeListener = (ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> { setActiveDocumentTrackingEnabled(t1); }; trackActiveFileToggleButton.selectedProperty() .addListener(new WeakChangeListener<>(trackActiveFileChangeListener)); trackActiveFileToggleButton.setSelected(true); } // Later ... Platform.runLater(() -> { getStage().setTitle(getResourceBundle().getString("builtin.plugin.preview.remote_html.title")); }); }
From source file:org.shiftedit.gui.preview.html.RemoteHTMLPreviewController.java
private void setupConnectionTable() { // Cell click handler tableCellMouseEventHandler = (MouseEvent t) -> { TableCell c = (TableCell) t.getSource(); int index = c.getIndex(); // Send ping request on double click if (t.getClickCount() == 2) { tableModel.get(index).ping(); }/*from ww w . java 2s . com*/ }; // Cell factory Callback<TableColumn, TableCell> cellFactory = (TableColumn p) -> { TextFieldTableCell cell = new TextFieldTableCell(); cell.addEventFilter(MouseEvent.MOUSE_CLICKED, new WeakEventHandler<>(tableCellMouseEventHandler)); return cell; }; // Remote address TableColumn remoteAddressCol = new TableColumn( getResourceBundle().getString("builtin.plugin.preview.remote_html.remote_address")); remoteAddressCol.setMinWidth(100); remoteAddressCol.setCellValueFactory(new PropertyValueFactory<>("remoteAddress")); remoteAddressCol.setCellFactory(cellFactory); connectionTable.getColumns().add(remoteAddressCol); // User agent TableColumn userAgentCol = new TableColumn( getResourceBundle().getString("builtin.plugin.preview.remote_html.user_agent")); userAgentCol.setMinWidth(200); userAgentCol.setCellValueFactory(new PropertyValueFactory<>("userAgent")); userAgentCol.setCellFactory(cellFactory); connectionTable.getColumns().add(userAgentCol); // Rendering time TableColumn renderingTimeCol = new TableColumn( getResourceBundle().getString("builtin.plugin.preview.remote_html.rendering_time")); renderingTimeCol.setMinWidth(200); renderingTimeCol.setCellValueFactory(new PropertyValueFactory<>("renderingTime")); renderingTimeCol.setCellFactory(cellFactory); connectionTable.getColumns().add(renderingTimeCol); connectionTable.setPlaceholder( new Label(getResourceBundle().getString("builtin.plugin.preview.remote_html.no_connection"))); connectionTable.setItems(tableModel); }