public ImageLinkPanel(final String id, final String relativeImagePath, final IModel<String> tooltip) { this(id); link.add(new TooltipImage("image", relativeImagePath, tooltip)); }
@Override protected void onComponentTag(final ComponentTag tag) { if (!Components.hasTagName(tag, "div", "li")) { tag.setName("div"); } super.onComponentTag(tag); }
/** * We are initializing link in onInitialize() because of some links we need to know a structure */ @Override protected void onInitialize() { super.onInitialize(); link = newLink("command"); link.setOutputMarkupId(true); link.add(new AttributeAppender("class", new PropertyModel<String>(this, "btnCssClass"), " ")); link.add(new Label("label", labelModel).setRenderBodyOnly(true)); link.add(new FAIcon("icon", new PropertyModel<String>(this, "icon"))); link.add(DISABLED_LINK_BEHAVIOR); add(link); }
/** * Helper methods that both checks whether the link is enabled and whether the action ENABLE is * allowed. * * @return whether the link should be rendered as enabled */ protected final boolean isLinkEnabled() { return isEnabled() && isEnableAllowed(); }
/** Initialize the buttons (start with all disabled) */ protected static void initButtons(AbstractLink... buttons) { for (AbstractLink button : buttons) { button.setEnabled(false); button.add(DISABLED_BEHAVIOR); button.setOutputMarkupId(true); } }
/** * Enable/disable a button * * @param button the button * @param enabled enabled state */ protected static void enable(AbstractLink button, boolean enabled) { if (enabled != button.isEnabled()) { button.setEnabled(enabled); if (enabled) { button.remove(DISABLED_BEHAVIOR); } else { button.add(DISABLED_BEHAVIOR); } } }
/** * Instantiates a new {@link MenuItem}. * * @param link * the link * @param labelModel * the model of the label text. */ public MenuItem(final AbstractLink link, final IModel<String> labelModel) { if ((link != null) && !link.getId().equals(MenuPanel.LINK_ID)) { throw new IllegalArgumentException("The id have to be SuckerfishMenuPanel.LINK_ID"); } this.link = link; this.link.add(this.label = newLabel(MenuPanel.LINK_TEXT_ID, labelModel)); }
@Override protected void populateItem(LoopItem item) { final int index = item.getIndex(); final IMenuLink menuItem = MenuPanel.this.menuItems.get(index); final AbstractLink link; final Component linkLabel = menuItem.getDisplayComponent("menuLinkLabel"); if (linkLabel instanceof Image) { item.add(new WebMarkupContainer("menuLink1").setVisible(false)); link = menuItem.getLink("menuLink2"); } else { link = menuItem.getLink("menuLink1"); item.add(new WebMarkupContainer("menuLink2").setVisible(false)); } link.setOutputMarkupId(true); linkLabel.setOutputMarkupId(true); link.add(linkLabel); item.add(link); if (!link.isEnabled()) { item.add(disabledMenuItem); } if (!link.isVisible()) { item.setVisible(false); } item.setOutputMarkupId(true); }
@Override public boolean apply(AbstractLink button) { if (button == null) { throw new IllegalArgumentException("invalid button object"); } if (!buttonMarkupId.equals(button.getId())) { throw new IllegalArgumentException("button id must be equal to '" + buttonMarkupId + "'"); } if (!Behaviors.contains(button, ButtonBehavior.class)) { LOG.debug("button {}#{} has no ButtonBehavior. This will lead to an invalid style! ", button.getPath(), button.getId()); button.add(new ButtonBehavior(ButtonType.Menu, ButtonSize.Medium)); } return true; } }
link = new ExternalLink("footerNewsLink", "https://www.projectforge.org/projectforge-news.html"); body.add(link); link.add(new Label("version", "Version " + AppVersion.VERSION.toString() + ", " + AppVersion.RELEASE_DATE) .setRenderBodyOnly(true)); link.setOutputMarkupId(true); link.setMarkupId("pf_footerNewsLink"); label = "New version available | "; newVersionlink.add(new Label("newVersion", label).setRenderBodyOnly(true)); newVersionlink.setOutputMarkupId(true); newVersionlink.setMarkupId("pf_footerNewVersionLink");
@Override protected void populateItem(ListItem<SideNavItem> item) { SideNavItem sideNavItem = item.getModelObject(); if (sideNavItem.isDivider()) { item.add(new AttributeModifier("class", "divider")); } else if (sideNavItem.isActive()) { item.add(new AttributeModifier("class", "active")); } else if (sideNavItem.isHeader()) { item.add(new AttributeModifier("class", "heading")); } AbstractLink sideNavItemLink = createLink("sideNavItemLink", item.getIndex()); item.add(sideNavItemLink); sideNavItemLink.add(new Label("sideNavItemText", sideNavItem.getTitle())); if (sideNavItem.isDivider() || sideNavItem.isHeader()) { sideNavItemLink.setVisible(false); } Label sideNavHeader = new Label("sideNavHeader", sideNavItem.getTitle()); sideNavHeader.setVisible(sideNavItem.isHeader()); item.add(sideNavHeader); } });
@Override protected void populateItem(ListItem<AbstractLink> item) { final AbstractLink link = item.getModelObject(); Args.isTrue(getButtonMarkupId().equals(link.getId()), "component id is invalid, please use ButtonList.getButtonMarkupId()"); item.add(link); link.configure(); if (!link.isEnabled()) { item.add(new CssClassNameAppender("disabled")); } } }
/** * @see org.apache.wicket.Component#isEnabled() */ @Override public boolean isEnabled() { // If we're auto-enabling if (getAutoEnable()) { // the link is enabled if this link doesn't link to the current page return !linksTo(getPage()); } return super.isEnabled(); }
@Override protected final WebMarkupContainer newButton(String markupId, IModel<String> labelModel, IModel<IconType> iconTypeModel) { Args.isTrue(btn == null, "btn was already set before."); btn = newBaseButton("button", labelModel, iconTypeModel); btn.setOutputMarkupId(true); caret = newCaret("caret"); add(caret); return btn; }
/** * Instantiates a new {@link MenuItem}. * * @param link * the link * @param labelModel * the model of the label text. */ public MenuItem(final AbstractLink link, final IModel<String> labelModel) { if ((link != null) && !link.getId().equals(MenuPanel.LINK_ID)) { throw new IllegalArgumentException("The id have to be SuckerfishMenuPanel.LINK_ID"); } this.link = link; this.link.add(this.label = newLabel(MenuPanel.LINK_TEXT_ID, labelModel)); }
item.add(new WebMarkupContainer("menuLink2").setVisible(false)); link.setOutputMarkupId(true); linkLabel.setOutputMarkupId(true); link.add(linkLabel); if (!link.isEnabled()) { item.add(disabledMenuItem); if (!link.isVisible()) { item.setVisible(false);
/** * @see org.apache.wicket.Component#isEnabled() */ @Override public boolean isEnabled() { // If we're auto-enabling if (getAutoEnable()) { // the link is enabled if this link doesn't link to the current page return !linksTo(getPage()); } return super.isEnabled(); }
/** * Adds html attribute "accesskey". * @param ch * @return this for chaining. */ public ContentMenuEntryPanel setAccessKey(final char ch) { link.add(AttributeModifier.replace("accesskey", String.valueOf(ch))); return this; }
link.add(target); link.setOutputMarkupId(true); return link;
public YuiMenuItem(final String label, final AbstractLink link) { super(MENU_ITEM_ID); if (link.getId().equals(LINK_ID) == false) { throw new RuntimeException("Link's id needs to be 'link' "); } getItemContainer().add(link); link.add(new Label("linkLabel", new Model<String>(label)).setRenderBodyOnly(true)); newSubMenu("emptyMenu").setVisible(false); }