Search in sources :

Example 21 with SeparatorMenuItem

use of javafx.scene.control.SeparatorMenuItem in project blue by kunstmusik.

the class BSBEditPane method setupPopupMenus.

private void setupPopupMenus(BSBObjectEntry[] bsbObjectEntries) {
    popupMenu = new ContextMenu();
    EventHandler<ActionEvent> al = e -> {
        MenuItem m = (MenuItem) e.getSource();
        Class<? extends BSBObject> clazz = (Class<? extends BSBObject>) m.getUserData();
        try {
            BSBObject bsbObj = clazz.newInstance();
            bsbObj.setX(addX);
            bsbObj.setY(addY);
            currentBSBGroup.addBSBObject(bsbObj);
        } catch (InstantiationException | IllegalAccessException ex) {
            Exceptions.printStackTrace(ex);
        }
    };
    for (BSBObjectEntry entry : bsbObjectEntries) {
        MenuItem m = new MenuItem("Add " + entry.label);
        m.setUserData(entry.bsbObjectClass);
        m.setOnAction(al);
        popupMenu.getItems().add(m);
    }
    MenuItem paste = new MenuItem("Paste");
    paste.setOnAction(ae -> paste(addX, addY));
    paste.disableProperty().bind(Bindings.createBooleanBinding(() -> selection.copyBufferProperty().size() == 0, selection.copyBufferProperty()));
    popupMenu.getItems().addAll(new SeparatorMenuItem(), paste);
    nonEditPopupMenu = new ContextMenu();
    MenuItem randomize = new MenuItem("Randomize");
    randomize.setOnAction(ae -> {
        if (bsbInterface != null) {
            bsbInterface.getRootGroup().randomize();
        }
    });
    nonEditPopupMenu.getItems().add(randomize);
}
Also used : EventHandler(javafx.event.EventHandler) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) Bindings(javafx.beans.binding.Bindings) InvalidationListener(javafx.beans.InvalidationListener) HashSet(java.util.HashSet) BSBGroup(blue.orchestra.blueSynthBuilder.BSBGroup) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) Exceptions(org.openide.util.Exceptions) EditModeOnly(blue.orchestra.editor.blueSynthBuilder.EditModeOnly) BSBGraphicInterface(blue.orchestra.blueSynthBuilder.BSBGraphicInterface) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) Pane(javafx.scene.layout.Pane) Color(javafx.scene.paint.Color) MenuItem(javafx.scene.control.MenuItem) GraphicsContext(javafx.scene.canvas.GraphicsContext) Collection(java.util.Collection) Node(javafx.scene.Node) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings) Set(java.util.Set) Canvas(javafx.scene.canvas.Canvas) Rectangle(javafx.scene.shape.Rectangle) KeyEvent(javafx.scene.input.KeyEvent) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Region(javafx.scene.layout.Region) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) BSBObjectEntry(blue.orchestra.blueSynthBuilder.BSBObjectEntry) Bounds(javafx.geometry.Bounds) ActionEvent(javafx.event.ActionEvent) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) BSBObjectEntry(blue.orchestra.blueSynthBuilder.BSBObjectEntry) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem)

Example 22 with SeparatorMenuItem

use of javafx.scene.control.SeparatorMenuItem in project org.csstudio.display.builder by kasemir.

the class ScriptsDialog method createScriptsTable.

/**
 * @return Node for UI elements that edit the scripts
 */
private Region createScriptsTable() {
    scripts_icon_col = new TableColumn<>();
    scripts_icon_col.setCellValueFactory(cdf -> new SimpleObjectProperty<ImageView>(getScriptImage(cdf.getValue())) {

        {
            bind(Bindings.createObjectBinding(() -> getScriptImage(cdf.getValue()), cdf.getValue().fileProperty()));
        }
    });
    scripts_icon_col.setCellFactory(col -> new TableCell<ScriptItem, ImageView>() {

        /* Instance initializer. */
        {
            setAlignment(Pos.CENTER_LEFT);
        }

        @Override
        protected void updateItem(final ImageView item, final boolean empty) {
            super.updateItem(item, empty);
            super.setGraphic(item);
        }
    });
    scripts_icon_col.setEditable(false);
    scripts_icon_col.setSortable(false);
    scripts_icon_col.setMaxWidth(25);
    scripts_icon_col.setMinWidth(25);
    // Create table with editable script 'file' column
    scripts_name_col = new TableColumn<>(Messages.ScriptsDialog_ColScript);
    scripts_name_col.setCellValueFactory(new PropertyValueFactory<ScriptItem, String>("file"));
    scripts_name_col.setCellFactory(col -> new TextFieldTableCell<ScriptItem, String>(new DefaultStringConverter()) {

        private final ChangeListener<? super Boolean> focusedListener = (ob, o, n) -> {
            if (!n)
                cancelEdit();
        };

        @Override
        public void cancelEdit() {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.cancelEdit();
        }

        @Override
        public void startEdit() {
            super.startEdit();
            ((TextField) getGraphic()).focusedProperty().addListener(focusedListener);
        }

        @Override
        public void commitEdit(final String newValue) {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.commitEdit(newValue);
            Platform.runLater(() -> btn_pv_add.requestFocus());
        }
    });
    scripts_name_col.setOnEditCommit(event -> {
        final int row = event.getTablePosition().getRow();
        script_items.get(row).file.set(event.getNewValue());
        fixupScripts(row);
    });
    scripts_table = new TableView<>(script_items);
    scripts_table.getColumns().add(scripts_icon_col);
    scripts_table.getColumns().add(scripts_name_col);
    scripts_table.setEditable(true);
    scripts_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    scripts_table.setTooltip(new Tooltip(Messages.ScriptsDialog_ScriptsTT));
    scripts_table.setPlaceholder(new Label(Messages.ScriptsDialog_NoScripts));
    // Buttons
    addMenuButton = new MenuButton(Messages.Add, JFXUtil.getIcon("add.png"), new MenuItem(Messages.AddPythonFile, JFXUtil.getIcon("file-python.png")) {

        {
            setOnAction(e -> addPythonFile());
        }
    }, new MenuItem(Messages.AddJavaScriptFile, JFXUtil.getIcon("file-javascript.png")) {

        {
            setOnAction(e -> addJavaScriptFile());
        }
    }, new SeparatorMenuItem(), new MenuItem(Messages.AddEmbeddedPython, JFXUtil.getIcon("python.png")) {

        {
            setOnAction(e -> addEmbeddedJython());
        }
    }, new MenuItem(Messages.AddEmbeddedJavaScript, JFXUtil.getIcon("javascript.png")) {

        {
            setOnAction(e -> addEmbeddedJavaScript());
        }
    });
    addMenuButton.setMaxWidth(Double.MAX_VALUE);
    addMenuButton.setAlignment(Pos.CENTER_LEFT);
    btn_script_remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
    btn_script_remove.setMaxWidth(Double.MAX_VALUE);
    btn_script_remove.setAlignment(Pos.CENTER_LEFT);
    btn_script_remove.setDisable(true);
    btn_script_remove.setOnAction(event -> {
        final int sel = scripts_table.getSelectionModel().getSelectedIndex();
        if (sel >= 0) {
            script_items.remove(sel);
            fixupScripts(sel);
        }
    });
    btn_edit = new SplitMenuButton(convertToFileMenuItem, new SeparatorMenuItem(), convertToEmbeddedPythonMenuItem, convertToEmbeddedJavaScriptMenuItem);
    btn_edit.setText(Messages.Select);
    btn_edit.setGraphic(JFXUtil.getIcon("select-file.png"));
    btn_edit.setMaxWidth(Double.MAX_VALUE);
    btn_edit.setMinWidth(120);
    btn_edit.setAlignment(Pos.CENTER_LEFT);
    btn_edit.setDisable(true);
    btn_edit.setOnAction(e -> editOrSelect());
    final VBox buttons = new VBox(10, addMenuButton, btn_script_remove, btn_edit);
    final HBox content = new HBox(10, scripts_table, buttons);
    HBox.setHgrow(scripts_table, Priority.ALWAYS);
    HBox.setHgrow(buttons, Priority.NEVER);
    return content;
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) ScriptPV(org.csstudio.display.builder.model.properties.ScriptPV) LineNumberTableCellFactory(org.csstudio.javafx.LineNumberTableCellFactory) VBox(javafx.scene.layout.VBox) AutoCompletedTableCell(org.csstudio.display.builder.representation.javafx.PVTableItem.AutoCompletedTableCell) TableHelper(org.csstudio.javafx.TableHelper) ListChangeListener(javafx.collections.ListChangeListener) TableView(javafx.scene.control.TableView) ModelThreadPool(org.csstudio.display.builder.model.util.ModelThreadPool) HBox(javafx.scene.layout.HBox) SplitPane(javafx.scene.control.SplitPane) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Language(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) MenuButton(javafx.scene.control.MenuButton) ObservableList(javafx.collections.ObservableList) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) StringProperty(javafx.beans.property.StringProperty) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) SyntaxHighlightedMultiLineInputDialog(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ButtonType(javafx.scene.control.ButtonType) JFXBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.JFXBaseRepresentation) FXCollections(javafx.collections.FXCollections) BackingStoreException(java.util.prefs.BackingStoreException) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Bindings(javafx.beans.binding.Bindings) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) Tooltip(javafx.scene.control.Tooltip) ScriptInfo(org.csstudio.display.builder.model.properties.ScriptInfo) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) SplitMenuButton(javafx.scene.control.SplitMenuButton) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Preferences(java.util.prefs.Preferences) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) TimeUnit(java.util.concurrent.TimeUnit) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ImageView(javafx.scene.image.ImageView) DialogHelper(org.csstudio.javafx.DialogHelper) Widget(org.csstudio.display.builder.model.Widget) ChangeListener(javafx.beans.value.ChangeListener) HBox(javafx.scene.layout.HBox) SplitMenuButton(javafx.scene.control.SplitMenuButton) Label(javafx.scene.control.Label) MenuButton(javafx.scene.control.MenuButton) SplitMenuButton(javafx.scene.control.SplitMenuButton) Button(javafx.scene.control.Button) MenuButton(javafx.scene.control.MenuButton) SplitMenuButton(javafx.scene.control.SplitMenuButton) TextField(javafx.scene.control.TextField) ImageView(javafx.scene.image.ImageView) Tooltip(javafx.scene.control.Tooltip) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) VBox(javafx.scene.layout.VBox)

Example 23 with SeparatorMenuItem

use of javafx.scene.control.SeparatorMenuItem in project pmd by pmd.

the class PropertyTableView method initialize.

private void initialize() {
    this.getColumns().add(propertyNameColumn);
    this.getColumns().add(propertyTypeColumn);
    this.getColumns().add(propertyValueColumn);
    this.setColumnResizePolicy(CONSTRAINED_RESIZE_POLICY);
    this.setTableMenuButtonVisible(true);
    ObservableList<PropertyTypeId> availableBuilders = FXCollections.observableArrayList(PropertyTypeId.typeIdsToConstants().values());
    Collections.sort(availableBuilders);
    StringConverter<PropertyTypeId> converter = DesignerUtil.stringConverter(PropertyTypeId::getStringId, PropertyTypeId::lookupMnemonic);
    propertyTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(converter, availableBuilders));
    propertyNameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
    propertyValueColumn.setCellValueFactory(new PropertyValueFactory<>("value"));
    propertyTypeColumn.setCellValueFactory(new PropertyValueFactory<>("typeId"));
    this.setPlaceholder(new Label("Right-click to add properties"));
    MenuItem editItem = new MenuItem("Edit...");
    editItem.setOnAction(e -> {
        PropertyDescriptorSpec spec = this.getSelectionModel().getSelectedItem();
        if (spec != null) {
            popEditPropertyDialog(spec);
        }
    });
    MenuItem removeItem = new MenuItem("Remove");
    removeItem.setOnAction(e -> {
        PropertyDescriptorSpec selected = this.getSelectionModel().getSelectedItem();
        if (selected != null) {
            this.getItems().remove(selected);
        }
    });
    MenuItem addItem = new MenuItem("Add property...");
    addItem.setOnAction(e -> onAddPropertyClicked());
    ContextMenu fullMenu = new ContextMenu();
    fullMenu.getItems().addAll(editItem, removeItem, new SeparatorMenuItem(), addItem);
    // Reduced context menu, for when there are no properties or none is selected
    MenuItem addItem2 = new MenuItem("Add property...");
    addItem2.setOnAction(e -> onAddPropertyClicked());
    ContextMenu smallMenu = new ContextMenu();
    smallMenu.getItems().add(addItem2);
    this.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
        if (t.getButton() == MouseButton.SECONDARY || t.getButton() == MouseButton.PRIMARY && t.getClickCount() > 1) {
            if (this.getSelectionModel().getSelectedItem() != null) {
                fullMenu.show(this, t.getScreenX(), t.getScreenY());
            } else {
                smallMenu.show(this, t.getScreenX(), t.getScreenY());
            }
        }
    });
    propertyNameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    propertyValueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    this.setEditable(false);
}
Also used : PropertyDescriptorSpec(net.sourceforge.pmd.util.fxdesigner.util.PropertyDescriptorSpec) PropertyTypeId(net.sourceforge.pmd.properties.PropertyTypeId) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ContextMenu(javafx.scene.control.ContextMenu) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem)

Example 24 with SeparatorMenuItem

use of javafx.scene.control.SeparatorMenuItem in project jvarkit by lindenb.

the class IndexCovJfx method doWork.

@Override
public int doWork(final Stage primaryStage, final List<String> args) {
    final Rectangle2D screen = Screen.getPrimary().getVisualBounds();
    final Pattern tab = Pattern.compile("[\t]");
    BufferedReader r = null;
    try {
        final File inputFile;
        if (args.isEmpty()) {
            // open gui
            final FileChooser fc = new FileChooser();
            inputFile = fc.showOpenDialog(null);
            if (inputFile == null) {
                return 0;
            }
        } else if (args.size() == 1) {
            inputFile = new File(args.get(0));
        } else {
            LOG.error("Illegal Number of arguments: " + args);
            return -1;
        }
        r = IOUtils.openFileForBufferedReading(inputFile);
        String line = r.readLine();
        if (line == null) {
            new Alert(AlertType.ERROR, "Cannot read first line of " + inputFile, ButtonType.OK).showAndWait();
            return -1;
        }
        String[] tokens = tab.split(line);
        if (tokens.length < 4 || !tokens[0].equals("#chrom") || !tokens[1].equals("start") || !tokens[2].equals("end")) {
            new Alert(AlertType.ERROR, "bad first line " + line + " in " + inputFile, ButtonType.OK).showAndWait();
            return -1;
        }
        this.sampleNames.addAll(Arrays.asList(tokens).subList(3, tokens.length).stream().map(S -> new Sample(S)).collect(Collectors.toList()));
        this.sampleListView = new ListView<>(this.sampleNames);
        final MultipleSelectionModel<Sample> sampleSelectionModel = this.sampleListView.getSelectionModel();
        sampleSelectionModel.setSelectionMode(SelectionMode.MULTIPLE);
        // this.sampleListView.setPrefWidth(200);
        final SmartComparator smartCmp = new SmartComparator();
        this.orignalndexCovRows.addAll(r.lines().filter(L -> !StringUtil.isBlank(L)).map(L -> Arrays.asList(tab.split(L))).map(T -> new IndexCovRow(T)).sorted((A, B) -> {
            int i = smartCmp.compare(A.getContig(), B.getContig());
            if (i != 0)
                return i;
            return A.getStart() - B.getStart();
        }).collect(Collectors.toList()));
        this.visibleIndexCovRows.addAll(orignalndexCovRows);
        String lastContig = null;
        for (final IndexCovRow row : this.visibleIndexCovRows) {
            if (lastContig == null || !lastContig.equals(row.getContig())) {
                this.contig2color.put(row.getContig(), this.contig2color.size() % 2 == 0 ? gray(0.96) : gray(0.98));
                lastContig = row.getContig();
            }
        }
        this.canvas = new Canvas(screen.getWidth() - 400, screen.getHeight() - 200);
        this.canvasSrollPane = new ScrollPane(canvas);
        this.canvasSrollPane.setFitToHeight(true);
        this.canvasSrollPane.setFitToWidth(true);
        this.canvasSrollPane.setHbarPolicy(ScrollBarPolicy.ALWAYS);
        this.canvasSrollPane.setHmin(0);
        // NOT HERE: see adjustScollPane();
        // this.canvasSrollPane.setHmax(this.visibleIndexCovRows.size()*CHUNK_WIDTH);
        // this.canvasSrollPane.setHvalue(0);
        this.canvasSrollPane.hvalueProperty().addListener(E -> repaintCanvas());
        final VBox root = new VBox();
        final MenuBar menuBar = new MenuBar();
        Menu menu = new Menu("Tools");
        MenuItem item = new MenuItem("Goto");
        item.setOnAction(AE -> askGoto());
        item.setAccelerator(new KeyCodeCombination(KeyCode.G, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        // 
        item = new MenuItem("Cleanup: remove data > DEL && data < DUP");
        item.setOnAction(AE -> askCleanup());
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: remove ALL samples <= DEL or ALL samples >= DUP");
        item.setOnAction(AE -> askEveryWhere());
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: keep selected samples having <= DEL or ALL samples >= DUP");
        item.setOnAction(AE -> filterForSampleSet(false));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: keep selected samples having <= DEL or ALL samples >= DUP and only those samples.");
        item.setOnAction(AE -> filterForSampleSet(true));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Filter: Keep data overlapping BED file");
        item.setOnAction(AE -> filterBed(false));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Filter: Keep data NOT overlapping BED file");
        item.setOnAction(AE -> filterBed(true));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Revert: Restore original data");
        item.setOnAction(AE -> doRestoreOriginalData());
        item.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        item = new MenuItem("Next Interesting");
        item.setOnAction(AE -> goToNextInteresting(1));
        item.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        item = new MenuItem("Previous Interesting");
        item.setOnAction(AE -> goToNextInteresting(-1));
        item.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        item = new MenuItem("Quit");
        menu.getItems().add(item);
        item.setOnAction(AE -> {
            Platform.exit();
        });
        menuBar.getMenus().add(menu);
        root.getChildren().add(menuBar);
        final HBox toolboxPane = new HBox();
        Label label = new Label("DEL when \u2264 :");
        toolboxPane.getChildren().add(label);
        this.deletionSpinner = new Spinner<>(0.0, 0.9, DEFAULT_deletionTreshold, 0.05);
        label.setLabelFor(this.deletionSpinner);
        this.deletionSpinner.valueProperty().addListener((a, b, c) -> repaintCanvas());
        toolboxPane.getChildren().add(this.deletionSpinner);
        label = new Label("DUP when \u2265 :");
        toolboxPane.getChildren().add(label);
        this.duplicationSpinner = new Spinner<>(1.1, 10.0, DEFAULT_duplicationTreshold, 0.05);
        this.duplicationSpinner.valueProperty().addListener((a, b, c) -> repaintCanvas());
        label.setLabelFor(this.duplicationSpinner);
        toolboxPane.getChildren().add(this.duplicationSpinner);
        label = new Label(" Jump to :");
        toolboxPane.getChildren().add(label);
        final TextField jumpToTextField = new TextField();
        jumpToTextField.setPromptText("chrom:pos");
        jumpToTextField.setPrefColumnCount(15);
        toolboxPane.getChildren().add(jumpToTextField);
        label.setLabelFor(jumpToTextField);
        jumpToTextField.setOnAction(AE -> askGoto(jumpToTextField.getText()));
        final Button goButton = new Button("Go");
        toolboxPane.getChildren().add(goButton);
        goButton.setOnAction(AE -> askGoto(jumpToTextField.getText()));
        root.getChildren().add(toolboxPane);
        // HBox hbox = new HBox(sampleListView,this.canvasSrollPane);
        final GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(5, 5, 5, 5));
        grid.add(this.sampleListView, 0, 0, 1, 1);
        grid.add(this.canvasSrollPane, 1, 0, 9, 1);
        // final StackPane root = new StackPane();
        root.getChildren().add(grid);
        final Scene scene = new Scene(root);
        primaryStage.setTitle(IndexCovJfx.class.getSimpleName() + " " + this.sampleNames.size() + " Sample(s) " + this.visibleIndexCovRows.size() + " Point(s).");
        primaryStage.setOnShown(E -> {
            adjustScollPane();
            this.canvasSrollPane.requestFocus();
            repaintCanvas();
            if (this.isUnitText()) {
                Platform.exit();
            }
        });
        this.canvasSrollPane.setOnKeyPressed(e -> {
            if (e.getCode() == KeyCode.LEFT) {
                canvasSrollPane.setHvalue(Math.max(canvasSrollPane.getHmin(), canvasSrollPane.getHvalue() - CHUNK_WIDTH));
            }
            if (e.getCode() == KeyCode.RIGHT) {
                canvasSrollPane.setHvalue(Math.min(canvasSrollPane.getHmax(), canvasSrollPane.getHvalue() + CHUNK_WIDTH));
            }
        });
        primaryStage.setScene(scene);
        primaryStage.show();
        /*sampleSelectionModel.selectedItemProperty().addListener(E->{
	        	repaintCanvas();
				});
	        sampleSelectionModel.selectedItemProperty().addListener(E->repaintCanvas());*/
        sampleSelectionModel.getSelectedIndices().addListener(new ListChangeListener<Integer>() {

            @Override
            public void onChanged(Change<? extends Integer> c) {
                repaintCanvas();
            }
        });
    } catch (final Exception err) {
        LOG.error(err);
        new Alert(AlertType.ERROR, "Error " + err, ButtonType.OK).showAndWait();
        return -1;
    } finally {
        CloserUtil.close(r);
    }
    return 0;
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) Program(com.github.lindenb.jvarkit.util.jcommander.Program) AbstractList(java.util.AbstractList) VBox(javafx.scene.layout.VBox) MultipleSelectionModel(javafx.scene.control.MultipleSelectionModel) KeyCombination(javafx.scene.input.KeyCombination) Application(javafx.application.Application) ScrollPane(javafx.scene.control.ScrollPane) StringUtil(htsjdk.samtools.util.StringUtil) ListChangeListener(javafx.collections.ListChangeListener) AlertType(javafx.scene.control.Alert.AlertType) Locale(java.util.Locale) Map(java.util.Map) Hershey(com.github.lindenb.jvarkit.util.Hershey) CloserUtil(htsjdk.samtools.util.CloserUtil) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) Rectangle2D(javafx.geometry.Rectangle2D) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) GraphicsContext(javafx.scene.canvas.GraphicsContext) JfxLauncher(com.github.lindenb.jvarkit.util.jcommander.JfxLauncher) Logger(com.github.lindenb.jvarkit.util.log.Logger) Set(java.util.Set) Canvas(javafx.scene.canvas.Canvas) Spinner(javafx.scene.control.Spinner) Screen(javafx.stage.Screen) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) SmartComparator(com.github.lindenb.jvarkit.lang.SmartComparator) ScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy) TextInputDialog(javafx.scene.control.TextInputDialog) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) ObservableList(javafx.collections.ObservableList) IntStream(java.util.stream.IntStream) Scene(javafx.scene.Scene) ListView(javafx.scene.control.ListView) ButtonType(javafx.scene.control.ButtonType) BedLineCodec(com.github.lindenb.jvarkit.util.bio.bed.BedLineCodec) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) Interval(htsjdk.samtools.util.Interval) Insets(javafx.geometry.Insets) IOUtils(com.github.lindenb.jvarkit.io.IOUtils) GridPane(javafx.scene.layout.GridPane) Locatable(htsjdk.samtools.util.Locatable) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) File(java.io.File) Menu(javafx.scene.control.Menu) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) FileChooser(javafx.stage.FileChooser) SelectionMode(javafx.scene.control.SelectionMode) Stage(javafx.stage.Stage) BufferedReader(java.io.BufferedReader) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) Button(javafx.scene.control.Button) FileChooser(javafx.stage.FileChooser) TextField(javafx.scene.control.TextField) Menu(javafx.scene.control.Menu) Pattern(java.util.regex.Pattern) GridPane(javafx.scene.layout.GridPane) Canvas(javafx.scene.canvas.Canvas) Rectangle2D(javafx.geometry.Rectangle2D) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Scene(javafx.scene.Scene) SmartComparator(com.github.lindenb.jvarkit.lang.SmartComparator) ScrollPane(javafx.scene.control.ScrollPane) BufferedReader(java.io.BufferedReader) Alert(javafx.scene.control.Alert) File(java.io.File) VBox(javafx.scene.layout.VBox)

Example 25 with SeparatorMenuItem

use of javafx.scene.control.SeparatorMenuItem in project jvarkit by lindenb.

the class VcfStage method createJavascriptSnippetMenu.

@Override
protected Menu createJavascriptSnippetMenu() {
    final Menu menu = super.createJavascriptSnippetMenu();
    menu.getItems().add(new SeparatorMenuItem());
    MenuItem item = new MenuItem("Insert Samples' name as Array");
    menu.getItems().add(item);
    item.setOnAction(AE -> {
        final int caret = super.javascriptArea.getCaretPosition();
        final StringBuilder sb = new StringBuilder("var sampleNames=[").append(getVcfFile().getHeader().getSampleNamesInOrder().stream().map(S -> "\"" + S + "\"").collect(Collectors.joining(","))).append("];\n");
        super.javascriptArea.insertText(caret, sb.toString());
    });
    return menu;
}
Also used : Arrays(java.util.Arrays) VCFHeader(htsjdk.variant.vcf.VCFHeader) ChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ChartFactory) VariantContextChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantContextChartFactory) ScrollPane(javafx.scene.control.ScrollPane) TabPane(javafx.scene.control.TabPane) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) VariantDepthChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantDepthChartFactory) Map(java.util.Map) AlleleFrequencyChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AlleleFrequencyChartFactory) CloserUtil(htsjdk.samtools.util.CloserUtil) Rectangle2D(javafx.geometry.Rectangle2D) SplitPane(javafx.scene.control.SplitPane) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GenotypeBuilder(htsjdk.variant.variantcontext.GenotypeBuilder) GraphicsContext(javafx.scene.canvas.GraphicsContext) AFByPopulationChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AFByPopulationChartFactory) TiTvChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.TiTvChartFactory) Set(java.util.Set) Screen(javafx.stage.Screen) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ArcType(javafx.scene.shape.ArcType) Separator(javafx.scene.control.Separator) PieChart(javafx.scene.chart.PieChart) BooleanProperty(javafx.beans.property.BooleanProperty) FlowPane(javafx.scene.layout.FlowPane) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Genotype(htsjdk.variant.variantcontext.Genotype) CloseableIterator(htsjdk.samtools.util.CloseableIterator) OutputType(htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder.OutputType) FXCollections(javafx.collections.FXCollections) TextFlow(javafx.scene.text.TextFlow) Supplier(java.util.function.Supplier) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) TabClosingPolicy(javafx.scene.control.TabPane.TabClosingPolicy) SequenceOntologyTree(com.github.lindenb.jvarkit.util.so.SequenceOntologyTree) VCFConstants(htsjdk.variant.vcf.VCFConstants) Counter(com.github.lindenb.jvarkit.util.Counter) Color(javafx.scene.paint.Color) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) AFBySexChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AFBySexChartFactory) File(java.io.File) Menu(javafx.scene.control.Menu) FileChooser(javafx.stage.FileChooser) Tab(javafx.scene.control.Tab) CompiledScript(javax.script.CompiledScript) AnnPredictionParserFactory(com.github.lindenb.jvarkit.util.vcf.predictions.AnnPredictionParserFactory) VCFFormatHeaderLine(htsjdk.variant.vcf.VCFFormatHeaderLine) ObservableValue(javafx.beans.value.ObservableValue) VariantTypeChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantTypeChartFactory) EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) Allele(htsjdk.variant.variantcontext.Allele) VariantContextWriterBuilder(htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder) VBox(javafx.scene.layout.VBox) AlertType(javafx.scene.control.Alert.AlertType) ContextMenu(javafx.scene.control.ContextMenu) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) Orientation(javafx.geometry.Orientation) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) PatternSyntaxException(java.util.regex.PatternSyntaxException) MenuItem(javafx.scene.control.MenuItem) Predicate(java.util.function.Predicate) VariantQualChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantQualChartFactory) GenotypeType(htsjdk.variant.variantcontext.GenotypeType) Font(javafx.scene.text.Font) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Text(javafx.scene.text.Text) List(java.util.List) Paint(javafx.scene.paint.Paint) Term(com.github.lindenb.jvarkit.util.so.SequenceOntologyTree.Term) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) Optional(java.util.Optional) VariantContext(htsjdk.variant.variantcontext.VariantContext) Pattern(java.util.regex.Pattern) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) Scene(javafx.scene.Scene) AnnPredictionParser(com.github.lindenb.jvarkit.util.vcf.predictions.AnnPredictionParser) ButtonType(javafx.scene.control.ButtonType) Function(java.util.function.Function) TableColumn(javafx.scene.control.TableColumn) Interval(htsjdk.samtools.util.Interval) Insets(javafx.geometry.Insets) VepPredictionParser(com.github.lindenb.jvarkit.util.vcf.predictions.VepPredictionParser) VepPredictionParserFactory(com.github.lindenb.jvarkit.util.vcf.predictions.VepPredictionParserFactory) Callback(javafx.util.Callback) GenotypeTypeChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.GenotypeTypeChartFactory) VCFFilterHeaderLine(htsjdk.variant.vcf.VCFFilterHeaderLine) Label(javafx.scene.control.Label) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Paint(javafx.scene.paint.Paint)

Aggregations

SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)26 MenuItem (javafx.scene.control.MenuItem)24 ContextMenu (javafx.scene.control.ContextMenu)15 Menu (javafx.scene.control.Menu)12 ArrayList (java.util.ArrayList)10 List (java.util.List)8 ObservableList (javafx.collections.ObservableList)8 Collectors (java.util.stream.Collectors)7 Label (javafx.scene.control.Label)7 VBox (javafx.scene.layout.VBox)7 File (java.io.File)6 Scene (javafx.scene.Scene)6 IOException (java.io.IOException)5 FXCollections (javafx.collections.FXCollections)5 Insets (javafx.geometry.Insets)5 Node (javafx.scene.Node)4 TextField (javafx.scene.control.TextField)4 Arrays (java.util.Arrays)3 Map (java.util.Map)3 Optional (java.util.Optional)3