List of usage examples for org.apache.wicket.markup.html.list ListView ListView
public ListView(final String id, final List<T> list)
From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel.java
License:Apache License
private void initLayout(final boolean inputEnabled) { WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER); placeholderContainer.setOutputMarkupPlaceholderTag(true); placeholderContainer.setOutputMarkupPlaceholderTag(true); placeholderContainer.add(new VisibleEnableBehaviour() { @Override/*from w ww.java 2 s . c o m*/ public boolean isVisible() { return getModel().getObject().isEmpty(); } }); add(placeholderContainer); AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) { @Override public void onClick(AjaxRequestTarget target) { addValuePerformed(target); } }; placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { if (buttonsDisabled()) { return " " + CSS_DISABLED; } return ""; } })); placeholderAdd.setOutputMarkupId(true); placeholderAdd.setOutputMarkupPlaceholderTag(true); placeholderContainer.add(placeholderAdd); ListView repeater = new ListView<T>(ID_REPEATER, getModel()) { @Override protected void populateItem(final ListItem<T> item) { TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel())); text.add(new AjaxFormComponentUpdatingBehavior("onblur") { @Override protected void onUpdate(AjaxRequestTarget target) { } }); text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder())); if (!inputEnabled) { text.add(new AttributeModifier("disabled", "disabled")); } item.add(text); WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); item.add(buttonGroup); initButtons(buttonGroup, item); } }; repeater.setOutputMarkupId(true); repeater.setOutputMarkupPlaceholderTag(true); repeater.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !getModel().getObject().isEmpty(); } }); add(repeater); }
From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextFormGroup.java
License:Apache License
private void initLayout(final IModel<String> label, final String labelSize, final String textSize, final boolean required) { Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelSize)) { l.add(AttributeAppender.prepend("class", labelSize)); }/*from www. j a v a 2 s .c o m*/ add(l); ListView repeater = new ListView<T>(ID_REPEATER, getModel()) { @Override protected void populateItem(final ListItem<T> item) { WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { StringBuilder sb = new StringBuilder(); if (StringUtils.isNotEmpty(textSize)) { sb.append(textSize).append(' '); } if (item.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) { sb.append(getOffsetClass()).append(' '); sb.append(CLASS_MULTI_VALUE); } return sb.toString(); } })); item.add(textWrapper); TextField text = new TextField(ID_TEXT, createTextModel(item.getModel())); text.add(new AjaxFormComponentUpdatingBehavior("onblur") { @Override protected void onUpdate(AjaxRequestTarget target) { } }); text.setRequired(required); text.add(AttributeAppender.replace("placeholder", label)); text.setLabel(label); textWrapper.add(text); FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text)); textWrapper.add(feedback); WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { if (item.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) { return CLASS_MULTI_VALUE; } return null; } })); item.add(buttonGroup); initButtons(buttonGroup, item); } }; add(repeater); }
From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel.java
License:Apache License
protected void initPanelLayout() { WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER); placeholderContainer.setOutputMarkupPlaceholderTag(true); placeholderContainer.setOutputMarkupPlaceholderTag(true); placeholderContainer.add(new VisibleEnableBehaviour() { @Override//from w ww .ja v a 2 s .com public boolean isVisible() { return getModel().getObject().isEmpty(); } }); add(placeholderContainer); AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) { @Override public void onClick(AjaxRequestTarget target) { addValuePerformed(target); } }; placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { if (buttonsDisabled()) { return " " + CSS_DISABLED; } return ""; } })); placeholderAdd.setOutputMarkupId(true); placeholderAdd.setOutputMarkupPlaceholderTag(true); placeholderContainer.add(placeholderAdd); ListView repeater = new ListView<T>(ID_REPEATER, getModel()) { @Override protected void populateItem(final ListItem<T> item) { TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel())); text.add(new AjaxFormComponentUpdatingBehavior("onblur") { @Override protected void onUpdate(AjaxRequestTarget target) { } }); text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder())); item.add(text); WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); item.add(buttonGroup); initButtons(buttonGroup, item); } }; repeater.setOutputMarkupId(true); repeater.setOutputMarkupPlaceholderTag(true); repeater.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !getModel().getObject().isEmpty(); } }); add(repeater); }
From source file:com.evolveum.midpoint.web.component.menu.MainMenuPanel.java
License:Apache License
private void initLayout() { final MainMenuItem menu = getModelObject(); WebMarkupContainer item = new WebMarkupContainer(ID_ITEM); item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override/* w w w. j a v a 2 s . co m*/ public String getObject() { if (menu.isMenuActive((WebPage) getPage())) { return "active"; } for (MenuItem item : menu.getItems()) { if (item.isMenuActive((WebPage) getPage())) { return "active"; } } return !menu.getItems().isEmpty() ? "treeview" : null; } })); add(item); WebMarkupContainer link; if (menu.getPageClass() != null) { link = new AjaxLink(ID_LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { mainMenuPerformed(menu); } }; } else if (menu instanceof AdditionalMenuItem) { link = new AjaxLink(ID_LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { additionalMenuPerformed(menu); } }; } else { link = new WebMarkupContainer(ID_LINK); } item.add(link); WebMarkupContainer icon = new WebMarkupContainer(ID_ICON); icon.add(AttributeModifier.replace("class", new PropertyModel<>(menu, MainMenuItem.F_ICON_CLASS))); link.add(icon); Label label = new Label(ID_LABEL, menu.getNameModel()); link.add(label); final PropertyModel<String> bubbleModel = new PropertyModel<>(menu, MainMenuItem.F_BUBBLE_LABEL); Label bubble = new Label(ID_BUBBLE, bubbleModel); bubble.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return bubbleModel.getObject() != null; } }); link.add(bubble); WebMarkupContainer arrow = new WebMarkupContainer(ID_ARROW); arrow.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return !menu.getItems().isEmpty() && bubbleModel.getObject() == null; } }); link.add(arrow); WebMarkupContainer submenu = new WebMarkupContainer(ID_SUBMENU); submenu.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return !menu.getItems().isEmpty(); } }); item.add(submenu); ListView<MenuItem> subItem = new ListView<MenuItem>(ID_SUB_ITEM, new Model((Serializable) menu.getItems())) { @Override protected void populateItem(ListItem<MenuItem> listItem) { createSubmenu(listItem); } }; submenu.add(subItem); }
From source file:com.evolveum.midpoint.web.component.menu.SideBarMenuPanel.java
License:Apache License
@Override protected void initLayout() { ListView<SideBarMenuItem> menuItems = new ListView<SideBarMenuItem>(ID_MENU_ITEMS, getModel()) { @Override/*from w ww. j ava 2 s .c om*/ protected void populateItem(final ListItem<SideBarMenuItem> item) { Label name = new Label(ID_NAME, item.getModelObject().getName()); item.add(name); ListView<MainMenuItem> items = new ListView<MainMenuItem>(ID_ITEMS, new PropertyModel<List<MainMenuItem>>(item.getModel(), SideBarMenuItem.F_ITEMS)) { @Override protected void populateItem(final ListItem<MainMenuItem> listItem) { MainMenuPanel item = new MainMenuPanel(ID_ITEM, listItem.getModel()); listItem.add(item); listItem.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { MainMenuItem mmi = listItem.getModelObject(); if (!SecurityUtils.isMenuAuthorized(mmi)) { return false; } if (mmi.getItems().isEmpty()) { return true; } for (MenuItem i : mmi.getItems()) { if (SecurityUtils.isMenuAuthorized(i)) { return true; } } return false; } }); } }; item.add(items); item.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { SideBarMenuItem mainMenu = item.getModelObject(); for (MainMenuItem i : mainMenu.getItems()) { boolean visible = true; if (i.getVisibleEnable() != null) { visible = i.getVisibleEnable().isVisible(); } if (visible && SecurityUtils.isMenuAuthorized(i)) { return true; } } return false; } }); } }; add(menuItems); }
From source file:com.evolveum.midpoint.web.component.message.FeedbackMessagePanel.java
License:Apache License
private void initLayout(final IModel<FeedbackMessage> message) { WebMarkupContainer messageContainer = new WebMarkupContainer("messageContainer"); messageContainer.setOutputMarkupId(true); messageContainer.add(new AttributeAppender("class", new LoadableModel<String>() { @Override//w w w .j av a2 s. c o m protected String load() { return getLabelCss(message); } }, " ")); messageContainer.add(new AttributeModifier("title", new LoadableModel<String>() { @Override protected String load() { return getString("feedbackMessagePanel.message." + createMessageTooltip(message)); } })); add(messageContainer); Label label = new Label("message", new LoadableModel<String>(false) { @Override protected String load() { return getTopMessage(message); } }); messageContainer.add(label); WebMarkupContainer topExceptionContainer = new WebMarkupContainer("topExceptionContainer"); messageContainer.add(topExceptionContainer); WebMarkupContainer content = new WebMarkupContainer("content"); if (message.getObject().getMessage() instanceof OpResult) { OpResult result = (OpResult) message.getObject().getMessage(); xml = result.getXml(); export(content, new Model<String>(xml)); ListView<OpResult> subresults = new ListView<OpResult>("subresults", createSubresultsModel(message)) { @Override protected void populateItem(final ListItem<OpResult> item) { item.add(new AttributeAppender("class", OperationResultPanel.createMessageLiClass(item.getModel()), " ")); item.add(new AttributeModifier("title", new LoadableModel<String>() { @Override protected String load() { return getString("feedbackMessagePanel.message." + OperationResultPanel.createMessageTooltip(item.getModel()).getObject()); } })); item.add(new OperationResultPanel("subresult", item.getModel())); } }; content.add(subresults); content.add(new AttributeAppender("class", new LoadableModel<String>(false) { @Override protected String load() { return getDetailsCss(new PropertyModel<OpResult>(message, "message")); } }, " ")); } else { content.setVisible(false); topExceptionContainer.setVisibilityAllowed(false); } content.setMarkupId(messageContainer.getMarkupId() + "_content"); add(content); WebMarkupContainer operationPanel = new WebMarkupContainer("operationPanel"); topExceptionContainer.add(operationPanel); operationPanel.add(new Label("operation", new LoadableModel<String>() { @Override protected String load() { OpResult result = (OpResult) message.getObject().getMessage(); String resourceKey = OperationResultPanel.OPERATION_RESOURCE_KEY_PREFIX + result.getOperation(); return getPage().getString(resourceKey, null, resourceKey); } })); WebMarkupContainer countPanel = new WebMarkupContainer("countPanel"); countPanel.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { OpResult result = (OpResult) message.getObject().getMessage(); return result.getCount() > 1; } }); countPanel.add(new Label("count", new PropertyModel<String>(message, "message.count"))); operationPanel.add(countPanel); ListView<Param> params = new ListView<Param>("params", OperationResultPanel.createParamsModel(new PropertyModel<OpResult>(message, "message"))) { @Override protected void populateItem(ListItem<Param> item) { item.add(new Label("paramName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("paramValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; topExceptionContainer.add(params); ListView<Context> contexts = new ListView<Context>("contexts", OperationResultPanel.createContextsModel(new PropertyModel<OpResult>(message, "message"))) { @Override protected void populateItem(ListItem<Context> item) { item.add(new Label("contextName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("contextValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; topExceptionContainer.add(contexts); /* * WebMarkupContainer countLi = new WebMarkupContainer("countLi"); * countLi.add(new VisibleEnableBehaviour() { * * @Override public boolean isVisible() { OpResult result = (OpResult) * message.getObject().getMessage(); return result.getCount() > 1; } }); * content.add(countLi); countLi.add(new Label("count", new * PropertyModel<String>(message, "message.count"))); */ initExceptionLayout(content, topExceptionContainer, message); content.add(new Label("collapseAll", new LoadableModel<String>() { @Override protected String load() { return getString("feedbackMessagePanel.collapseAll"); } })); content.add(new Label("expandAll", new LoadableModel<String>() { @Override protected String load() { return getString("feedbackMessagePanel.expandAll"); } })); }
From source file:com.evolveum.midpoint.web.component.message.OperationResultPanel.java
License:Apache License
private void initParams(WebMarkupContainer operationContent, final IModel<OpResult> model) { ListView<Param> params = new ListView<Param>("params", createParamsModel(model)) { @Override/*from w w w .j a va 2s .c o m*/ protected void populateItem(ListItem<Param> item) { item.add(new Label("paramName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("paramValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; operationContent.add(params); ListView<OpResult> subresults = new ListView<OpResult>("subresults", createSubresultsModel(model)) { @Override protected void populateItem(final ListItem<OpResult> item) { item.add(new AttributeAppender("class", createMessageLiClass(item.getModel()), " ")); item.add(new AttributeModifier("title", new LoadableModel<String>() { @Override protected String load() { return getString( "operationResultPanel.title." + createMessageTooltip(item.getModel()).getObject()); } })); item.add(new OperationResultPanel("subresult", item.getModel())); } }; operationContent.add(subresults); }
From source file:com.evolveum.midpoint.web.component.message.OperationResultPanel.java
License:Apache License
private void initContexts(WebMarkupContainer operationContent, final IModel<OpResult> model) { ListView<Context> contexts = new ListView<Context>("contexts", createContextsModel(model)) { @Override/* w w w . j a va 2s . c o m*/ protected void populateItem(ListItem<Context> item) { item.add(new Label("contextName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("contextValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; operationContent.add(contexts); }
From source file:com.evolveum.midpoint.web.component.message.TempMessagePanel.java
License:Apache License
private void initLayout(final IModel<FeedbackMessage> message) { Label label = new Label("message", new LoadableModel<String>(false) { @Override/* ww w . j a v a 2s . c o m*/ protected String load() { return getTopMessage(message); } }); label.add(new AttributeAppender("class", new LoadableModel<String>() { @Override protected String load() { return getLabelCss(message); } }, " ")); label.setOutputMarkupId(true); label.add(new AttributeModifier("title", new LoadableModel<String>() { @Override protected String load() { return getString("tempMessagePanel.message." + FeedbackMessagePanel.createMessageTooltip(message)); } })); add(label); WebMarkupContainer content = new WebMarkupContainer("content"); if (message.getObject().getMessage() instanceof OpResult) { content.add(new AttributeAppender("class", new LoadableModel<String>(false) { @Override protected String load() { return getDetailsCss(new PropertyModel<OpResult>(message, "message")); } }, " ")); } else { content.setVisible(false); } content.setMarkupId(label.getMarkupId() + "_content"); content.add(new AttributeModifier("title", new LoadableModel<String>() { @Override protected String load() { return getString("tempMessagePanel.message." + FeedbackMessagePanel.createMessageTooltip(message)); } })); add(content); WebMarkupContainer operationPanel = new WebMarkupContainer("operationPanel"); content.add(operationPanel); operationPanel.add(new Label("operation", new LoadableModel<String>() { @Override protected String load() { OpResult result = (OpResult) message.getObject().getMessage(); String resourceKey = OperationResultPanel.OPERATION_RESOURCE_KEY_PREFIX + result.getOperation(); return getPage().getString(resourceKey, null, resourceKey); } })); WebMarkupContainer countPanel = new WebMarkupContainer("countPanel"); countPanel.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { OpResult result = (OpResult) message.getObject().getMessage(); return result.getCount() > 1; } }); countPanel.add(new Label("count", new PropertyModel<String>(message, "message.count"))); operationPanel.add(countPanel); ListView<Param> params = new ListView<Param>("params", OperationResultPanel.createParamsModel(new PropertyModel<OpResult>(message, "message"))) { @Override protected void populateItem(ListItem<Param> item) { item.add(new Label("paramName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("paramValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; content.add(params); ListView<Context> contexts = new ListView<Context>("contexts", OperationResultPanel.createContextsModel(new PropertyModel<OpResult>(message, "message"))) { @Override protected void populateItem(ListItem<Context> item) { item.add(new Label("contextName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("contextValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; content.add(contexts); initExceptionLayout(content, message); }
From source file:com.evolveum.midpoint.web.component.model.delta.ContainerValuePanel.java
License:Apache License
@Override protected void initLayout() { add(new ListView<ContainerItemDto>(ID_ITEM, new PropertyModel(getModel(), ContainerValueDto.F_ITEM_LIST)) { @Override//from w w w . j a v a 2 s.c o m protected void populateItem(ListItem<ContainerItemDto> item) { item.add(new Label(ID_ATTRIBUTE, new PropertyModel(item.getModel(), ContainerItemDto.F_ATTRIBUTE))); if (item.getModelObject().getValue() instanceof ContainerValueDto) { item.add(new ContainerValuePanel(ID_VALUE, new PropertyModel(item.getModel(), ContainerItemDto.F_VALUE))); } else { // should be String item.add(new Label(ID_VALUE, new PropertyModel(item.getModel(), ContainerItemDto.F_VALUE))); } } }); }