Java Code Examples for org.apache.wicket.markup.html.link.AbstractLink#add()

The following examples show how to use org.apache.wicket.markup.html.link.AbstractLink#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryAwarePagingNavigator.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected AbstractLink newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) {
	AbstractLink link;
	if (pagingHistorySupport != null) {
		int pageNumber = (int) pageable.getCurrentPage() + increment;
		link = new BookmarkablePageLink<Void>(id, getPage().getClass(),
				pagingHistorySupport.newPageParameters(pageNumber)) {

			@Override
			protected void onConfigure() {
				super.onConfigure();
				setEnabled(pageNumber >= 0 && pageNumber < getPageable().getPageCount());
			}
			
		};
		link.add(new DisabledAttributeLinkBehavior());
	} else {
		link = new PagingNavigationIncrementLink<Void>(id, pageable, increment);
	}
	return link;
}
 
Example 2
Source File: HistoryAwarePagingNavigator.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected AbstractLink newPagingNavigationLink(String id, IPageable pageable, int pageNumber) {
	AbstractLink link;
	int absolutePageNumber;
	if (pageNumber == -1)
		absolutePageNumber = (int) (getPageable().getPageCount()-1);
	else
		absolutePageNumber = pageNumber;
	if (pagingHistorySupport != null) {
		link = new BookmarkablePageLink<Void>(id, getPage().getClass(),
				pagingHistorySupport.newPageParameters(absolutePageNumber)) {
			
			@Override
			protected void onConfigure() {
				super.onConfigure();
				setEnabled(absolutePageNumber != pageable.getCurrentPage());
			}
			
		};
		link.add(new DisabledAttributeLinkBehavior());
	} else {
		link = new PagingNavigationLink<Void>(id, pageable, pageNumber);
	}
	return link;
}
 
Example 3
Source File: OmMenuItem.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractLink create(String markupId) {
	AbstractLink item;
	if (Strings.isEmpty(title)) {
		item = new MenuDivider();
	} else if (items.isEmpty()) {
		item = new NavbarAjaxLink<String>(markupId, Model.of(title)) {
			private static final long serialVersionUID = 1L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				OmMenuItem.this.onClick(target);
			}
		}.setIconType(icon);
		item.add(AttributeModifier.append(ATTR_CLASS, "nav-link"));
	} else {
		item = new NavbarDropDownButton(Model.of(title), Model.of(icon)) {
			private static final long serialVersionUID = 1L;

			@Override
			protected List<AbstractLink> newSubMenuButtons(String markupId) {
				return items.stream().map(mItem -> ((OmMenuItem)mItem).create(markupId)).collect(Collectors.toList());
			}
		};
	}
	item.add(AttributeModifier.append(ATTR_TITLE, desc));
	item.setVisible(visible);
	return item;
}
 
Example 4
Source File: ActionLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public ActionLinkPanel(final String id, final ActionLinkType actionLinkType, final String value)
{
  super(id);
  AbstractLink link1;
  if (actionLinkType == ActionLinkType.CALL) {
    add(link1 = getCallLink(value));
    add(getInvisibleSmsLink());
  } else if (actionLinkType == ActionLinkType.SMS) {
    add(new Label("link", "[invisible]").setVisible(false));
    add(getSmsLink(value));
  } else if (actionLinkType == ActionLinkType.CALL_AND_SMS) {
    add(link1 = getCallLink(value));
    add(getSmsLink(value));
  } else if (actionLinkType == ActionLinkType.MAIL) {
    add(link1 = new ExternalLink("link", "mailto:" + value, value));
    add(getInvisibleSmsLink());
  } else {
    final String url;
    if (value != null && value.contains("://") == true) {
      url = value;
    } else {
      url = "http://" + value;
    }
    add(link1 = new ExternalLink("link", url, value));
    link1.add(AttributeModifier.append("target", "_blank"));
    add(getInvisibleSmsLink());
  }
}
 
Example 5
Source File: TextLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param id
 * @param link Must have component id {@link #LINK_ID}
 * @param label The link text.
 * @param tooltip
 */
public TextLinkPanel(final String id, final AbstractLink link, final String label, final String tooltip)
{
  super(id);
  this.link = link;
  init(id, link, tooltip);
  this.label = new Label("text", label);
  link.add(this.label);
}
 
Example 6
Source File: TextLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param id
 * @param link Must have component id {@link #LINK_ID}
 * @param label The link text.
 */
public TextLinkPanel(final String id, final AbstractLink link, final IModel<String> label, final String tooltip)
{
  super(id);
  this.link = link;
  init(id, link, tooltip);
  this.label = new Label("text", label);
  link.add(this.label);
}
 
Example 7
Source File: IconLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public IconLinkPanel setLink(final AbstractLink link)
{
  this.link = link;
  add(link);
  icon = new WebMarkupContainer("icon");
  icon.add(AttributeModifier.append("class", type.getClassAttrValue()));
  link.add(icon);
  return this;
}
 
Example 8
Source File: MenuPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public LinkFragment(AbstractLink link, String label) {
	super("linkFragment", "LINK_FRAGMENT", MenuPanel.this);

	setRenderBodyOnly(true);
	link.add(new Label(LINK_TEXT_ID, label));
	add(link);
}
 
Example 9
Source File: MenuPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public LinkImageTextFragment(AbstractLink link, String image, String label) {
          super("linkFragment", decorateMarkupId("LINK_IMAGE_TEXT_FRAGMENT", image), MenuPanel.this);

	setRenderBodyOnly(true);
          if (isFontawesome(image)) {
              link.add(new TransparentWebMarkupContainer(LINK_IMAGE_ID).add(AttributeModifier.append("class", "fa-" + image)));
          } else {
              link.add(new ContextImage(LINK_IMAGE_ID, image));
          }
          link.add(new SimpleTooltipBehavior(label));
	link.add(new Label(LINK_TEXT_ID, label));
	add(link);
}
 
Example 10
Source File: MenuPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public LinkImageFragment(AbstractLink link, String image) {
	super("linkFragment", decorateMarkupId("LINK_IMAGE_FRAGMENT", image), MenuPanel.this);

	setRenderBodyOnly(true);
          if (isFontawesome(image)) {
              link.add(new TransparentWebMarkupContainer(LINK_IMAGE_ID).add(AttributeModifier.append("class", "fa-" + image)));
          } else {
              link.add(new ContextImage(LINK_IMAGE_ID, image));
          }
	add(link);
}
 
Example 11
Source File: EtcdNodePanel.java    From etcd-viewer with Apache License 2.0 4 votes vote down vote up
public EtcdNodePanel(String id, IModel<String> etcdRegistry, IModel<String> keyModel) {
    super(id);

    this.registry = etcdRegistry;

    this.key = keyModel;

    setModel(new LoadableDetachableModel<EtcdNode>() {
        private static final long serialVersionUID = 1L;
        @Override
        protected EtcdNode load() {
            if (registry.getObject() == null) {
                return null;
            }
            try (EtcdProxy p = proxyFactory.getEtcdProxy(registry.getObject())) {

                return p.getNode(key.getObject());
            } catch (Exception e) {
                log.warn(e.getLocalizedMessage(), e);
                // TODO: handle this exception and show some alert on page
                error("Could not retrieve key " + key.getObject() + ": " + e.toString());
                EtcdNodePanel.this.setEnabled(false);
                return null;
            }
        }
    });

    parentKey = new ParentKeyModel();

    setOutputMarkupId(true);

    createModalPanels();

    add(breadcrumbAndActions = new WebMarkupContainer("breadcrumbAndActions"));
    breadcrumbAndActions.setOutputMarkupId(true);

    createBreadcrumb();

    createNodeActions();

    add(new WebMarkupContainer("icon").add(new AttributeModifier("class", new StringResourceModel("icon.node.dir.${dir}", getModel(), ""))));

    add(new Label("key", new PropertyModel<>(getModel(), "key")));

    add(contents = new WebMarkupContainer("contents"));
    contents.setOutputMarkupId(true);

    WebMarkupContainer currentNode;
    contents.add(currentNode = new WebMarkupContainer("currentNode"));

    currentNode.add(new AttributeAppender("class", new StringResourceModel("nodeClass", getModel(), "") , " "));

    currentNode.add(new Label("createdIndex", new PropertyModel<>(getModel(), "createdIndex")));
    currentNode.add(new Label("modifiedIndex", new PropertyModel<>(getModel(), "modifiedIndex")));
    currentNode.add(new Label("ttl", new PropertyModel<>(getModel(), "ttl")));
    currentNode.add(new Label("expiration", new PropertyModel<>(getModel(), "expiration")));

    contents.add(new TriggerModalLink<EtcdNode>("editValue", getModel(), editNodeModal) {
        private static final long serialVersionUID = 1L;
        @Override
        protected void onConfigure() {
            super.onConfigure();
            if (key.getObject() == null || "".equals(key.getObject()) || "/".equals(key.getObject())) {
                add(AttributeAppender.append("disabled", "disabled"));
            } else {
                add(AttributeModifier.remove("disabled"));
            }

            // hide value for directory entries
            setVisible(EtcdNodePanel.this.getModelObject() != null && !EtcdNodePanel.this.getModelObject().isDir());
        }
        @Override
        protected void onModalTriggerClick(AjaxRequestTarget target) {
            updating.setObject(true);
            actionModel.setObject(getModelObject());
        }
    } .add(new MultiLineLabel("value", new PropertyModel<>(getModel(), "value"))));


    AbstractLink goUp;
    contents.add(goUp = createNavigationLink("goUp", parentKey));
    goUp.add(new Behavior() {
        private static final long serialVersionUID = 1L;
        @Override
        public void onConfigure(Component component) {
            super.onConfigure(component);
            component.setEnabled(key.getObject() != null && !"".equals(key.getObject()) && !"/".equals(key.getObject()));
        }
    });

    contents.add(createNodesView("nodes"));
}
 
Example 12
Source File: ActionItemLink.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
public ActionItemLink(IModel<String> label, IconType iconType, AbstractLink link) {
	add(link);
	WebMarkupContainer webMarkupContainer = new WebMarkupContainer("icon-type");
	webMarkupContainer.add(new AttributeAppender("class", "glyphicon glyphicon-" + iconType.getCssName()));
	link.add(webMarkupContainer);
}
 
Example 13
Source File: ImageLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public ImageLinkPanel(final String id, final AbstractLink link, final String relativeImagePath, final String tooltip)
{
  super(id);
  add(link);
  link.add(new TooltipImage("image", relativeImagePath, tooltip));
}
 
Example 14
Source File: FormPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
private void setButtonValue(AbstractLink button, String value) {
	button.add(new AttributeModifier("value", Model.of(value)));
}