/******************************************************************************************************************* * ******************************************************************************************************************/ @Test public void must_set_the_MenuItem_text_from_UserAction_Displayable() throws InterruptedException { final List<MenuItem> menuItems = fixture.createMenuItems(roleMapWithUserActionProvider); assertThat(menuItems, is(not(nullValue()))); assertThat(menuItems.size(), is(actions.size())); for (int i = 0; i < menuItems.size(); i++) { final MenuItem menuItem = menuItems.get(i); assertThat(menuItem, is(not(nullValue()))); assertThat(menuItem.getText(), is("Action #" + i)); } }
CirclePopupMenuNode (MenuItem menuItem) { this.menuItem = menuItem; setId(this.getClass().getSimpleName() + "#" + menuNodeIdAtomicLong.incrementAndGet()); // show the graphical part if (menuItem.getGraphic() == null) { throw new NullPointerException("MenuItems in CirclePopupMenu require a graphical part, text is optional"); } getChildren().add(menuItem.getGraphic()); // show the text as a tooltip if (menuItem.getText() != null && menuItem.getText().length() > 0) { Tooltip t = new Tooltip(menuItem.getText()); Tooltip.install(this, t); } // react on a mouse click to perform the menu action setOnMouseClicked( (eventHandler) -> { hide(); if (menuItem.getOnAction() != null) { menuItem.getOnAction().handle(null); } }); } final private MenuItem menuItem;
CornerMenuNode (MenuItem menuItem) { this.menuItem = menuItem; setId(this.getClass().getSimpleName() + "#" + menuNodeIdAtomicLong.incrementAndGet()); // show the graphical part if (menuItem.getGraphic() == null) { throw new NullPointerException("MenuItems in CornerMenu require a graphical part, text is optional"); } getChildren().add(menuItem.getGraphic()); // show the text as a tooltip if (menuItem.getText() != null && menuItem.getText().length() > 0) { Tooltip t = new Tooltip(menuItem.getText()); Tooltip.install(this, t); } // react on a mouse click to perform the menu action setOnMouseClicked( (eventHandler) -> { if (isAutoShowAndHide()) { hide(); } if (menuItem.getOnAction() != null) { menuItem.getOnAction().handle(null); } }); } final private MenuItem menuItem;
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test public void must_set_the_MenuItem_text_from_UserAction_Displayable() throws InterruptedException { final List<MenuItem> menuItems = fixture.createMenuItems(asObjectWithUserActionProvider); assertThat(menuItems, is(not(nullValue()))); assertThat(menuItems.size(), is(actions.size())); for (int i = 0; i < menuItems.size(); i++) { final MenuItem menuItem = menuItems.get(i); assertThat(menuItem, is(not(nullValue()))); assertThat(menuItem.getText(), is("Action #" + i)); } }
/** * Handles action events to enable or disable selected SWIM data list * view items. */ @Override public void handle(ActionEvent event) { int index = this.listView.getSelectionModel().getSelectedIndex(); if (-1 != index) { String identifier = this.listView.getItems().get(index); MenuItem menuItem = (MenuItem) event.getSource(); if (menuItem.getText().equals(SwimDataListView.ENABLE)) { this.activate(identifier); } else if (menuItem.getText().equals(SwimDataListView.DISABLE)) { this.deactivate(identifier); } this.listView.worldWindow.redrawNow(); } }
default: LOGGER.log(Level.WARNING, "unhandled menu item " + menuItem.getId() + ":" + menuItem.getText());