use of javafx.scene.control.MenuItem in project aima-java by aimacode.
the class IntegratedAppBuilder method registerApp.
public void registerApp(Class<? extends IntegrableApplication> appClass) {
final IntegratedAppPaneCtrl ctrl = paneCtrl;
MenuItem item = new MenuItem(appClass.getSimpleName());
item.setOnAction(ev -> ctrl.startApp(appClass));
addToMenu(appsMenu, appClass.getPackage().getName(), item);
}
use of javafx.scene.control.MenuItem 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);
}
use of javafx.scene.control.MenuItem 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);
}
use of javafx.scene.control.MenuItem in project trex-stateless-gui by cisco-system-traffic-generator.
the class ChartContainer method createContextMenuItem.
private MenuItem createContextMenuItem(String chartType) {
MenuItem item = new MenuItem(chartType);
item.setOnAction(this::handleContextMenuAction);
return item;
}
use of javafx.scene.control.MenuItem 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);
}
}
}
}
Aggregations