Java Code Examples for org.apache.wicket.markup.html.list.ListItem#add()
The following examples show how to use
org.apache.wicket.markup.html.list.ListItem#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: OrderItemListPanel.java From the-app with Apache License 2.0 | 6 votes |
private Component orderItemList() { return new ListView<OrderItemInfo>("orderItems", new PropertyModel<List<OrderItemInfo>>(getDefaultModel(), "orderItems")) { private int orderItemCounter = 1; @Override protected void populateItem(ListItem<OrderItemInfo> orderItem) { orderItem.add(new Label("orderItemCounter", Model.of(orderItemCounter++))); orderItem.add(new Label("product", new PropertyModel<String>(orderItem.getModel(), "product.name"))); orderItem.add(new Label("description", new PropertyModel<String>(orderItem.getModel(), "product.description"))); orderItem.add(new Label("totalSum", new PriceModel(new PropertyModel<>(orderItem.getModel(), "totalSum")))); } @Override protected void onDetach() { orderItemCounter = 1; super.onDetach(); } }; }
Example 2
Source File: GradeImportConfirmationStep.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Helper to create a listview for what needs to be shown for new assignments * @param markupId wicket markup id * @param itemList list of Assignments populated by the item creation steps */ private ListView<Assignment> makeAssignmentsToCreateListView(final String markupId, final List<Assignment> itemList) { final ListView<Assignment> rval = new ListView<Assignment>(markupId, itemList) { @Override protected void populateItem(final ListItem<Assignment> item) { final Assignment assignment = item.getModelObject(); String extraCredit = assignment.isExtraCredit() ? yes : no; String dueDate = FormatHelper.formatDate(assignment.getDueDate(), ""); String releaseToStudents = assignment.isReleased() ? yes : no; String includeInCourseGrades = assignment.isCounted() ? yes : no; item.add(new Label("title", assignment.getName())); item.add(new Label("points", assignment.getPoints())); item.add(new Label("extraCredit", extraCredit)); item.add(new Label("dueDate", dueDate)); item.add(new Label("releaseToStudents", releaseToStudents)); item.add(new Label("includeInCourseGrades", includeInCourseGrades)); } }; return rval; }
Example 3
Source File: ProjectsOverviewPage.java From inception with Apache License 2.0 | 6 votes |
private ListView<ProjectPermission> createRoleBadges(Project aProject) { return new ListView<ProjectPermission>(MID_ROLE, projectService .listProjectPermissionLevel(userRepository.getCurrentUser(), aProject)) { private static final long serialVersionUID = -96472758076828409L; @Override protected void populateItem(ListItem<ProjectPermission> aItem) { PermissionLevel level = aItem.getModelObject().getLevel(); aItem.add(new Label(MID_LABEL, getString( Classes.simpleName(level.getDeclaringClass()) + '.' + level.toString()))); } }; }
Example 4
Source File: OrderItemListPanel.java From AppStash with Apache License 2.0 | 6 votes |
private Component orderItemList() { return new ListView<OrderItemInfo>("orderItems", new PropertyModel<List<OrderItemInfo>>(getDefaultModel(), "orderItems")) { private int orderItemCounter = 1; @Override protected void populateItem(ListItem<OrderItemInfo> orderItem) { orderItem.add(new Label("orderItemCounter", Model.of(orderItemCounter++))); orderItem.add(new Label("product", new PropertyModel<String>(orderItem.getModel(), "product.name"))); orderItem.add(new Label("description", new PropertyModel<String>(orderItem.getModel(), "product.description"))); orderItem.add(new Label("totalSum", new PriceModel(new PropertyModel<>(orderItem.getModel(), "totalSum")))); } @Override protected void onDetach() { orderItemCounter = 1; super.onDetach(); } }; }
Example 5
Source File: LogDialogContent.java From inception with Apache License 2.0 | 6 votes |
private ListView<LogMessage> createMessagesView(IModel<LogMessageGroup> aModel) { return new ListView<LogMessage>("messages", PropertyModel.of(aModel, "messages")) { private static final long serialVersionUID = 5961113080333988246L; @Override protected void populateItem(ListItem<LogMessage> aItem) { IModel<LogMessage> msg = aItem.getModel(); aItem.add(new Label("level", PropertyModel.of(msg, "level"))); aItem.add(new Label("source", PropertyModel.of(msg, "source"))); aItem.add(new Label("message", PropertyModel.of(msg, "message"))); } }; }
Example 6
Source File: ProgressesPanel.java From syncope with Apache License 2.0 | 6 votes |
public ProgressesPanel(final String id, final Date lastUpdate, final List<ProgressBean> progressBeans) { super(id); add(new Label("lastUpdate", SyncopeConsoleSession.get().getDateFormat().format(lastUpdate))); ListView<ProgressBean> progresses = new ListView<ProgressBean>("progresses", progressBeans) { private static final long serialVersionUID = -9180479401817023838L; @Override protected void populateItem(final ListItem<ProgressBean> item) { item.add(new ProgressPanel("progress", item.getModelObject())); } }; progresses.setOutputMarkupId(true); add(progresses); }
Example 7
Source File: AccessSpecificSettingsPanel.java From inception with Apache License 2.0 | 5 votes |
private ListView<KnowledgeBaseProfile> remoteSuggestionsList(String aId, List<KnowledgeBaseProfile> aSuggestions) { return new ListView<KnowledgeBaseProfile>(aId, aSuggestions) { private static final long serialVersionUID = 4179629475064638272L; @Override protected void populateItem(ListItem<KnowledgeBaseProfile> item) { // add a link for one knowledge base with proper label LambdaAjaxLink link = new LambdaAjaxLink("suggestionLink", t -> { // set all the fields according to the chosen profile kbModel.getObject().setUrl(item.getModelObject().getAccess().getAccessUrl()); // sets root concepts list - if null then an empty list otherwise change the // values to IRI and populate the list kbModel.getObject().getKb().applyRootConcepts(item.getModelObject()); kbModel.getObject().getKb().applyMapping(item.getModelObject().getMapping()); kbInfoModel.setObject(item.getModelObject().getInfo()); kbModel.getObject().getKb().setFullTextSearchIri( item.getModelObject().getAccess().getFullTextSearchIri()); kbModel.getObject().getKb() .setDefaultLanguage(item.getModelObject().getDefaultLanguage()); kbModel.getObject().getKb() .setDefaultDatasetIri(item.getModelObject().getDefaultDataset()); kbModel.getObject().getKb() .setReification(item.getModelObject().getReification()); t.add(urlField, defaultDatasetField, infoContainerRemote); }); link.add(new Label("suggestionLabel", item.getModelObject().getName())); item.add(link); } }; }
Example 8
Source File: AbstractAttrsWizardStep.java From syncope with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) protected AbstractFieldPanel<?> setPanel( final Map<String, PlainSchemaTO> schemas, final ListItem<Attr> item, final boolean setReadOnly) { Attr attr = item.getModelObject(); final boolean isMultivalue = mode != AjaxWizard.Mode.TEMPLATE && schemas.get(attr.getSchema()).isMultivalue(); AbstractFieldPanel<?> panel = getFieldPanel(schemas.get(attr.getSchema())); if (isMultivalue) { // SYNCOPE-1476 set form as multipart to properly manage membership attributes panel = new MultiFieldPanel.Builder<>( new PropertyModel<>(attr, "values")).build( "panel", attr.getSchema(), FieldPanel.class.cast(panel)).setFormAsMultipart(true); // SYNCOPE-1215 the entire multifield panel must be readonly, not only its field MultiFieldPanel.class.cast(panel).setReadOnly(schemas.get(attr.getSchema()).isReadonly()); MultiFieldPanel.class.cast(panel).setFormReadOnly(setReadOnly); } else { FieldPanel.class.cast(panel).setNewModel(attr.getValues()).setReadOnly(setReadOnly); } item.add(panel); setExternalAction(attr, panel); return panel; }
Example 9
Source File: DashboardColumnPanel.java From nextreports-server with Apache License 2.0 | 5 votes |
public DashboardColumnPanel(String id, IModel<DashboardColumn> model) { super(id, model); setOutputMarkupId(true); final int columnIndex = getDashboardColumn().getIndex(); columnContainer = new WebMarkupContainer("columnContainer"); columnContainer.setOutputMarkupId(true); columnContainer.setMarkupId("column-" + columnIndex); ListView<Widget> listView = new ListView<Widget>("widgetList", new WidgetsModel()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Widget> item) { final Widget widget = item.getModelObject(); if (widget.isCollapsed()) { WidgetPanel widgetPanel = createWidgetPanel("widget", widget, new WidgetModel(widget.getId())); item.add(widgetPanel); } else { // item.add(new WidgetLoadingPanel("widget", new WidgetModel(widget.getId()))); item.add(createWidgetPanel("widget", widget, new WidgetModel(widget.getId()))); } item.setOutputMarkupId(true); item.setMarkupId("widget-" + widget.getId()); } }; columnContainer.add(listView); add(columnContainer); stopSortableAjaxBehavior = addSortableBehavior(columnContainer); }
Example 10
Source File: ProjectsOverviewPage.java From inception with Apache License 2.0 | 5 votes |
private WebMarkupContainer createRoleFilters() { ListView<PermissionLevel> listview = new ListView<PermissionLevel>(MID_ROLE_FILTER, asList(PermissionLevel.values())) { private static final long serialVersionUID = -4762585878276156468L; @Override protected void populateItem(ListItem<PermissionLevel> aItem) { PermissionLevel level = aItem.getModelObject(); LambdaAjaxLink link = new LambdaAjaxLink("roleFilterLink", _target -> actionApplyRoleFilter(_target, aItem.getModelObject())); link.add(new Label(MID_LABEL, getString( Classes.simpleName(level.getDeclaringClass()) + '.' + level.toString()))); link.add(new AttributeAppender("class", () -> activeRoleFilters.getObject().contains(aItem.getModelObject()) ? "active" : "", " ")); aItem.add(link); } }; WebMarkupContainer container = new WebMarkupContainer("roleFilters"); container.setOutputMarkupPlaceholderTag(true); container.add(listview); return container; }
Example 11
Source File: TopicListPanel.java From ontopia with Apache License 2.0 | 5 votes |
@Override protected void populateItem(ListItem<Topic> item) { Topic topic = item.getModelObject(); // FIXME: upgrade to TopicLink item.add(new TopicInstanceLink("topicLink", new TopicModel<Topic>(topic))); //item.add(new org.apache.wicket.markup.html.basic.Label("topicName", topic.getName())); }
Example 12
Source File: LinkToSocialNetworkPanel.java From Orienteer with Apache License 2.0 | 5 votes |
private ListView<OAuth2Service> createSocialNetworksServices(String id) { return new ListView<OAuth2Service>(id, resolveNotLinkedOAuth2Services(getModelObject())) { @Override protected void onConfigure() { super.onConfigure(); setModelObject(resolveNotLinkedOAuth2Services(LinkToSocialNetworkPanel.this.getModelObject())); } @Override protected void populateItem(ListItem<OAuth2Service> item) { IOAuth2Provider provider = item.getModelObject().getProvider(); Image image = new Image("networkImage", provider.getIconResourceReference()); image.setOutputMarkupPlaceholderTag(true); image.add(new AjaxEventBehavior("click") { @Override protected void onEvent(AjaxRequestTarget target) { onSocialImageClick(target, item.getModel()); image.setVisible(false); target.add(image); } }); image.add(new AttributeModifier("alt", new ResourceModel(provider.getLabel()).getObject())); item.add(image); } @Override protected void onInitialize() { super.onInitialize(); setReuseItems(true); } }; }
Example 13
Source File: ListViewPanel.java From syncope with Apache License 2.0 | 5 votes |
private static ListView<String> header(final List<String> labels) { return new ListView<String>("names", labels) { private static final long serialVersionUID = -9112553137618363167L; @Override protected void populateItem(final ListItem<String> item) { item.add(new Label("name", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; }
Example 14
Source File: MyPictures.java From sakai with Educational Community License v2.0 | 5 votes |
protected void populateItem(ListItem<File> listItem) { final File file = (File) listItem.getModelObject(); listItem.add(new Label("file", file.getName())); listItem.add(new Link("delete") { public void onClick() { Files.remove(file); } }); }
Example 15
Source File: BulkEditItemsPanel.java From sakai with Educational Community License v2.0 | 5 votes |
@Override protected void populateItem(final ListItem<Assignment> item) { final Assignment assignment = item.getModelObject(); item.add(new Label("itemTitle", assignment.getName())); final ReleaseCheckbox release = new ReleaseCheckbox("release", new PropertyModel<Boolean>(assignment, "released")); final IncludeCheckbox include = new IncludeCheckbox("include", new PropertyModel<Boolean>(assignment, "counted")); final AjaxCheckBox delete = new AjaxCheckBox("delete", Model.of(Boolean.FALSE)){ @Override protected void onUpdate(AjaxRequestTarget target) { updateModel(); if (this.getModel().getObject()) { // if the checkbox has just been checked, this will be True. BulkEditItemsPanel.this.deletableItemsList.add(item.getModelObject().getId()); } else { // this means the checkbox has been unchecked. BulkEditItemsPanel.this.deletableItemsList.remove(item.getModelObject().getId()); } } }; // Are there categories in this Gradebook? If so, and this item is not in a category, disabled grade // calculation inclusion. List<CategoryDefinition> categories = businessService.getGradebookCategories(); if (categories != null && categories.size() > 0 && StringUtils.isBlank(assignment.getCategoryName())) { include.setEnabled(false); } if (assignment.isExternallyMaintained()){ //don't allow External items to be deleted. delete.setEnabled(false); } item.add(release); item.add(include); item.add(delete); }
Example 16
Source File: DashboardPanel.java From nextreports-server with Apache License 2.0 | 4 votes |
private void addColumnsPanel() { final IModel<List<DashboardColumn>> columnsModel = new LoadableDetachableModel<List<DashboardColumn>>() { private static final long serialVersionUID = 1L; @Override protected List<DashboardColumn> load() { List<DashboardColumn> dashboardColumns = new ArrayList<DashboardColumn>(); int columnCount = getDashboard().getColumnCount(); // System.out.println("columnCount = " + columnCount); for (int i = 0; i < columnCount; i++) { dashboardColumns.add(new DashboardColumnModel(getModel(), i).getObject()); } // System.out.println("dashboardColumns = " + dashboardColumns); return dashboardColumns; } }; ListView<DashboardColumn> columnsView = new ListView<DashboardColumn>("columns", columnsModel) { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { if (!hasBeenRendered()) { // System.out.println("....................."); columnPanels = new ArrayList<DashboardColumnPanel>(); } super.onBeforeRender(); } @Override protected void populateItem(ListItem<DashboardColumn> item) { // TODO float columnPanelWidth = 100f / columnsModel.getObject().size(); DashboardColumnPanel columnPanel = createColumnPanel("column", item.getIndex()); columnPanel.getColumnContainer().add(AttributeModifier.replace("style", "width: " + columnPanelWidth + "%;")); item.add(columnPanel); columnPanels.add(columnPanel); System.out.println("... " + columnPanel); } }; add(columnsView); }
Example 17
Source File: TelemetrySettingsPage.java From webanno with Apache License 2.0 | 4 votes |
public TelemetrySettingsPage() { Form<Void> form = new Form<>("form"); settingModel = new ListModel<TelemetrySettings>(listSettings()); ListView<TelemetrySettings> settings = new ListView<TelemetrySettings>("settings") { private static final long serialVersionUID = 7433492093706423431L; @Override protected void populateItem(ListItem<TelemetrySettings> aItem) { // We already filtered for settings where the support exists in listSettings, so // we can rely on the support being present here. TelemetrySupport<?> support = telemetryService .getTelemetrySuppport(aItem.getModelObject().getSupport()).get(); int version = support.getVersion(); aItem.add(new Label("name", support.getName())); aItem.add(support.createTraitsEditor("traitsEditor", aItem.getModel())); aItem.add(new WebMarkupContainer("reviewRequiredMessage").add(visibleWhen( () -> aItem.getModelObject().getVersion() < version))); TelemetryDetailsPanel details = new TelemetryDetailsPanel("details", new ListModel<TelemetryDetail>(support.getDetails())); details.setOutputMarkupPlaceholderTag(true); details.setVisible(false); aItem.add(details); aItem.add(new LambdaAjaxLink("toggleDetails", _target -> { details.setVisible(!details.isVisible()); _target.add(details); })); } }; settings.setModel(settingModel); form.add(settings); form.add(new LambdaAjaxButton<Void>("save", this::actionSave).triggerAfterSubmit()); add(form); }
Example 18
Source File: ListAccessors.java From sakai with Educational Community License v2.0 | 4 votes |
public ListAccessors() { String userId = sessionManager.getCurrentSessionUserId(); Collection<Accessor> accessors = oAuthService.getAccessAccessorForUser(userId); ListView<Accessor> accessorList = new ListView<Accessor>("accessorlist", new ArrayList<>(accessors)) { @Override protected void populateItem(ListItem<Accessor> components) { try { final Consumer consumer = oAuthService.getConsumer(components.getModelObject().getConsumerId()); ExternalLink consumerHomepage = new ExternalLink("consumerUrl", consumer.getUrl(), consumer.getName()); consumerHomepage.add(new AttributeModifier("target", "_blank")); consumerHomepage.setEnabled(consumer.getUrl() != null && !consumer.getUrl().isEmpty()); components.add(consumerHomepage); components.add(new Label("consumerDescription", consumer.getDescription())); components.add(new Label("creationDate", new StringResourceModel("creation.date", new Model<>(components.getModelObject().getCreationDate())))); components.add(new Label("expirationDate", new StringResourceModel("expiration.date", new Model<>(components.getModelObject().getExpirationDate())))); components.add(new Link<Accessor>("delete", components.getModel()) { @Override public void onClick() { try { oAuthService.revokeAccessor(getModelObject().getToken()); setResponsePage(getPage().getClass()); getSession().info(consumer.getName() + "' token has been removed."); } catch (Exception e) { warn("Couldn't remove " + consumer.getName() + "'s token': " + e.getLocalizedMessage()); } } }); } catch (InvalidConsumerException invalidConsumerException) { // Invalid consumer, it is probably deleted // For security reasons, this token should be revoked oAuthService.revokeAccessor(components.getModelObject().getToken()); components.setVisible(false); } } @Override public boolean isVisible() { return !getModelObject().isEmpty() && super.isVisible(); } }; add(accessorList); Label noAccessorLabel = new Label("noAccessor", new ResourceModel("no.accessor")); noAccessorLabel.setVisible(!accessorList.isVisible()); add(noAccessorLabel); }
Example 19
Source File: UserGroupFormPopupPanel.java From artifact-listener with Apache License 2.0 | 4 votes |
@Override protected Component createBody(String wicketId) { DelegatedMarkupPanel body = new DelegatedMarkupPanel(wicketId, UserGroupFormPopupPanel.class); userGroupForm = new Form<UserGroup>("form", getModel()); body.add(userGroupForm); TextField<String> nameField = new RequiredTextField<String>("name", BindingModel.of(userGroupForm.getModel(), Binding.userGroup().name())); nameField.setLabel(new ResourceModel("administration.usergroup.field.name")); userGroupForm.add(nameField); TextArea<String> descriptionField = new TextArea<String>("description", BindingModel.of(userGroupForm.getModel(), Binding.userGroup().description())); descriptionField.setLabel(new ResourceModel("administration.usergroup.field.description")); userGroupForm.add(descriptionField); final CheckGroup<Authority> authorityCheckGroup = new CheckGroup<Authority>("authoritiesGroup", BindingModel.of(userGroupForm.getModel(), Binding.userGroup().authorities()), Suppliers2.<Authority>hashSet()); userGroupForm.add(authorityCheckGroup); ListView<Authority> authoritiesListView = new ListView<Authority>("authorities", Model.ofList(authorityUtils.getPublicAuthorities())) { private static final long serialVersionUID = -7557232825932251026L; @Override protected void populateItem(ListItem<Authority> item) { Authority authority = item.getModelObject(); Check<Authority> authorityCheck = new Check<Authority>("authorityCheck", new GenericEntityModel<Long, Authority>(authority)); authorityCheck.setLabel(new ResourceModel("administration.usergroup.authority." + authority.getName())); authorityCheckGroup.add(authorityCheck); item.add(authorityCheck); } }; authorityCheckGroup.add(authoritiesListView); return body; }
Example 20
Source File: WishListView.java From yes-cart with Apache License 2.0 | 4 votes |
@Override protected void onBeforeRenderPopulateListItem(final ListItem<ProductSearchResultDTO> listItem, final String selectedLocale, final Pair<String, String> thumbWidthHeight) { super.onBeforeRenderPopulateListItem(listItem, selectedLocale, thumbWidthHeight); final LinksSupport links = getWicketSupportFacade().links(); final ProductSearchResultDTO product = listItem.getModel().getObject(); final CustomerWishList itemData = wishListDataByProduct.get(product); final ProductAvailabilityModel pam = productServiceFacade.getProductAvailability(product, ShopCodeContext.getShopId()); final Pair<PriceView, PriceModel> priceView = getPriceView(product, itemData); final String qty = itemData.getQuantity().stripTrailingZeros().toPlainString(); final boolean simpleWishList = CustomerWishList.SIMPLE_WISH_ITEM.equals(itemData.getWlType()); final boolean share = CustomerWishList.PRIVATE.equals(itemData.getVisibility()); final PageParameters visibilityLinks = new PageParameters(); visibilityLinks.add(WebParametersKeys.PAGE_TYPE, "wishlist"); listItem.add( links.newAddToWishListLink("shareItemLink", product.getDefaultSkuCode(), "0", itemData.getWlType(), null, CustomerWishList.SHARED, visibilityLinks) .setVisible(ownerViewing && simpleWishList && share) ); listItem.add( links.newAddToWishListLink("hideItemLink", product.getDefaultSkuCode(), "0", itemData.getWlType(), null, CustomerWishList.PRIVATE, visibilityLinks) .setVisible(ownerViewing && simpleWishList && !share) ); listItem.add( determineAtbLink(links, "addToCardFromWishListLink", product, itemData, qty) .add(new Label("addToCardFromWishListLinkLabel", pam.isInStock() || pam.isPerpetual() ? getLocalizer().getString("addToCartWlBtn", this, new Model<Serializable>(new ValueMap(Collections.singletonMap("quantity", qty)))) : getLocalizer().getString("preorderCartWlBtn", this, new Model<Serializable>(new ValueMap(Collections.singletonMap("quantity", qty)))))) .setVisible(!priceView.getSecond().isPriceUponRequest() && MoneyUtils.isPositive(priceView.getSecond().getRegularPrice()) && pam.isAvailable()) ); listItem.add( links.newRemoveFromWishListLink("removeFromWishListLink", product.getFulfilmentCentreCode(), product.getDefaultSkuCode(), itemData.getCustomerwishlistId(), (Class) getPage().getClass(), null) .add(new Label("removeFromWishListLinkLabel", getLocalizer().getString("removeFromWishlist", this))) .setVisible(ownerViewing) ); listItem.add(priceView.getFirst()); listItem.add(new AttributeModifier("data-tag", itemData.getTag())); listItem.add(new AttributeModifier("data-visibility", itemData.getVisibility())); listItem.add(new AttributeModifier("data-type", itemData.getWlType())); listItem.add(new AttributeModifier("data-sku", product.getDefaultSkuCode())); listItem.add(new AttributeModifier("data-fc", itemData.getSupplierCode())); listItem.add(new AttributeModifier("data-qty", itemData.getQuantity().toPlainString())); }