Java 类javafx.scene.control.ContextMenu 实例源码

项目:FEFEditor    文件:Person.java   
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    try {
        person = new FatesPerson(FileData.getInstance().getWorkingFile());
        updateList();
    } catch (Exception e) {
        e.printStackTrace();
    }

    ContextMenu contextMenu = new ContextMenu();
    addBlock = new MenuItem("Add Block");
    removeBlock = new MenuItem("Remove Block");
    contextMenu.getItems().add(addBlock);
    contextMenu.getItems().add(removeBlock);
    personList.setContextMenu(contextMenu);

    addListeners();
}
项目:marathonv5    文件:JavaFXTargetLocator.java   
private List<Window> getContextMenu() {
    List<Window> contextMenus = new ArrayList<>();
    new Wait("Unable to context menu") {
        @Override public boolean until() {
            @SuppressWarnings({ "deprecation" })
            Iterator<Window> windows = Window.impl_getWindows();
            while (windows.hasNext()) {
                Window window = windows.next();
                if (window instanceof ContextMenu) {
                    contextMenus.add(window);
                }
            }
            return contextMenus.size() > 0;
        }
    };
    ;
    return contextMenus;
}
项目:WebPLP    文件:Main.java   
private ConsolePane createConsole()
{
    ConsolePane console = new ConsolePane();
    ContextMenu contextMenu = new ContextMenu();

    MenuItem clearConsoleItem = new MenuItem("Clear");
    clearConsoleItem.setOnAction(e -> console.clear());
    contextMenu.getItems().add(clearConsoleItem);

    console.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
        contextMenu.show(console, event.getScreenX(), event.getScreenY());
        event.consume();
    });
    console.setOnMouseClicked(event -> {
        if (event.getButton() == MouseButton.PRIMARY)
            contextMenu.hide();
    });

    return console;
}
项目:CalendarFX    文件:ContextMenuProvider.java   
@Override
public ContextMenu call(ContextMenuParameter param) {
    DateControl control = param.getDateControl();
    ContextMenu contextMenu = null;

    /*
     * Check for WeekDayView first because it is a specialization of
     * DayView. Otherwise we would always return the context menu of
     * DayView.
     */
    if (control instanceof WeekDayView) {
        contextMenu = getWeekDayViewMenu(param);
    } else if (control instanceof DayView) {
        contextMenu = getDayViewMenu(param);
    } else if (control instanceof AllDayView) {
        contextMenu = getAllDayViewMenu(param);
    }

    if (contextMenu == null || contextMenu.getItems().isEmpty()) {
        return null;
    }

    return contextMenu;
}
项目:CalendarFX    文件:ContextMenuProvider.java   
/**
 * Returns the context menu specific for a single {@link WeekDayView}. Week
 * day views are used inside a {@link WeekView}.
 *
 * @param param
 *            parameter object with the most relevant information for
 *            creating a new context menu
 * @return a context menu for a week day view
 */
protected ContextMenu getWeekDayViewMenu(ContextMenuParameter param) {
    ContextMenu contextMenu = getDayViewBaseMenu(param);

    WeekDayView weekDayView = (WeekDayView) param.getDateControl();
    WeekView weekView = weekDayView.getWeekView();
    Menu daysMenu = new Menu(Messages.getString("ContextMenuProvider.SHOW_DAYS")); //$NON-NLS-1$
    int[] days = new int[]{5, 7, 14, 21, 28};
    for (int d : days) {
        String itemText = MessageFormat.format(Messages.getString("ContextMenuProvider.DAYS"), d); //$NON-NLS-1$
        MenuItem item = new MenuItem(itemText);
        item.setOnAction(evt -> weekView.setNumberOfDays(d));
        daysMenu.getItems().add(item);
    }

    contextMenu.getItems().add(daysMenu);

    return contextMenu;
}
项目:CalendarFX    文件:ContextMenuProvider.java   
/**
 * Returns the context menu specific for an {@link AllDayView}.
 *
 * @param param
 *            parameter object with the most relevant information for
 *            creating a new context menu
 * @return a context menu for an all day view
 */
protected ContextMenu getAllDayViewMenu(ContextMenuParameter param) {
    ContextMenu contextMenu = new ContextMenu();

    DateControl control = param.getDateControl();
    if (control instanceof AllDayView) {
        MenuItem newEntry = new MenuItem(Messages.getString("ContextMenuProvider.ADD_NEW_EVENT")); //$NON-NLS-1$
        newEntry.setOnAction(evt -> {
            control.createEntryAt(param.getZonedDateTime());
            contextMenu.hide();
        });
        contextMenu.getItems().add(newEntry);
    }

    if (contextMenu.getItems().isEmpty()) {
        return null;
    }

    return contextMenu;
}
项目:vars-annotation    文件:AssocButtonFactory.java   
public Button build(String name, Association association) {

        EventBus eventBus = toolBox.getEventBus();

        Button button = new JFXButton(name);
        button.setUserData(association);
        button.getStyleClass().add("abpanel-button");
        button.setOnAction(event -> {
            ArrayList<Annotation> annotations = new ArrayList<>(toolBox.getData().getSelectedAnnotations());
            eventBus.send(new CreateAssociationsCmd(association, annotations));
        });
        button.setTooltip(new Tooltip(association.toString()));

        ContextMenu contextMenu = new ContextMenu();
        MenuItem deleteButton = new MenuItem(toolBox.getI18nBundle().getString("cbpanel.conceptbutton.delete"));
        deleteButton.setOnAction(event ->
                ((Pane) button.getParent()).getChildren().remove(button));
        contextMenu.getItems().addAll(deleteButton);
        button.setContextMenu(contextMenu);

        return button;

    }
项目:SystemMonitorJFX    文件:MainStage.java   
private void initTableContextMenu() {
      TextField textField = new TextField("Type Something"); // we will add a popup menu to this text field
      contextMenu = new ContextMenu();

      MenuItem pauseP = new MenuItem("Stop process");
pauseP.setId("pausep");

MenuItem continueP = new MenuItem("Continue process");
continueP.setId("continuep");

MenuItem killP = new MenuItem("Kill process");
killP.setId("killp");

pauseP.setOnAction(actionEventHandler);
continueP.setOnAction(actionEventHandler);
killP.setOnAction(actionEventHandler);


      contextMenu.getItems().addAll(pauseP, continueP, new SeparatorMenuItem(), killP);
      // ...
      textField.setContextMenu(contextMenu);
  }
项目:Cognizant-Intelligent-Test-Scripter    文件:HelpBrowser.java   
@Override
public void load() {
    super.load();
    Platform.runLater(new Runnable() { // this will run initFX as JavaFX-Thread
        @Override
        public void run() {
            webView.setContextMenuEnabled(false);
            contextMenu = new ContextMenu();
            open = new MenuItem("Open in browser");
            addActionListener();
            addContextMenuListener();
            contextMenu.getItems().addAll(open);
        }
    });

}
项目:TechnicalAnalysisTool    文件:MarketDataTreeViewNode.java   
private void createConextMenu() {
    MenuItem contextRefresh = new MenuItem("Refresh");
    contextRefresh.setOnAction(e->{
        buildEntireTree();
        expandTreeView(root);
    });
    MenuItem contextOpen = new MenuItem("Open chart");
    contextOpen.setOnAction(e->{
        openSelectedChart();
    });
    MenuItem contextCollapse = new MenuItem("Collapse Nodes");
    contextCollapse.setOnAction(e->{
        collapseTreeView(root);
    });
    contextMenu = new ContextMenu(contextOpen, contextRefresh, contextCollapse);
    contextMenu.setPrefWidth(250);
}
项目:fx-animation-editor    文件:KeyFrameTimeLabel.java   
private void configureTextField() {
    ClampedDoubleStringConverter stringConverter = new ClampedDoubleStringConverter();
    stringConverter.setMin(MIN_TIME);
    stringConverter.setMax(MAX_TIME);
    stringConverter.setNullValue(DEFAULT_TIME);
    stringConverter.setDecimalPlaces(-1);
    stringConverter.setFormat(FORMAT);
    textField.setTextFormatter(new NonNegativeDoubleTextFormatter());
    textField.setContextMenu(new ContextMenu());
    TextFieldHelper.bind(textField, textFieldValue, stringConverter, null);
    TextFieldHelper.executeOnFocusLostOrEnter(textField, () -> {
        requestFocus();
        setEditMode(false);
        onCommit();
    });
}
项目:cayenne-modeler    文件:ObjectEntityTreeItem.java   
@Override
public ContextMenu getContextMenu()
{
    ContextMenu contextMenu  = new ContextMenu();
    ObjEntity   objectEntity = (ObjEntity) getPropertyAdapter().getWrappedObject();

    getPropertyAdapter().getDataMapAdapter().getDatabaseEntityAdapters().stream().forEach(databaseEntity ->
        {
            if (StringUtils.equals(databaseEntity.getName(), objectEntity.getDbEntityName()))
            {
                MenuItem jumpTo = new MenuItem("Jump To Database Entity: " + databaseEntity.getName());

                jumpTo.setMnemonicParsing(false);
                jumpTo.setOnAction(event ->
                    {
                        LOGGER.debug("Jumping to DB Entity: " + databaseEntity.getName());
                    });

                contextMenu.getItems().add(jumpTo);
            }
        });

  return contextMenu;
}
项目:willow-browser    文件:BookmarkHandler.java   
/**
 * @param chrome        the browser chrome the bookmark is to control.
 * @param bookmarksMenu the menu into which the bookmark is to be installed.
 * @param bookmarkName  the name of the bookmark.
 * @param bookmarkUrl   the url of the bookmark.
 *
 * @return true if the bookmark was not already installed in the chrome, otherwise false.
 */
public static boolean installBookmark(
        final Willow chrome,
        final ContextMenu bookmarksMenu,
        final String bookmarkName,
        final String bookmarkUrl
) {
    for (MenuItem item : bookmarksMenu.getItems()) {
        if (item.getText().equals(bookmarkName)) {
            return false;
        }
    }

    final MenuItem menuItem = new MenuItem(bookmarkName);
    menuItem.setOnAction(actionEvent -> chrome.getBrowser().navTo(bookmarkUrl));
    bookmarksMenu.getItems().add(menuItem);

    return true;
}
项目:willow-browser    文件:History.java   
/**
 * @return a new context menu for a range of history items.
 */
private ContextMenu createMenu() {
    // a menu of history items.
    final ContextMenu historyMenu = new ContextMenu();

    // determine an appropriate subset range of the history list to display.
    int minIdx = Math.max(0, pointer - 8); // min range (inclusive) of history items to show.
    int maxIdx = Math.min(items.size(), pointer + 6); // min range (exclusive) of history items to show.

    // add menu items to the history list.
    for (int i = maxIdx - 1; i >= minIdx; i--) {
        final MenuItem nextMenu = createMenuItem(items.get(i), i);
        historyMenu.getItems().add(nextMenu);
        if (i == pointer) {
            nextMenu.getStyleClass().add("current-menu");
        }
    }

    return historyMenu;
}
项目:Gargoyle    文件:DaoWizardViewController.java   
/**
 * tbParam 테이블의 컨텍스트 메뉴 적용
 *
 * @작성자 : KYJ
 * @작성일 : 2015. 10. 22.
 */
private void tbParamContextMenu() {

    MenuItem menuItemExtractFromQuery = new MenuItem("Extract from Query");
    menuItemExtractFromQuery.setOnAction(this::menuItemExtractFromQueryOnAction);

    MenuItem menuItemRemove = new MenuItem("Remove Var.");
    menuItemRemove.setOnAction(this::menuItemRemoveOnAction);
    // 사실 이 항목은 필요없을것같음.
    // MenuItem addMenuItem = new MenuItem("Add");
    // addMenuItem.setOnAction(this::addMenuParamOnAction);
    // MenuItem deleteMenuItem = new MenuItem("Delete");
    // deleteMenuItem.setOnAction(this::deleteMenuParamOnAction);

    tbParams.setContextMenu(new ContextMenu(menuItemExtractFromQuery, menuItemRemove));

}
项目:Gargoyle    文件:CommonsContextMenu.java   
/**
 * 컨텍스트 메뉴 추가.
 *
 * @Date 2015. 10. 14.
 * @param tableView
 * @param mode
 *            Menus 클래스 참고
 * @return
 * @User KYJ
 */
public static void addMenus(Control node, int mode) {
    ContextMenu contextMenu = new ContextMenu();

    if (Menus.isAdd(mode)) {
        contextMenu.getItems().add(addMenuEvent(node));
    }

    if (Menus.isDelete(mode)) {
        contextMenu.getItems().add(deleteMenuEvent(node));
    }

    if (Menus.isUp(mode)) {
        contextMenu.getItems().add(upMenuEvent(node));
    }

    if (Menus.isDown(mode)) {
        contextMenu.getItems().add(downMenuEvent(node));
    }

    node.setContextMenu(contextMenu);
}
项目:Gargoyle    文件:ScmCommitComposite.java   
@Override
public void init() {
    MenuItem miReflesh = new MenuItem("Reflesh");
    miReflesh.setOnAction(ex -> {


        getLineChartDayOfWeek().getData().clear();
        getLineChartDayOfWeekCategory().getCategories().clear();
        getBarChartDayOfMonth().getData().clear();
        getBarChartDayOfMonthCategory().getCategories().clear();
        load();
    });

    ContextMenu contextMenu = new ContextMenu(miReflesh);

    this.addEventFilter(MouseEvent.MOUSE_CLICKED, ev -> {
        contextMenu.hide();
        if (ev.getButton() == MouseButton.SECONDARY) {

            contextMenu.show(FxUtil.getWindow(this), ev.getScreenX(), ev.getScreenY());
        }
    });
}
项目:Gargoyle    文件:LogViewController.java   
protected void createContextMenu() {
    ContextMenu contextMenu = new ContextMenu();
    txtLog.setContextMenu(contextMenu);

    MenuItem e = new MenuItem("EMRService Log Viewer");
    e.setOnAction(ev -> {
        EMRServiceLogTableViewHelper helper = new EMRServiceLogTableViewHelper(this.txtLog.getText());

        FxUtil.createStageAndShow(helper.getView(), stage -> {
            stage.initOwner(FxUtil.getWindow(composite.getParent()));
            stage.setTitle("EMRService Log Viewer");
            stage.setWidth(1200d);
            stage.setHeight(800d);
        });

        helper.start();
    });
    contextMenu.getItems().add(e);

}
项目:standalone-app    文件:HexEditorView.java   
@Override
protected Node createView0(OpenedFile file, String path) {
    HexArea editor = new HexArea();
    editor.setContent(file.getContent(path));

    ContextMenu newContextMenu = new ContextMenu();
    MenuItem save = new MenuItem("Save");
    save.setOnAction(e -> {
        save(editor).whenComplete((res, err) -> {
            if (err != null) {
                err.printStackTrace();
            } else {
                file.putContent(path, res);
            }
        });
    });
    newContextMenu.getItems().add(save);
    editor.setContextMenu(newContextMenu);

    return editor;
}
项目:standalone-app    文件:AllFilesViewerController.java   
public void openOpenNewTabMenu() {
    if (root.getSelectionModel().getSelectedItem() != null) {
        Tab selectedFile = root.getSelectionModel().getSelectedItem();
        ContextMenu contextMenu = new ContextMenu();
        for (EditorView ev : editorController.getRegisteredEditors()) {
            MenuItem item = new MenuItem(ev.getDisplayName());
            item.setOnAction(event -> {
                openNewEditor(selectedFile, ev);
            });
            contextMenu.getItems().add(item);
        }
        contextMenu.setOnHidden(event -> {
            isMenuOpen = false;
        });
        Point p = MouseInfo.getPointerInfo().getLocation();
        contextMenu.show(root.getScene().getWindow(), p.x, p.y);
    }
}
项目:particlesfx    文件:Main.java   
public void addContextMenu( Node node) {

        MenuItem menuItem;

        // create context menu
        ContextMenu contextMenu = new ContextMenu();

        // add attractor
        menuItem = new MenuItem("Add Attractor");
        menuItem.setOnAction(e -> addAttractor());
        contextMenu.getItems().add( menuItem);

        // add repeller
        menuItem = new MenuItem("Add Repeller");
        menuItem.setOnAction(e -> addRepeller());
        contextMenu.getItems().add( menuItem);

        // context menu listener
        node.setOnMousePressed(event -> {
            if (event.isSecondaryButtonDown()) {
                contextMenu.show(node, event.getScreenX(), event.getScreenY());
            }
        });
    }
项目:arma-dialog-creator    文件:ADCCanvasView.java   
private void initializeUICanvasEditor(@NotNull ArmaDisplay display) {
    canvasControls.getTreeViewMain().setToDisplay(display);
    canvasControls.getTreeViewBackground().setToDisplay(display);

    uiCanvasEditor.setComponentMenuCreator(new ComponentContextMenuCreator() {
        @Override
        public @NotNull ContextMenu initialize(CanvasComponent component) {
            return new DefaultComponentContextMenu(((ArmaControlRenderer) component).getMyControl());
        }
    });
    uiCanvasEditor.getDoubleClickUpdateGroup().addListener((group, clickedControl) -> {
        if (clickedControl != null && clickedControl == uiCanvasEditor.getSelection().getFirst()) {
            DefaultComponentContextMenu.showControlPropertiesPopup((ArmaControl) clickedControl);
        }
    });
    uiCanvasEditor.setCanvasContextMenu(new CanvasContextMenu());
    setupEditorSelectionSync();
}
项目:openjfx-8u-dev-tests    文件:TabPaneApp2.java   
protected void reset() {
    tabPane.getTabs().clear();
    eventList.getItems().clear();
    for (int i = 0; i < TABS_NUM; i++) {
        Tab tab = new NamedTab("Tab " + i);
        tab.setTooltip(new Tooltip("Tab " + i));
        ContextMenu menu = new ContextMenu();
        for (int j = 0; j < 3; j++) {
            menu.getItems().add(new MenuItem("Tab " + i + " menu item " + j));
        }
        tab.setContextMenu(menu);
        if (tab.getContextMenu() != menu) {
            error.setText("tab.setContextMenu() fails");
        }
        tabPane.getTabs().add(tab);
    }
    tabPane.setSide(Side.TOP);
    error.setText("");
}
项目:openjfx-8u-dev-tests    文件:SwingContextMenuApp.java   
private void createScene(JFXPanel fxMainPanel) {
    redPane = new StackPane();
    redPane.setPrefSize(100.0, 100.0);
    redPane.setStyle("-fx-background-color: red");
    ContextMenu contextMenu = new ContextMenu();
    MenuItem menuItem = new MenuItem("Test Menu Item");
    contextMenu.getItems().add(menuItem);

    redPane.setOnContextMenuRequested(event -> {
        contextMenu.show(redPane, event.getScreenX(), event.getScreenY());
        event.consume();
    });
    contextMenu.showingProperty().addListener(this::onchange);
    scene = new Scene(redPane);
    fxMainPanel.setScene(scene);
    robot.setAutoWaitForIdle(true);
}
项目:openjfx-8u-dev-tests    文件:ScrollEventApp.java   
private void initContextMenu() {
    contextMenu = new ContextMenu();
    contextMenu.setId(CONTEXT_MENU_ID);
    for(int i = 1; i <= 5; i++) {
        contextMenu.getItems().add(new MenuItem("item - " + i));
    }

    contextMenu.setOnShown(new EventHandler<WindowEvent>() {
        public void handle(WindowEvent t) {
            TextField tfCounter = hm.get(Options.contextMenuOnShown.toString());
            assertTrue(tfCounter != null);

            String text = tfCounter.getText();
            if (text.equals("")) {
                tfCounter.setText("1");
            } else {
                int val = Integer.parseInt(text);
                val++;
                tfCounter.setText(String.valueOf(val));
            }
        }
    });
}
项目:openjfx-8u-dev-tests    文件:MenuItemTest.java   
@Smoke
@Test(timeout = 300000)
public void radioSizingTest() throws Throwable {
    Wrap<? extends Menu> menu = menuBarAsParent.lookup(new MenuByText(MenuItemApp.RADIO_ID)).wrap();
    Parent<MenuItem> menu_as_parent = menu.as(Parent.class, MenuItem.class);
    expand(menu, true);
    final Scene popup_scene = Root.ROOT.lookup(new LookupCriteria<Scene>() {
        public boolean check(Scene scene) {
            if (!(scene.getWindow() instanceof ContextMenu)) {
                return false;
            }
            return true;
        }
    }).get();
    Double width = getWidth(popup_scene);
    Double height = getHeight(popup_scene);
    for (int i = 0; i < menu_as_parent.lookup().size(); i++) {
        Wrap<? extends MenuItem> item_wrap = menu_as_parent.lookup().wrap(i);
        item_wrap.mouse().move();
        Double new_width = getWidth(popup_scene);
        Double new_height = getHeight(popup_scene);
        assertEquals(width, new_width);
        assertEquals(height, new_height);
    }
}
项目:slogo    文件:TurtleView.java   
private ContextMenu establishContextMenu () {
    ContextMenu context = new ContextMenu();
    MenuItem turtleStatus = new MenuItem(TURTLE_STATUS + id);
    SeparatorMenuItem separator = new SeparatorMenuItem();

    MenuItem visibility = new MenuItem(TOGGLE_VISIBILITY_PROMPT);
    visibility.setOnAction(e -> visibilityAction());

    MenuItem shape = new MenuItem(CHANGE_SHAPE_PROMPT);
    shape.setOnAction(e -> shapeAction());

    MenuItem color = new MenuItem(CHANGE_TURTLE_PEN_COLOR);
    color.setOnAction(e -> colorAction());

    MenuItem stamp = new MenuItem(STAMP);
    stamp.setOnAction(e -> writeToInternalEditor(new StringBuilder(idsToCommands.getString((STAMP)))));

    context.getItems().addAll(turtleStatus,
                              separator,
                              visibility,
                              color,
                              shape,
                              stamp);

    return context;
}
项目:corona-ide    文件:ProjectListCell.java   
@Override
protected void updateItem(Project item, boolean empty) {
    super.updateItem(item, empty);
    if (empty || item == null) {
        setText(null);
        setGraphic(null);
    } else {
        this.item = Objects.requireNonNull(item);
        setText(item.getName());

        ContextMenu contextMenu = new ContextMenu();
        MenuItem menuDelete = new MenuItem();
        menuDelete.setText("Delete");
        menuDelete.setOnAction(this::deleteMenuAction);
        contextMenu.getItems().addAll(menuDelete);
        setContextMenu(contextMenu);
    }
}
项目:jfiles    文件:ClientAppViewController.java   
/**
 * Builds context menu for files.
 *
 * @return context menu
 */
private ContextMenu buildFileContextMenu() {
    ContextMenu menu = new ContextMenu();

    MenuItem cut = new MenuItem("Cut");
    MenuItem copy = new MenuItem("Copy");
    MenuItem paste = new MenuItem("Paste");
    MenuItem delete = new MenuItem("Delete");
    menu.getItems().addAll(cut, copy, paste, delete);

    cut.setOnAction(event -> cut());
    copy.setOnAction(event -> copy());
    paste.setOnAction(event -> paste());
    delete.setOnAction(event -> delete());

    return menu;
}
项目:Maus    文件:FileContextMenu.java   
public static void getFileContextMenu(HBox fileIcon, String fileName, MouseEvent e, ClientObject client) {
    ContextMenu cm = new ContextMenu();
    MenuItem sb1 = new MenuItem("Delete File");
    MenuItem sb2 = new MenuItem("Download File");
    sb2.setOnAction(event -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        directoryChooser.setTitle("Select download location");
        File selectedDirectory =
                directoryChooser.showDialog(Maus.getPrimaryStage());
        FileContextMenu.selectedDirectory = selectedDirectory.getAbsolutePath();
        try {
            client.clientCommunicate("DOWNLOAD");
            client.clientCommunicate(fileName);
        } catch (IOException e1) {
            Logger.log(Level.ERROR, e1.toString());
        }
    });
    cm.getItems().addAll(sb1, sb2);
    cm.show(fileIcon, e.getScreenX(), e.getScreenY());
}
项目:story-inspector    文件:ReportSectionTab.java   
@Override
protected ContextMenu generateContextMenu(final Analyzer<?> analyzer) {
    final ContextMenu menu = new ContextMenu();

    final MenuItem edit = new MenuItem("Edit");
    edit.setOnAction(e -> editAnalyzer(analyzer));

    final MenuItem save = new MenuItem("Save As Custom");
    save.setOnAction(e -> saveAnalyzers(ReportSectionTab.this.analyzerListView.getSelectionModel().getSelectedItems()));

    final MenuItem delete = new MenuItem("Delete");
    delete.setOnAction(e -> deleteAnalyzers(ReportSectionTab.this.analyzerListView.getSelectionModel().getSelectedItems()));

    menu.getItems().add(edit);
    menu.getItems().add(save);
    menu.getItems().add(delete);
    return menu;
}
项目:story-inspector    文件:AnalyzerPaneController.java   
@Override
protected ContextMenu generateContextMenu(final CustomAnalyzer<?> customAnalyzer) {
    final ContextMenu menu = new ContextMenu();

    final MenuItem edit = new MenuItem("Edit");
    edit.setOnAction(e -> editAnalyzer(customAnalyzer));
    final MenuItem clone = new MenuItem("Clone");
    clone.setOnAction(e -> cloneAnalyzer(customAnalyzer.getAnalyzer()));
    final MenuItem add = new MenuItem("Add To Report");
    add.setOnAction(e -> addAnalyzers(AnalyzerPaneController.this.customAnalyzersListView.getSelectionModel().getSelectedItems().stream()
            .map(c -> c.getAnalyzer()).collect(Collectors.toList())));
    final MenuItem delete = new MenuItem("Delete");
    delete.setOnAction(e -> deleteAnalyzers(AnalyzerPaneController.this.customAnalyzersListView.getSelectionModel().getSelectedItems()));

    menu.getItems().add(edit);
    menu.getItems().add(add);
    menu.getItems().add(clone);
    menu.getItems().add(delete);
    return menu;
}
项目:binjr    文件:ContextMenuTableViewCell.java   
public static <S, T> Callback<TableColumn<S, T>, TableCell<S, T>> forTableColumn(final ContextMenu contextMenu, final Callback<TableColumn<S, T>, TableCell<S, T>> cellFactory) {
    return column -> {
        TableCell<S, T> cell;
        if (cellFactory == null) {
            cell = new TableCell<S, T>();
            cell.itemProperty().addListener((observable, oldValue, newValue) -> {
                cell.setText(newValue == null ? null : newValue.toString());
            });
        }
        else {
            cell = cellFactory.call(column);
        }
        cell.setContextMenu(contextMenu);
        return cell;
    };
}
项目:viskell    文件:MainOverlay.java   
/**
 * Make a Pane that contains a Context menu that can be displayed on-screen
 *
 * @param menuActions that can be performed
 *
 * @return Menu Pane
 */
private Pane makeMenuPane(MenuActions menuActions) {
    ContextMenu burgerMenu = new GlobalContextMenu(menuActions);
    Button menu = new Button(MENU_LABEL);
    menu.setFocusTraversable(false);
    menu.setContextMenu(burgerMenu);
    menu.setOnAction(e -> menu.getContextMenu().show(menu, Side.BOTTOM, 0, 10));

    FlowPane toolBar = new FlowPane(10, 0, menu);

    toolBar.setMaxHeight(40);
    toolBar.setMaxWidth(40); // workaround to make it not confiscate the whole top of the screen
    toolBar.setPadding(new Insets(10));
    toolBar.getStyleClass().add("overlayButtons");

    return toolBar;
}
项目:standalone-app    文件:HexEditorView.java   
@Override
protected Node createView0(OpenedFile file, String path) {
    HexArea editor = new HexArea();
    editor.setContent(file.getContent(path));

    ContextMenu newContextMenu = new ContextMenu();
    MenuItem save = new MenuItem("Save");
    save.setOnAction(e -> {
        save(editor).whenComplete((res, err) -> {
            if (err != null) {
                err.printStackTrace();
            } else {
                file.putContent(path, res);
            }
        });
    });
    newContextMenu.getItems().add(save);
    editor.setContextMenu(newContextMenu);

    return editor;
}
项目:standalone-app    文件:AllFilesViewerController.java   
public void openOpenNewTabMenu() {
    if (root.getSelectionModel().getSelectedItem() != null) {
        Tab selectedFile = root.getSelectionModel().getSelectedItem();
        ContextMenu contextMenu = new ContextMenu();
        for (EditorView ev : editorController.getRegisteredEditors()) {
            MenuItem item = new MenuItem(ev.getDisplayName());
            item.setOnAction(event -> {
                openNewEditor(selectedFile, ev);
            });
            contextMenu.getItems().add(item);
        }
        contextMenu.setOnHidden(event -> {
            isMenuOpen = false;
        });
        Point p = MouseInfo.getPointerInfo().getLocation();
        contextMenu.show(root.getScene().getWindow(), p.x, p.y);
    }
}
项目:FxIconics    文件:FxIconicsShowcase.java   
private void addContextMenuToLabel(Label label) {
    MenuItem miBlack = new MenuItem("black");
    MenuItem miRed = new MenuItem("red");
    MenuItem miYellow = new MenuItem("yellow");
    MenuItem miGreen = new MenuItem("green");
    MenuItem miBlue = new MenuItem("blue");
    MenuItem miOrange = new MenuItem("orange");
    MenuItem miPurple = new MenuItem("purple");
    MenuItem miPink = new MenuItem("pink");
    MenuItem miGrey = new MenuItem("grey");
    miBlack.setOnAction(event1 -> label.setStyle("-fx-text-fill: black; -fx-cursor: hand;"));
    miRed.setOnAction(event1 -> label.setStyle("-fx-text-fill: red; -fx-cursor: hand"));
    miYellow.setOnAction(event1 -> label.setStyle("-fx-text-fill: yellow; -fx-cursor: hand"));
    miGreen.setOnAction(event1 -> label.setStyle("-fx-text-fill: green; -fx-cursor: hand"));
    miBlue.setOnAction(event1 -> label.setStyle("-fx-text-fill: blue; -fx-cursor: hand"));
    miOrange.setOnAction(event1 -> label.setStyle("-fx-text-fill: orange; -fx-cursor: hand"));
    miPurple.setOnAction(event1 -> label.setStyle("-fx-text-fill: purple; -fx-cursor: hand"));
    miPink.setOnAction(event1 -> label.setStyle("-fx-text-fill: deeppink; -fx-cursor: hand"));
    miGrey.setOnAction(event1 -> label.setStyle("-fx-text-fill: grey; -fx-cursor: hand"));

    ContextMenu ctm = new ContextMenu();
    ctm.getItems().addAll(miBlack, miRed, miYellow, miGreen, miBlue, miOrange, miPurple, miPink, miGrey);
    label.setContextMenu(ctm);
}
项目:WhoWhatWhere    文件:VisualTraceController.java   
private void setTableContextMenu()
{
    tableTrace.setRowFactory(param ->
    {
        TableRow<TraceLineInfo> row = new TableRow<>();

        MenuItem moreGeoIPInfo = new MenuItem("  Show GeoIP results from multiple sources");
        moreGeoIPInfo.setOnAction(event9 -> Main.openInBrowser(GeoIPResolver.getSecondaryGeoIpPrefix() + row.getItem().ipAddressProperty().get()));

        Menu copyMenu = generateCopyMenu(row);

        ContextMenu rowMenu = new ContextMenu(moreGeoIPInfo, copyMenu);

        row.contextMenuProperty().bind(Bindings.when(Bindings.isNotNull(row.itemProperty())).then(rowMenu).otherwise((ContextMenu) null));

        return row;
    });
}
项目:WhoWhatWhere    文件:VisualTraceController.java   
private void setMapContextMenu()
{
    imgView.setOnContextMenuRequested(event ->
    {
        MenuItem copyMap = new MenuItem("  Copy map image");
        copyMap.setOnAction(mapEvent ->
        {
            Clipboard clipboard = Clipboard.getSystemClipboard();
            ClipboardContent content = new ClipboardContent();

            content.putImage(imgView.getImage());
            clipboard.setContent(content);
        });

        ContextMenu menu = new ContextMenu(copyMap);
        menu.show(imgView.getScene().getWindow(), event.getScreenX(), event.getScreenY());
    });
}
项目:StreamSis    文件:ActorContextMenuBuilder.java   
public static ContextMenu createCMForStructureViewList(ListView<Actor> listView) {
    ContextMenu cm = new ContextMenu();
    CustomMenuItem addActorMenuItem = GUIUtil.createTooltipedMenuItem("Add new",
            "Create new global Actor and add it to currently selected SisScene.\n\n"
                    + aboutActor);
    Menu addExistingActorMenuItem = generateAddExistingActorMenu(false);
    addActorMenuItem.setOnAction((ActionEvent event) -> {
        addNewActor();
    });
    cm.getItems().addAll(addActorMenuItem);
    if (addExistingActorMenuItem.getItems().size() != 0) {
        cm.getItems().add(addExistingActorMenuItem);
    }
    cm.autoHideProperty().set(true);
    return cm;
}