/** * Indicates whether this is a top-level menu (ie. attached to a menu bar). * * @return {@code true} if this is a top-level menu. */ public boolean isTopLevelMenu() { MenuContainer container = WebUtilities.getAncestorOfClass(MenuContainer.class, this); if (container instanceof WMenuItemGroup) { container = WebUtilities.getAncestorOfClass(MenuContainer.class, container); } return container instanceof WMenu; }
/** * @return {@code true} if the WMenuItem is either an immediate child of a WMenu or an immediate child of a WMenuItemGroup which is itself * an immediate child of a WMenu. */ public final boolean isTopLevelItem() { MenuContainer container = WebUtilities.getAncestorOfClass(MenuContainer.class, this); if (container instanceof WMenuItemGroup) { container = WebUtilities.getAncestorOfClass(MenuContainer.class, container); } return container instanceof WMenu; }
/** * @return the parent table */ protected WTable getTable() { return WebUtilities.getAncestorOfClass(WTable.class, this); }
/** * @return the logical thread pool controller */ protected LogicalThreadPoolController getThreadController() { LogicalThreadPoolController ctrl = WebUtilities.getAncestorOfClass(LogicalThreadPoolController.class, this); if (ctrl == null) { throw new IllegalStateException("No logical thread pool controller found."); } return ctrl; }
/** * Indicates whether this tab is open in the given context. * * @return true if this tab is open in the given context, otherwise false. */ public boolean isOpen() { WTabSet tabSet = WebUtilities.getAncestorOfClass(WTabSet.class, this); return tabSet.getActiveTabs().contains(this); }
/** * Determine if this WMenuItem's parent WMenu is on the Request. * * @param request the request being responded to. * @return true if this WMenuItem's WMenu is on the Request, otherwise return false. */ protected boolean isMenuPresent(final Request request) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, this); if (menu != null) { return menu.isPresent(request); } return false; }
/** * {@inheritDoc} */ @Override public boolean isSelected() { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, this); if (menu != null) { return menu.getSelectedMenuItems().contains(this); } return false; }
/** * @param submenu the WSubMenu currently being rendered * @return {@code true} if the submenu is in a WMenu of MenuType.TREE */ private boolean isTree(final WSubMenu submenu) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, submenu); return menu != null && WMenu.MenuType.TREE == menu.getType(); }
/** * Determine if this WMenuItem's parent WMenu is on the Request. * * @param request the request being responded to. * @return true if this WMenuItem's WMenu is on the Request, otherwise return false. */ protected boolean isMenuPresent(final Request request) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, this); return menu != null && menu.isPresent(request); }
@Override public void execute(final ActionEvent event) { WDialog dialog = (WDialog) WebUtilities.getAncestorOfClass(WDialog.class, cancelButton); dialog.reset(); } });
/** * Updates the title, based on the selected example. */ private void updateTitle() { String title; if (this.getCurrentComponent() == null) { title = "Example Picker"; } else { title = this.getCurrentComponent().getClass().getName(); } WApplication app = WebUtilities.getAncestorOfClass(WApplication.class, this); if (app != null) { app.setTitle(title); } }
/** * Indicates whether this sub menu is disabled in the given context. * * @return true if this sub menu is disabled. */ @Override public boolean isDisabled() { if (isFlagSet(ComponentModel.DISABLED_FLAG)) { return true; } MenuContainer container = WebUtilities.getAncestorOfClass(MenuContainer.class, this); if (container instanceof Disableable && ((Disableable) container).isDisabled()) { return true; } return false; }
/** * Since the dialog is closed on a round-trip, we need to override executeOnError to re-show the dialog. * * @param event the event which triggered validation. * @param diags the list of validation errors. */ @Override public void executeOnError(final ActionEvent event, final List<Diagnostic> diags) { super.executeOnError(event, diags); WDialog dialog = (WDialog) WebUtilities.getAncestorOfClass(WDialog.class, selectButton); dialog.display(); } });
/** * Indicates whether this group is disabled. * * @return true if this group is disabled. */ @Override public boolean isDisabled() { if (isFlagSet(ComponentModel.DISABLED_FLAG)) { return true; } MenuContainer container = WebUtilities.getAncestorOfClass(MenuContainer.class, this); if (container instanceof Disableable && ((Disableable) container).isDisabled()) { return true; } return false; }
/** * @inheritDoc */ @Override protected void preparePaintComponent(final Request request) { if (!isInitialised()) { WebUtilities.getAncestorOfClass(WApplication.class, this).addJsFile("/com/github/bordertech/wcomponents/examples/hellobutton.js"); setInitialised(true); } super.preparePaintComponent(request); }
/** * Override preparePaintComponent in order to set some content which varies according to the modality of the * containing dialog. * * @param request the request being responded to. */ @Override protected void preparePaintComponent(final Request request) { removeTerm(MODE_FLAG_TERM_TEXT); WDialog dialog = (WDialog) WebUtilities.getAncestorOfClass(WDialog.class, this); addTerm(MODE_FLAG_TERM_TEXT, new WText( ((dialog == null || dialog.getMode() == WDialog.MODELESS) ? NON_MODAL_TEXT : MODAL_TEXT))); } }
/** * {@inheritDoc} */ @Override public void execute(final ActionEvent event) { if (event.getActionObject() == null) { return; } WMenuItem target = (WMenuItem) event.getActionObject(); WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, target); menu.clearSelectedMenuItems(); getFilterableTableModel().filterBeanList(); } }
@Override public void execute(final ActionEvent event) { Person person = (Person) getBean(); TableCellWithActionExample example = WebUtilities.getAncestorOfClass( TableCellWithActionExample.class, ExampleButton.this); example.getActionText().setText( "Action for: " + person.getFirstName() + ' ' + person.getLastName()); } });
/** * {@inheritDoc} */ @Override public void handleRequest(final Request request) { // If is LAZY or DYNAMIC and is the current trigger, then process the WTabSet for the correct open/closed tabs if ((TabMode.LAZY.equals(getMode()) || TabMode.DYNAMIC.equals(getMode())) && AjaxHelper.isCurrentAjaxTrigger(this)) { WTabSet tabSet = (WTabSet) WebUtilities.getAncestorOfClass(WTabSet.class, this); tabSet.handleRequest(request); } }
@Override public void execute(final ActionEvent event) { ExampleData example = tree.getSelectedExampleData(); if (example != null) { TreePicker picker = WebUtilities.getAncestorOfClass(TreePicker.class, tree); picker.selectExample(example); addToRecent(example); if (!menu.isVisible()) { menu.setVisible(true); recentMenuHeading.setVisible(true); } } menu.clearSelectedMenuItems(); } });