Search in sources :

Example 1 with ContextMenu

use of javafx.scene.control.ContextMenu in project TeachingInSimulation by ScOrPiOzzy.

the class DrawingController method addDrawingPreviewBtn.

private void addDrawingPreviewBtn(final Resource resource) {
    String url = utils.getFullPath(ResourceConsts.FTP_RES_PATH + resource.getPath());
    Image image = new Image(url, 70, 70, true, true);
    ImageView view = new ImageView(image);
    ToggleButton toggle = new ToggleButton();
    toggle.setGraphic(view);
    toggle.getStyleClass().add("drawing-btn");
    toggle.setUserData(resource);
    ContextMenu menu = new ContextMenu();
    MenuItem item = new MenuItem(MsgUtil.getMessage("button.delete"));
    item.setOnAction(e -> {
        AlertUtil.showConfirm(stage, MsgUtil.getMessage("alert.confirmation.data.delete"), resp -> {
            if (ButtonType.YES == resp) {
                drawings.remove(String.valueOf(resource.getId()));
                refresh();
            }
        });
    });
    menu.getItems().add(item);
    toggle.setContextMenu(menu);
    group.getToggles().add(toggle);
    btns.getChildren().add(toggle);
}
Also used : ToggleButton(javafx.scene.control.ToggleButton) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image)

Example 2 with ContextMenu

use of javafx.scene.control.ContextMenu in project TeachingInSimulation by ScOrPiOzzy.

the class TypicalCase3D method showPopupMenu.

/**
 * 显示元器件弹出菜单
 * @param def
 */
public void showPopupMenu(ElecCompDef def) {
    ContextMenu menu = null;
    String key = def.getProxy().getUuid();
    if (menus.containsKey(key)) {
        menu = menus.get(key);
    } else {
        MenuItem tag = new MenuItem(MsgUtil.getMessage("button.tag"));
        tag.setOnAction(e -> {
            TextInputDialog steamIdDialog = new TextInputDialog(def.getProxy().getTagName());
            steamIdDialog.setTitle(MsgUtil.getMessage("button.tag"));
            steamIdDialog.setHeaderText(null);
            steamIdDialog.getEditor().textProperty().addListener((b, o, n) -> {
                Pattern pat = Pattern.compile(REGEX_CHINESE);
                Matcher mat = pat.matcher(n);
                if (mat.find()) {
                    steamIdDialog.getEditor().setText(o);
                }
            });
            steamIdDialog.setContentText(MsgUtil.getMessage("typical.case.prompt.input.comp.tag"));
            steamIdDialog.showAndWait().ifPresent(tagName -> {
                def.getProxy().setTagName(tagName);
                CircuitState state = jmeApp.getStateManager().getState(CircuitState.class);
                if (state == null) {
                    return;
                }
                state.setTagNameChanged(true);
            });
        });
        MenuItem del = new MenuItem(MsgUtil.getMessage("button.delete"));
        del.setOnAction(e -> {
            CircuitState state = jmeApp.getStateManager().getState(CircuitState.class);
            if (state == null) {
                return;
            }
            boolean enable = state.detachFromCircuit(def);
            if (enable) {
                menus.remove(key);
            } else {
                AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.wiring"));
            }
        });
        menu = new ContextMenu(tag, del);
    }
    Point anchor = MouseInfo.getPointerInfo().getLocation();
    menu.show(GUIState.getStage(), anchor.x, anchor.y);
}
Also used : CircuitState(com.cas.sim.tis.app.state.CircuitState) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) Point(java.awt.Point) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 3 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class DockTabPaneSkin method removeTabs.

private void removeTabs(List<? extends DockTab> removedList) {
    for (final DockTab tab : removedList) {
        stopCurrentAnimation(tab);
        // Animate the tab removal
        final TabHeaderSkin tabRegion = tabHeaderArea.getTabHeaderSkin(tab);
        if (tabRegion != null) {
            tabRegion.isClosing = true;
            tabRegion.removeListeners(tab);
            removeTabContent(tab);
            // remove the menu item from the popup menu
            ContextMenu popupMenu = tabHeaderArea.controlButtons.popup;
            TabMenuItem tabItem = null;
            if (popupMenu != null) {
                for (MenuItem item : popupMenu.getItems()) {
                    tabItem = (TabMenuItem) item;
                    if (tab == tabItem.getTab()) {
                        break;
                    }
                    tabItem = null;
                }
            }
            if (tabItem != null) {
                tabItem.dispose();
                popupMenu.getItems().remove(tabItem);
            }
            // end of removing menu item
            EventHandler<ActionEvent> cleanup = ae -> {
                tabRegion.animationState = TabAnimationState.NONE;
                tabHeaderArea.removeTab(tab);
                tabHeaderArea.requestLayout();
                if (getSkinnable().getTabs().isEmpty()) {
                    tabHeaderArea.setVisible(false);
                }
            };
            if (closeTabAnimation.get() == TabAnimation.GROW) {
                tabRegion.animationState = TabAnimationState.HIDING;
                Timeline closedTabTimeline = tabRegion.currentAnimation = createTimeline(tabRegion, Duration.millis(ANIMATION_SPEED), 0.0F, cleanup);
                closedTabTimeline.play();
            } else {
                cleanup.handle(null);
            }
        }
    }
}
Also used : EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) Pos(javafx.geometry.Pos) PseudoClass(javafx.css.PseudoClass) Rotate(javafx.scene.transform.Rotate) EnumConverter(com.sun.javafx.css.converters.EnumConverter) LoggerFactory(org.slf4j.LoggerFactory) StackPane(javafx.scene.layout.StackPane) Side(javafx.geometry.Side) InvalidationListener(javafx.beans.InvalidationListener) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) BehaviorSkinBase(com.sun.javafx.scene.control.skin.BehaviorSkinBase) ControlResources.getString(com.sun.javafx.scene.control.skin.resources.ControlResources.getString) DockPos(com.kyj.fx.voeditor.visual.component.dock.pane.DockPos) DockPane(com.kyj.fx.voeditor.visual.component.dock.pane.DockPane) Point2D(javafx.geometry.Point2D) Pane(javafx.scene.layout.Pane) MultiplePropertyChangeListenerHandler(com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler) MenuItem(javafx.scene.control.MenuItem) AccessibleAttribute(javafx.scene.AccessibleAttribute) SingleSelectionModel(javafx.scene.control.SingleSelectionModel) DockEvent(com.kyj.fx.voeditor.visual.component.dock.pane.DockEvent) CssMetaData(javafx.css.CssMetaData) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) TraversalEngine(com.sun.javafx.scene.traversal.TraversalEngine) Observable(javafx.beans.Observable) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) WeakInvalidationListener(javafx.beans.WeakInvalidationListener) List(java.util.List) Duration(javafx.util.Duration) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) WeakListChangeListener(javafx.collections.WeakListChangeListener) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) AccessibleRole(javafx.scene.AccessibleRole) Styleable(javafx.css.Styleable) Bounds(javafx.geometry.Bounds) SkinBase(javafx.scene.control.SkinBase) RadioMenuItem(javafx.scene.control.RadioMenuItem) MouseButton(javafx.scene.input.MouseButton) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) DockNode(com.kyj.fx.voeditor.visual.component.dock.pane.DockNode) SwipeEvent(javafx.scene.input.SwipeEvent) ArrayList(java.util.ArrayList) TabClosingPolicy(javafx.scene.control.TabPane.TabClosingPolicy) VPos(javafx.geometry.VPos) AccessibleAction(javafx.scene.AccessibleAction) Direction(com.sun.javafx.scene.traversal.Direction) StyleableProperty(javafx.css.StyleableProperty) KeyValue(javafx.animation.KeyValue) Animation(javafx.animation.Animation) Tooltip(javafx.scene.control.Tooltip) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) Node(javafx.scene.Node) ScrollEvent(javafx.scene.input.ScrollEvent) DropShadow(javafx.scene.effect.DropShadow) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) Popup(javafx.stage.Popup) ActionEvent(javafx.event.ActionEvent) ToggleGroup(javafx.scene.control.ToggleGroup) StyleableObjectProperty(javafx.css.StyleableObjectProperty) Utils(com.sun.javafx.util.Utils) ImageView(javafx.scene.image.ImageView) WritableValue(javafx.beans.value.WritableValue) Collections(java.util.Collections) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) RadioMenuItem(javafx.scene.control.RadioMenuItem)

Example 4 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class SvnChagnedCodeComposite method createContextMenu.

/**
	 * 차트 위치를 복구하는 기능을 처리.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 7. 20.
	 * @param e
	 */
//	public void sceneOnKeyPressed(KeyEvent e) {
//		if (e.getCode() == KeyCode.ESCAPE) {
//
//			setRight(null);
//			e.consume();
//		}
//	}
/**
	 * @작성자 : KYJ
	 * @작성일 : 2016. 7. 20.
	 */
private void createContextMenu() {
    MenuItem miViewHistory = new MenuItem("View History");
    miViewHistory.setOnAction(ev -> {
        Node ownerNode = contextMenu.getOwnerNode();
        System.out.println(ownerNode);
        Node center = getCenter();
        if ((ownerNode != null && ownerNode instanceof Region) && (center != null && center == piChartChagendCode)) {
            Data userData = (Data) contextMenu.getUserData();
            if (userData != null) {
                String relativePath = userData.getName();
                ListView<GargoyleSVNLogEntryPath> createHistoryListView = supplier.createHistoryListView(relativePath);
                FxUtil.showPopOver(ownerNode, createHistoryListView);
            }
        }
    });
    contextMenu = new ContextMenu(miViewHistory);
}
Also used : Node(javafx.scene.Node) Region(javafx.scene.layout.Region) MenuItem(javafx.scene.control.MenuItem) Data(javafx.scene.chart.PieChart.Data) ContextMenu(javafx.scene.control.ContextMenu)

Example 5 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class DAOLoaderController method initialize.

@FXML
public void initialize() {
    txtSrchTable.setText("*");
    colSrchClassName.setCellValueFactory(param -> new SimpleObjectProperty<Object>(param.getValue().get("CLASS_NAME").toString()));
    colSrchPackageName.setCellValueFactory(param -> new SimpleObjectProperty<Object>(param.getValue().get("PACKAGE_NAME").toString()));
    MenuItem history = new MenuItem("history");
    history.setOnAction(this::menuHistoryOnAction);
    MenuItem menuRemove = new MenuItem("remove");
    menuRemove.setOnAction(this::menuRemoveOnAction);
    tbSrchDao.setContextMenu(new ContextMenu(history, menuRemove));
}
Also used : MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu) FXML(javafx.fxml.FXML)

Aggregations

ContextMenu (javafx.scene.control.ContextMenu)81 MenuItem (javafx.scene.control.MenuItem)69 ActionEvent (javafx.event.ActionEvent)21 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)20 Menu (javafx.scene.control.Menu)18 Label (javafx.scene.control.Label)15 List (java.util.List)13 Collectors (java.util.stream.Collectors)13 File (java.io.File)12 VBox (javafx.scene.layout.VBox)11 ObservableList (javafx.collections.ObservableList)9 ArrayList (java.util.ArrayList)8 EventHandler (javafx.event.EventHandler)8 FXCollections (javafx.collections.FXCollections)7 Optional (java.util.Optional)6 Node (javafx.scene.Node)6 Scene (javafx.scene.Scene)6 Text (javafx.scene.text.Text)6 IOException (java.io.IOException)5 Arrays (java.util.Arrays)5