Search in sources :

Example 46 with ActionEvent

use of javafx.event.ActionEvent in project jvarkit by lindenb.

the class JfxNgs method start.

/*
    private void showPreferenceDialoge(Window parentStage)
	    {
	    Stage dialog = new Stage();


	     dialog.setTitle("Preferences");
		 dialog.initOwner(parentStage);
		 dialog.initModality(Modality.APPLICATION_MODAL);
		 dialog.showAndWait();
	    }*/
@Override
public void start(final Stage primaryStage) throws Exception {
    final Parameters params = this.getParameters();
    primaryStage.setTitle(getClass().getSimpleName());
    Menu menu = new Menu("File");
    menu.getItems().addAll(createCommonMenuItems(primaryStage));
    menu.getItems().add(new SeparatorMenuItem());
    MenuItem menuItem = new MenuItem("Quit...");
    menuItem.setOnAction(AE -> doMenuQuit());
    menu.getItems().add(menuItem);
    MenuBar bar = new MenuBar(menu);
    FlowPane flow = new FlowPane(5, 5);
    flow.setPadding(new Insets(10));
    flow.getChildren().add(new Label("Set Location of all frames to:"));
    final TextField textField = new TextField();
    textField.setPrefColumnCount(25);
    textField.setPromptText("Location. e:g '2:1234-5678'");
    flow.getChildren().add(textField);
    Button button = new Button("Go");
    flow.getChildren().add(button);
    textField.setTooltip(new Tooltip("set genomic location can be: empty, 'contig', 'contig:pos', 'contig:start-end' and (\"unmapped\" for bam)"));
    final EventHandler<ActionEvent> handler = new EventHandler<ActionEvent>() {

        @Override
        public void handle(final ActionEvent event) {
            final String loc = textField.getText().trim();
            LOG.info("moveTo all to " + loc);
            for (final NgsStage<?, ?> sc : all_opened_stages) {
                LOG.info("moveTo " + sc.getTitle() + " to " + loc);
                sc.moveTo(loc);
            }
        }
    };
    button.setOnAction(handler);
    button.setTooltip(new Tooltip("Go the specified genomic location."));
    textField.setOnAction(handler);
    BorderPane pane = new BorderPane();
    pane.setPadding(new Insets(5));
    pane.setBottom(new Label("Author: Pierre Lindenbaum PhD."));
    VBox vbox1 = new VBox(bar, flow, pane);
    final Scene scene = new Scene(vbox1, 500, 300);
    primaryStage.setScene(scene);
    Exception lastException = null;
    primaryStage.addEventHandler(WindowEvent.WINDOW_SHOWING, new EventHandler<WindowEvent>() {

        @Override
        public void handle(final WindowEvent event) {
            final List<String> unnamedParams = new ArrayList<>(params.getUnnamed());
            String startPos = "";
            int optind = 0;
            while (optind + 1 < unnamedParams.size()) {
                if (unnamedParams.get(optind).equals("-h") || unnamedParams.get(optind).equals("--help")) {
                    unnamedParams.remove(optind);
                    System.out.println("JfxNgs : Pierre Lindenbaum PhD 2017");
                    System.out.println("Options:");
                    System.out.println(" -h|--help this screen.");
                    System.out.println(" -p|--position (string) the starting position");
                    Platform.exit();
                } else if (unnamedParams.get(optind).equals("-p") || unnamedParams.get(optind).equals("--position")) {
                    startPos = unnamedParams.get(optind + 1);
                    unnamedParams.remove(optind + 1);
                    unnamedParams.remove(optind);
                } else {
                    optind++;
                }
            }
            for (final String arg : unnamedParams) {
                VcfFile vcfin = null;
                BamFile bamin = null;
                try {
                    if (IOUtil.isUrl(arg)) {
                        if (arg.endsWith(".bam")) {
                            bamin = BamFile.newInstance(arg);
                        } else if (arg.endsWith(".vcf.gz")) {
                            vcfin = VcfFile.newInstance(arg);
                        }
                    } else {
                        final File f = new File(arg);
                        if (fileMatchExtensionFilter(f.getName(), BamStage.EXTENSION_FILTERS)) {
                            bamin = BamFile.newInstance(f);
                        } else if (fileMatchExtensionFilter(f.getName(), VcfStage.EXTENSION_FILTERS)) {
                            vcfin = VcfFile.newInstance(f);
                        } else {
                            JfxNgs.showExceptionDialog(primaryStage, "Cannot open " + f);
                        }
                    }
                    if (vcfin != null) {
                        new VcfStage(JfxNgs.this, vcfin).setLocationOnOpen(startPos).show();
                    } else if (bamin != null) {
                        new BamStage(JfxNgs.this, bamin).show();
                    }
                } catch (Exception e) {
                    CloserUtil.close(vcfin);
                    CloserUtil.close(bamin);
                    showExceptionDialog(primaryStage, e);
                }
            }
        }
    });
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Insets(javafx.geometry.Insets) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) FlowPane(javafx.scene.layout.FlowPane) TextField(javafx.scene.control.TextField) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) List(java.util.List) Menu(javafx.scene.control.Menu) Tooltip(javafx.scene.control.Tooltip) CheckMenuItem(javafx.scene.control.CheckMenuItem) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Scene(javafx.scene.Scene) ScriptException(javax.script.ScriptException) BackingStoreException(java.util.prefs.BackingStoreException) IOException(java.io.IOException) WindowEvent(javafx.stage.WindowEvent) VBox(javafx.scene.layout.VBox) File(java.io.File)

Example 47 with ActionEvent

use of javafx.event.ActionEvent in project jvarkit by lindenb.

the class NgsStage method createJavascriptSnippetMenu.

/**
 * generate the javascript Menu, containing the snippets.
 * the snippet are stored as a xml file in the jar file
 * @return
 */
protected Menu createJavascriptSnippetMenu() {
    final Menu menu = new Menu("Snippets");
    loadSnippets().stream().filter(C -> C.isFilterScope()).forEach(C -> {
        final MenuItem item = new MenuItem(C.label + (C.function ? "[Function]" : ""));
        item.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                if (!C.function) {
                    NgsStage.this.javascriptArea.setText(C.code);
                } else {
                    final int caret = NgsStage.this.javascriptArea.getCaretPosition();
                    NgsStage.this.javascriptArea.insertText(caret, C.code);
                }
            }
        });
        menu.getItems().add(item);
    });
    return menu;
}
Also used : Arrays(java.util.Arrays) ChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ChartFactory) ScrollPane(javafx.scene.control.ScrollPane) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Map(java.util.Map) Hershey(com.github.lindenb.jvarkit.util.Hershey) ScriptException(javax.script.ScriptException) CloserUtil(htsjdk.samtools.util.CloserUtil) PrintWriter(java.io.PrintWriter) GraphicsContext(javafx.scene.canvas.GraphicsContext) Set(java.util.Set) Canvas(javafx.scene.canvas.Canvas) FilterOutputStream(java.io.FilterOutputStream) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) Platform(javafx.application.Platform) Separator(javafx.scene.control.Separator) Clipboard(javafx.scene.input.Clipboard) FlowPane(javafx.scene.layout.FlowPane) QName(javax.xml.namespace.QName) BorderPane(javafx.scene.layout.BorderPane) Hyperlink(javafx.scene.control.Hyperlink) CloseableIterator(htsjdk.samtools.util.CloseableIterator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FXCollections(javafx.collections.FXCollections) TextFlow(javafx.scene.text.TextFlow) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) AbstractIterator(htsjdk.samtools.util.AbstractIterator) Color(javafx.scene.paint.Color) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) Menu(javafx.scene.control.Menu) FileChooser(javafx.stage.FileChooser) Tab(javafx.scene.control.Tab) CompiledScript(javax.script.CompiledScript) ObservableValue(javafx.beans.value.ObservableValue) EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) IOUtil(htsjdk.samtools.util.IOUtil) XMLInputFactory(javax.xml.stream.XMLInputFactory) IgvSocket(com.github.lindenb.jvarkit.util.igv.IgvSocket) CycleMethod(javafx.scene.paint.CycleMethod) LinearGradient(javafx.scene.paint.LinearGradient) VBox(javafx.scene.layout.VBox) XMLEvent(javax.xml.stream.events.XMLEvent) AlertType(javafx.scene.control.Alert.AlertType) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) Pane(javafx.scene.layout.Pane) Orientation(javafx.geometry.Orientation) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Stop(javafx.scene.paint.Stop) Predicate(java.util.function.Predicate) Logger(com.github.lindenb.jvarkit.util.log.Logger) Font(javafx.scene.text.Font) Spinner(javafx.scene.control.Spinner) Chart(javafx.scene.chart.Chart) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Text(javafx.scene.text.Text) SimpleBindings(javax.script.SimpleBindings) Priority(javafx.scene.layout.Priority) List(java.util.List) Paint(javafx.scene.paint.Paint) Optional(java.util.Optional) ClipboardContent(javafx.scene.input.ClipboardContent) Scene(javafx.scene.Scene) TextArea(javafx.scene.control.TextArea) ButtonType(javafx.scene.control.ButtonType) HashMap(java.util.HashMap) Function(java.util.function.Function) TableColumn(javafx.scene.control.TableColumn) HashSet(java.util.HashSet) Interval(htsjdk.samtools.util.Interval) TableCell(javafx.scene.control.TableCell) Attribute(javax.xml.stream.events.Attribute) Insets(javafx.geometry.Insets) StartElement(javax.xml.stream.events.StartElement) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) OutputStream(java.io.OutputStream) PrintStream(java.io.PrintStream) XMLEventReader(javax.xml.stream.XMLEventReader) Locatable(htsjdk.samtools.util.Locatable) Modality(javafx.stage.Modality) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) FileInputStream(java.io.FileInputStream) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) InputStream(java.io.InputStream) ActionEvent(javafx.event.ActionEvent) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Menu(javafx.scene.control.Menu)

Example 48 with ActionEvent

use of javafx.event.ActionEvent in project uPMT by coco35700.

the class RootLayoutController method openALink.

// ----------------------------modifier: open a document
@FXML
public void openALink() {
    Stage web = new Stage();
    // link.onActionProperty().addListener(listener);
    link.setOnAction((ActionEvent action) -> {
        try {
            java.awt.Desktop.getDesktop().browse(new URI("https://github.com/coco35700/uPMT"));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    });
    // web.setAlwaysOnTop(true);
    web.centerOnScreen();
    web.close();
}
Also used : ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) FXML(javafx.fxml.FXML)

Example 49 with ActionEvent

use of javafx.event.ActionEvent in project certmgr by hdecarne.

the class StoreController method onCmdCopyEntry.

@SuppressWarnings("unused")
@FXML
void onCmdCopyEntry(ActionEvent evt) {
    UserCertStoreEntry entry = getSelectedStoreEntry();
    if (entry != null) {
        List<Path> entryFilePaths = entry.getFilePaths();
        if (!entryFilePaths.isEmpty()) {
            List<File> entryFiles = entryFilePaths.stream().map((p) -> p.toFile()).collect(Collectors.toList());
            Clipboard clipboard = Clipboard.getSystemClipboard();
            ClipboardContent content = new ClipboardContent();
            content.putFiles(entryFiles);
            clipboard.setContent(content);
        }
    }
}
Also used : Path(java.nio.file.Path) X509Certificate(java.security.cert.X509Certificate) Button(javafx.scene.control.Button) Exceptions(de.carne.util.Exceptions) ScheduledFuture(java.util.concurrent.ScheduledFuture) PreferencesDialog(de.carne.certmgr.jfx.preferences.PreferencesDialog) Date(java.util.Date) Alerts(de.carne.jfx.scene.control.Alerts) CheckMenuItem(javafx.scene.control.CheckMenuItem) X509CRL(java.security.cert.X509CRL) PKCS10CertificateRequest(de.carne.certmgr.certs.x509.PKCS10CertificateRequest) UserCertStoreTreeTableViewHelper(de.carne.certmgr.jfx.util.UserCertStoreTreeTableViewHelper) CertOptionsController(de.carne.certmgr.jfx.certoptions.CertOptionsController) AboutInfoController(de.carne.jfx.scene.control.aboutinfo.AboutInfoController) AlertType(javafx.scene.control.Alert.AlertType) ContextMenu(javafx.scene.control.ContextMenu) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry) TreeTableCell(javafx.scene.control.TreeTableCell) BigInteger(java.math.BigInteger) CertImportController(de.carne.certmgr.jfx.certimport.CertImportController) Lazy(de.carne.util.Lazy) X509CRLHelper(de.carne.certmgr.certs.x509.X509CRLHelper) Path(java.nio.file.Path) PrintWriter(java.io.PrintWriter) PathPreference(de.carne.certmgr.util.PathPreference) StageController(de.carne.jfx.stage.StageController) MenuItem(javafx.scene.control.MenuItem) AboutInfoDialog(de.carne.jfx.scene.control.aboutinfo.AboutInfoDialog) Collectors(java.util.stream.Collectors) Attributes(de.carne.certmgr.certs.x509.Attributes) PreferencesController(de.carne.certmgr.jfx.preferences.PreferencesController) Images(de.carne.certmgr.jfx.resources.Images) FXML(javafx.fxml.FXML) Windows(de.carne.jfx.stage.Windows) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) Optional(java.util.Optional) ClipboardContent(javafx.scene.input.ClipboardContent) Debug(de.carne.util.Debug) ButtonData(javafx.scene.control.ButtonBar.ButtonData) Nullable(de.carne.check.Nullable) ButtonType(javafx.scene.control.ButtonType) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) NumberFormat(java.text.NumberFormat) TreeTableRow(javafx.scene.control.TreeTableRow) TreeTableView(javafx.scene.control.TreeTableView) ReasonFlag(de.carne.certmgr.certs.x509.ReasonFlag) CRLOptionsController(de.carne.certmgr.jfx.crloptions.CRLOptionsController) UserCertStore(de.carne.certmgr.certs.UserCertStore) Tooltip(javafx.scene.control.Tooltip) PlatformHelper(de.carne.jfx.application.PlatformHelper) DirectoryChooser(javafx.stage.DirectoryChooser) X509CertificateHelper(de.carne.certmgr.certs.x509.X509CertificateHelper) ObjectProperty(javafx.beans.property.ObjectProperty) CertExportController(de.carne.certmgr.jfx.certexport.CertExportController) Label(javafx.scene.control.Label) StringWriter(java.io.StringWriter) IOException(java.io.IOException) File(java.io.File) Preferences(java.util.prefs.Preferences) StorePreferencesController(de.carne.certmgr.jfx.storepreferences.StorePreferencesController) TimeUnit(java.util.concurrent.TimeUnit) TreeTableColumn(javafx.scene.control.TreeTableColumn) ActionEvent(javafx.event.ActionEvent) TreeItemPropertyValueFactory(javafx.scene.control.cell.TreeItemPropertyValueFactory) StorePreferencesDialog(de.carne.certmgr.jfx.storepreferences.StorePreferencesDialog) LogViewController(de.carne.jfx.stage.logview.LogViewController) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ClipboardContent(javafx.scene.input.ClipboardContent) Clipboard(javafx.scene.input.Clipboard) File(java.io.File) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry) FXML(javafx.fxml.FXML)

Example 50 with ActionEvent

use of javafx.event.ActionEvent in project CST-135 by psradke.

the class FinalSale method start.

@Override
public void start(Stage primaryStage) throws Exception {
    // Background image
    BackgroundImage backImg = new BackgroundImage(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/FinalSaleBackground.png", 810, 720, false, true), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
    // PANE CREATION
    // Home and Back Buttons Pane
    GridPane buttons = new GridPane();
    buttons.setHgap(10);
    buttons.setVgap(10);
    buttons.setPadding(new Insets(0, 10, 0, 10));
    // TableView Cart Pane
    GridPane cartView = new GridPane();
    cartView.setHgap(9);
    cartView.setVgap(9);
    cartView.setOpacity(0.9);
    cartView.setPadding(new Insets(0, 10, 0, 10));
    // Delete and Purchase Buttons Pane
    GridPane buttons2 = new GridPane();
    buttons2.setHgap(10);
    buttons2.setVgap(10);
    buttons2.setPadding(new Insets(0, 10, 0, 10));
    // Main Pane for arrangement
    VBox vBox = new VBox();
    vBox.setPadding(new Insets(10, 10, 10, 10));
    vBox.getChildren().addAll(buttons, cartView, buttons2);
    // Background Pane
    StackPane root = new StackPane();
    root.setMaxSize(800, 610);
    root.setMinSize(800, 610);
    root.setBackground(new Background(backImg));
    root.setPadding(new Insets(0, 10, 0, 10));
    root.getChildren().add(vBox);
    // BUTTON CREATION
    // Home Button
    Button home = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/HomeButton.png")));
    home.setBackground(Background.EMPTY);
    home.setMaxSize(5, 10);
    home.setMinSize(5, 10);
    buttons.add(home, 9, 2);
    // home.setOnAction(e -> {
    // homePage.setScene(scene);
    // });
    // Back Button
    Button back = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/BackButton.png")));
    back.setBackground(Background.EMPTY);
    back.setMaxSize(5, 10);
    back.setMinSize(5, 10);
    buttons.add(back, 64, 2);
    back.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Back");
        }
    });
    // Purchase Button
    Button purchase = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/Purchase.png")));
    purchase.setBackground(Background.EMPTY);
    purchase.setMaxSize(5, 10);
    purchase.setMinSize(5, 10);
    buttons2.add(purchase, 36, 11);
    purchase.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Purcahse");
        }
    });
    // Delete Button
    // Button delete = new Button("Delete Product");
    // delete.setOnAction(e -> deleteClicked());
    // CREATE TABLE FOR DISPLAYING CART
    TableView<Product> table;
    // Name column
    TableColumn<Product, String> nameCol = new TableColumn<>("Name");
    nameCol.setMinWidth(150);
    nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
    // Price column
    TableColumn<Product, Double> priceCol = new TableColumn<>("Price");
    priceCol.setMinWidth(20);
    priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
    // Weight column
    TableColumn<Product, Double> weightCol = new TableColumn<>("Weight");
    weightCol.setMinWidth(50);
    weightCol.setCellValueFactory(new PropertyValueFactory<>("weight"));
    // Quantity column
    TableColumn<Product, Double> quantityCol = new TableColumn<>("Quantity");
    quantityCol.setMinWidth(20);
    quantityCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
    table = new TableView<>();
    table.setItems(getProduct());
    table.setBackground(Background.EMPTY);
    table.setMaxSize(620, 313);
    table.setMinSize(620, 313);
    table.getColumns().addAll(nameCol, priceCol, weightCol, quantityCol);
    cartView.add(table, 7, 18);
    Scene scene = new Scene(root, 800, 710);
    primaryStage.setTitle("Checkout");
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    primaryStage.show();
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) ActionEvent(javafx.event.ActionEvent) BackgroundImage(javafx.scene.layout.BackgroundImage) Image(javafx.scene.image.Image) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) BackgroundImage(javafx.scene.layout.BackgroundImage) Button(javafx.scene.control.Button) ImageView(javafx.scene.image.ImageView) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Aggregations

ActionEvent (javafx.event.ActionEvent)171 EventHandler (javafx.event.EventHandler)61 Stage (javafx.stage.Stage)52 KeyFrame (javafx.animation.KeyFrame)47 Timeline (javafx.animation.Timeline)47 FXML (javafx.fxml.FXML)44 Alert (javafx.scene.control.Alert)36 Button (javafx.scene.control.Button)35 Label (javafx.scene.control.Label)35 MenuItem (javafx.scene.control.MenuItem)33 ContextMenu (javafx.scene.control.ContextMenu)25 File (java.io.File)24 Insets (javafx.geometry.Insets)24 Scene (javafx.scene.Scene)24 List (java.util.List)21 ObservableList (javafx.collections.ObservableList)21 Node (javafx.scene.Node)20 TextField (javafx.scene.control.TextField)20 Optional (java.util.Optional)18 FXCollections (javafx.collections.FXCollections)18