List of usage examples for org.apache.wicket.markup.html.list ListView setReuseItems
public ListView<T> setReuseItems(boolean reuseItems)
From source file:org.jabylon.rest.ui.wicket.config.sections.WorkspaceConfigSection.java
License:Open Source License
public WorkspaceConfigSection(String id, IModel<Workspace> object, Preferences prefs) { super(id, object); add(buildAddNewLink(object));/*from www . j a v a2 s . com*/ ComplexEObjectListDataProvider<Project> provider = new ComplexEObjectListDataProvider<Project>(object, PropertiesPackage.Literals.RESOLVABLE__CHILDREN); ListView<Project> project = new ListView<Project>("projects", provider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Project> item) { item.add(new BookmarkablePageLink<Void>("edit", SettingsPage.class, WicketUtil.buildPageParametersFor(item.getModelObject()))); item.add(new Label("project-name", item.getModelObject().getName())); item.add(createDeleteAction(item.getModel())); } }; project.setReuseItems(true); add(project); }
From source file:org.jabylon.scheduler.ui.JobOverviewPanel.java
License:Open Source License
@Override protected void construct() { super.construct(); jobsModel = createJobsModel();/*w w w. j av a 2s . c o m*/ WebMarkupContainer container = new WebMarkupContainer("container", jobsModel); IModel<Integer> sizeModel = new ComputableModel<IModel<List<JobInstance>>, Integer>(new SizeFunction(), jobsModel); Label noJobs = new Label("running-jobs", nls("running.jobs.title", sizeModel)); noJobs.setOutputMarkupId(true); container.add(noJobs); ListView<JobInstance> list = new ListView<JobInstance>("list", jobsModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<JobInstance> item) { JobInstance instance = item.getModelObject(); String argLab = getLabel(instance.getDomainObject()); if (argLab == null) item.add(new Label("title", nls(instance.getExecutionObject().getClass(), instance.getDescription()))); else item.add(new Label("title", nls(instance.getExecutionObject().getClass(), instance.getDescription(), argLab))); ProgressionModel model = new ProgressionModel(instance.getID()); ProgressPanel progressPanel = new ProgressPanel("panel", model); item.add(progressPanel); item.setOutputMarkupId(true); progressPanel.start(); } private String getLabel(Object domainObject) { if (domainObject instanceof Workspace) { return "Workspace"; } if (domainObject instanceof Resolvable) { @SuppressWarnings("rawtypes") Resolvable r = (Resolvable) domainObject; return r.fullPath().toString(); } return null; } }; list.setOutputMarkupId(true); list.setReuseItems(true); container.add(list); container.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1))); add(container); }
From source file:org.jabylon.updatecenter.repository.ui.UpdatecenterTabContent.java
License:Open Source License
public UpdatecenterTabContent(String id, IModel<ResourceFilter> model, PageParameters parameters) { super(id, model, parameters); resources = Model.ofList(new LoadBundlesFunction().apply(model)); Form<Void> form = new Form<Void>("form") { private static final long serialVersionUID = 1L; @Override//from w w w . java 2 s. co m protected void onSubmit() { super.onSubmit(); List<? extends ResourceWrapper> list = resources.getObject(); List<Resource> toBeChanged = new ArrayList<Resource>(); for (ResourceWrapper wrapper : list) { if (!wrapper.isChecked()) continue; Resource[] resources = repositoryConnector.findResources(wrapper.getId()); for (Resource resource2 : resources) { logger.info("Installing Resource {}", resource2.getSymbolicName()); toBeChanged.add(resource2); } } try { repositoryConnector.install(toBeChanged.toArray(new Resource[toBeChanged.size()])); } catch (OBRException e) { if (e.getCause() != null) getSession().error(e.getCause().getMessage()); else getSession().error(e.getMessage()); } if (!toBeChanged.isEmpty()) { //get rid of the page version to get a full refresh PageParameters parameters = new PageParameters(); parameters.set(0, "settings"); setResponsePage(getPage().getClass(), parameters); } } }; add(form); ListView<ResourceWrapper> resourceView = new ListView<ResourceWrapper>("row", resources) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<ResourceWrapper> item) { ResourceWrapper resourceWrapper = item.getModelObject(); Resource resource = resourceWrapper.getResource(); String name = resource.getSymbolicName(); item.add(new Label("name", name)); String description = (String) resource.getProperties().get(Resource.DESCRIPTION); if (description == null) description = resource.getPresentationName(); item.add(new Label("description", description)); item.add(new Label("version", resource.getVersion().toString())); item.add(new CheckBox("install", new PropertyModel<Boolean>(item.getModel(), "checked"))); } }; resourceView.setReuseItems(true); form.add(resourceView); }
From source file:org.onehippo.forge.settings.management.config.autoexport.AutoExportConfigPanel.java
License:Apache License
private void addModulesConfigurationToForm() { final WebMarkupContainer listContainer = new WebMarkupContainer("modulesContainer"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); final AutoExportConfig autoExportConfig = autoExportConfigModel.getObject(); //final ArrayList<String> modulesList = autoExportConfig.getModules(); ListView<String> modules = new ListView<String>("autoexport-modules", new PropertyModel(autoExportConfigModel, "modules")) { private static final long serialVersionUID = 1L; @Override//from w w w .ja va 2 s .co m protected void populateItem(final ListItem<String> item) { RequiredTextField moduleField = new RequiredTextField("module", item.getModel()); moduleField.setOutputMarkupId(true); moduleField.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); item.add(moduleField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //modulesList.remove(item.getIndex()); //autoExportConfigModel.getObject().setModules(modulesList); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; modules.setReuseItems(true); listContainer.add(modules); add(listContainer); }
From source file:org.onehippo.forge.settings.management.config.formdata.FormdataConfigPanel.java
License:Apache License
private void addExclusionPaths(FormdataConfig formdataConfig) { final WebMarkupContainer listContainer = new WebMarkupContainer("excludedPathsView"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); // Don't do this in a listview final ListView<String> excludedPathsView; excludedPathsView = new ListView<String>("formdata-excludedPaths", new PropertyModel(formdataConfig, "excludepaths")) { private static final long serialVersionUID = 1L; @Override//from w ww. j a v a 2 s . c om protected void populateItem(final ListItem<String> item) { RequiredTextField extensionField = new RequiredTextField("formdata-path", item.getModel()); extensionField.setOutputMarkupId(true); item.add(extensionField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { getModelObject().remove(item.getModelObject()); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; AjaxLink addExtension = new AjaxLink("add-path") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { excludedPathsView.getModelObject().add(""); target.add(listContainer); target.focusComponent(this); } }; excludedPathsView.setReuseItems(true); listContainer.add(excludedPathsView); listContainer.add(addExtension); add(listContainer); }
From source file:org.onehippo.forge.settings.management.config.upload.AssetValidationServiceConfigPanel.java
License:Apache License
private void addAllowedExtensionsField(AssetValidationServiceConfig assetValidationServiceConfig) { final WebMarkupContainer listContainer = new WebMarkupContainer("allowedExtensionsView"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); // Don't do this in a listview final ListView<String> allowedExtensionsView; allowedExtensionsView = new ListView<String>("assetvalidation-allowedExtensions", new PropertyModel(assetValidationServiceConfig, "allowedExtensions")) { private static final long serialVersionUID = 1L; @Override/*from ww w .j ava 2 s.c o m*/ protected void populateItem(final ListItem<String> item) { RequiredTextField extensionField = new RequiredTextField("asset-extension", item.getModel()); extensionField.setOutputMarkupId(true); item.add(extensionField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { getModelObject().remove(item.getModelObject()); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; AjaxLink addExtension = new AjaxLink("add-extension") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { allowedExtensionsView.getModelObject().add(""); target.add(listContainer); target.focusComponent(this); } }; allowedExtensionsView.setReuseItems(true); listContainer.add(allowedExtensionsView); listContainer.add(addExtension); add(listContainer); }
From source file:org.onehippo.forge.settings.management.config.upload.ImageValidationServiceConfigPanel.java
License:Apache License
private void addAllowedExtensionsField(ImageValidationServiceConfig imageValidationServiceConfig) { final WebMarkupContainer listContainer = new WebMarkupContainer("allowedExtensionsView"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); // Don't do this in a listview final ListView<String> allowedExtensionsView; allowedExtensionsView = new ListView<String>("imagevalidation-allowedExtensions", new PropertyModel(imageValidationServiceConfig, "allowedExtensions")) { private static final long serialVersionUID = 1L; @Override/* ww w. jav a2 s . c o m*/ protected void populateItem(final ListItem<String> item) { RequiredTextField extensionField = new RequiredTextField("image-extension", item.getModel()); extensionField.setOutputMarkupId(true); item.add(extensionField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { getModelObject().remove(item.getModelObject()); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; AjaxLink addExtension = new AjaxLink("add-extension") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { allowedExtensionsView.getModelObject().add(""); target.add(listContainer); target.focusComponent(this); } }; allowedExtensionsView.setReuseItems(true); listContainer.add(allowedExtensionsView); listContainer.add(addExtension); add(listContainer); }
From source file:org.syncope.console.pages.panels.StatusPanel.java
License:Apache License
public <T extends AbstractAttributableTO> StatusPanel(final String id, final UserTO userTO, final List<StatusBean> selectedResources, final boolean enabled) { super(id);//from w ww. j av a 2 s. c om final List<StatusBean> statuses = new ArrayList<StatusBean>(); final StatusBean syncope = new StatusBean(); syncope.setAccountLink(userTO.getUsername()); syncope.setResourceName("Syncope"); syncope.setStatus( userTO.getStatus() != null ? Status.valueOf(userTO.getStatus().toUpperCase()) : Status.UNDEFINED); statuses.add(syncope); statuses.addAll(statusUtils.getRemoteStatuses(userTO)); final CheckGroup group = new CheckGroup("group", selectedResources); add(group); final Fragment headerCheckFrag; if (enabled) { headerCheckFrag = new Fragment("headerCheck", "headerCheckFrag", this); headerCheckFrag.add(new CheckGroupSelector("groupselector", group)); } else { headerCheckFrag = new Fragment("headerCheck", "emptyCheckFrag", this); } add(headerCheckFrag); final ListView<StatusBean> resources = new ListView<StatusBean>("resources", statuses) { private static final long serialVersionUID = 4949588177564901031L; @Override protected void populateItem(final ListItem<StatusBean> item) { final Image image; final String alt, title; boolean checkVisibility = true; switch (item.getModelObject().getStatus()) { case ACTIVE: image = new Image("icon", "statuses/active.png"); alt = "active icon"; title = "Enabled"; break; case UNDEFINED: image = new Image("icon", "statuses/undefined.png"); checkVisibility = false; alt = "undefined icon"; title = "Undefined status"; break; case USER_NOT_FOUND: image = new Image("icon", "statuses/usernotfound.png"); checkVisibility = false; alt = "notfound icon"; title = "User not found"; break; default: image = new Image("icon", "statuses/inactive.png"); alt = "inactive icon"; title = "Disabled"; } image.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("alt", alt); tag.put("title", title); } }); final Fragment checkFrag; if (!enabled) { checkFrag = new Fragment("rowCheck", "emptyCheckFrag", group.getParent()); } else { final Check check = new Check("check", item.getModel(), group); check.setEnabled(checkVisibility); check.setVisible(checkVisibility); checkFrag = new Fragment("rowCheck", "rowCheckFrag", getParent()); checkFrag.add(check); } item.add(checkFrag); item.add(new Label("resource", new ResourceModel(item.getModelObject().getResourceName(), item.getModelObject().getResourceName()))); if (StringUtils.isNotBlank(item.getModelObject().getAccountLink())) { item.add(new Label("accountLink", new ResourceModel(item.getModelObject().getAccountLink(), item.getModelObject().getAccountLink()))); } else { item.add(new Label("accountLink", "")); } item.add(image); } }; resources.setReuseItems(true); group.add(resources); }
From source file:org.wicketstuff.mbeanview.AttributeValuesPanel.java
License:Apache License
public AttributeValuesPanel(String id, final IModel<MBeanServer> server, final ObjectName objectName, MBeanAttributeInfo[] beanAttributeInfos) { super(id, server); add(modalOutput = new ModalWindow("modalOutput")); modalOutput.setCookieName("modalOutput"); Form<Void> form = new Form<Void>("form"); add(form);/*from w ww . j a va2 s . c o m*/ ListView<MBeanAttributeInfo> attributes = new ListView<MBeanAttributeInfo>("attributes", Arrays.asList(beanAttributeInfos)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MBeanAttributeInfo> item) { final MBeanAttributeInfo info = item.getModelObject(); item.add(new Label("name", info.getName())); final AttributeModel model = new AttributeModel(server, objectName, info) { @Override protected void onError(Throwable throwable) { item.error(throwable.toString()); } }; AjaxLink<Void> link = new AjaxLink<Void>("value") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { modalOutput.setContent(new DataViewPanel(modalOutput.getContentId(), model)); modalOutput.setTitle(info.getName()); modalOutput.show(target); } @Override public boolean isEnabled() { return model.getObject() instanceof Collection || model.getObject() != null && model.getObject().getClass().isArray(); } @Override public boolean isVisible() { return !info.isWritable(); } }; item.add(link); link.add(new Label("label", model)); item.add(new TextField<Object>("editableValue", model, Object.class) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return info.isWritable(); } @Override public <C> IConverter<C> getConverter(Class<C> type) { return new ValueConverter(item.getModelObject().getType()); } }); item.add(new FencedFeedbackPanel("feedback", item)); } }; attributes.setReuseItems(true); form.add(attributes); form.add(new Button("submit")); }
From source file:org.wicketstuff.mbeanview.OperationsPanel.java
License:Apache License
public OperationsPanel(String id, final IModel<MBeanServer> server, final ObjectName objectName, MBeanOperationInfo[] beanOperationInfos) { super(id);/* w w w . j a v a 2 s . c om*/ this.objectName = objectName; add(modalOutput = new ModalWindow("modalOutput")); modalOutput.setTitle("Operation result view."); modalOutput.setCookieName("modalOutput"); Form<Void> form = new Form<Void>("form"); add(form); ListView<MBeanOperationInfo> operations = new ListView<MBeanOperationInfo>("operations", Arrays.asList(beanOperationInfos)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MBeanOperationInfo> item) { final MBeanOperationInfo info = item.getModelObject(); String returnLbl = info.getReturnType(); try { Class<?> c = Class.forName(info.getReturnType()); if (c.isArray()) { returnLbl = c.getComponentType().getSimpleName() + "[]"; } else { returnLbl = c.getSimpleName(); } } catch (ClassNotFoundException e) { } item.add(new Label("return", returnLbl)); IModel<Object[]> values = Model.of(new Object[info.getSignature().length]); ParameterRepeater parameterRepeater = new ParameterRepeater("parameters", info.getSignature(), values); item.add(parameterRepeater); final FencedFeedbackPanel feedback = new FencedFeedbackPanel("feedback", item); feedback.setOutputMarkupId(true); item.add(feedback); item.add(new OperationButton("method", server, info, values) { private static final long serialVersionUID = 1L; @Override protected void onFailure(Exception e, AjaxRequestTarget target) { List<String> returnList = new ArrayList<String>(); returnList.add(e.getMessage()); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); returnList.add(sw.toString()); modalOutput.setTitle("Failure"); modalOutput.setContent( new DataViewPanel(modalOutput.getContentId(), Model.ofList(returnList))); modalOutput.show(target); } @Override protected void onSuccess(Object returnObj, AjaxRequestTarget target) { if (returnObj == null) { item.info("Success"); target.add(feedback); } else { modalOutput.setTitle("Success"); modalOutput.setContent(new DataViewPanel(modalOutput.getContentId(), Model.of((Serializable) returnObj))); modalOutput.show(target); } } }); } }; operations.setReuseItems(true); form.add(operations); }