Java Code Examples for org.apache.wicket.markup.repeater.RepeatingView#newChildId()
The following examples show how to use
org.apache.wicket.markup.repeater.RepeatingView#newChildId() .
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: JiraIssuesPanel.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
public JiraIssuesPanel(final String id, final IModel<String> model) { super(id); setRenderBodyOnly(true); if (WicketUtils.isJIRAConfigured() == false) { final WebMarkupContainer dummy = new WebMarkupContainer("issues"); setVisible(false); dummy.add(new ExternalLink("jiraLink", "dummy")); add(dummy); return; } final RepeatingView jiraIssuesRepeater = new RepeatingView("issues"); add(jiraIssuesRepeater); final String[] jiraIssues = JiraUtils.checkForJiraIssues(model.getObject()); if (jiraIssues == null) { jiraIssuesRepeater.setVisible(false); } else { for (final String issue : jiraIssues) { final WebMarkupContainer item = new WebMarkupContainer(jiraIssuesRepeater.newChildId()); item.setRenderBodyOnly(true); jiraIssuesRepeater.add(item); item.add(new ExternalLink("jiraLink", JiraUtils.buildJiraIssueBrowseLinkUrl(issue), issue)); } } }
Example 2
Source File: AbstractSecuredPage.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("serial") private void addBreadCrumbs(final RepeatingView breadcrumbItems, final AbstractSecuredPage page) { final WebPage returnTo = page.getReturnToPage(); if (returnTo != null && returnTo instanceof AbstractSecuredPage) { addBreadCrumbs(breadcrumbItems, (AbstractSecuredPage) returnTo); } final WebMarkupContainer li = new WebMarkupContainer(breadcrumbItems.newChildId()); breadcrumbItems.add(li); final Link<Void> pageLink = new Link<Void>("link") { @Override public void onClick() { setResponsePage(page); } }; li.add(pageLink); pageLink.add(new Label("label", page.getTitle())); }
Example 3
Source File: AbstractImportStoragePanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
protected Component addCell(final RepeatingView cellRepeater, final Component comp, final String style) { final WebMarkupContainer cell = new WebMarkupContainer(cellRepeater.newChildId()); cellRepeater.add(cell); cell.add(comp); if (style != null) { comp.add(AttributeModifier.replace("style", style)); } return comp; }
Example 4
Source File: AddressListPage.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
private boolean addPhoneNumber(final RepeatingView view, final Integer addressId, final PhoneType phoneType, final String phoneNumber, final boolean favoriteNumber, final boolean sendSms, final IconType icon, final boolean first) { if (StringUtils.isBlank(phoneNumber) == true) { return first; } if (first == false) { view.add(new Label(view.newChildId(), "<br/>").setEscapeModelStrings(false).setRenderBodyOnly(true)); } final AddressListPhoneNumberPanel phoneNumberPanel = new AddressListPhoneNumberPanel(view.newChildId(), this, addressId, phoneType, phoneNumber, favoriteNumber, sendSms, icon, first); view.add(phoneNumberPanel); return false; }
Example 5
Source File: AccessEditTablePanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
private void addAccessRow(final RepeatingView rowRepeater, final AccessEntryDO accessEntry) { final WebMarkupContainer row = new WebMarkupContainer(rowRepeater.newChildId()); rowRepeater.add(row); row.add(new Label("area", getString(accessEntry.getAccessType().getI18nKey()))); final ButtonGroupPanel groupPanel = new ButtonGroupPanel("checkboxes").setToggleButtons(); row.add(groupPanel); groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessSelect"), getString("access.type.select"))); groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessInsert"), getString("access.type.insert"))); groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessUpdate"), getString("access.type.update"))); groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessDelete"), getString("access.type.delete"))); }
Example 6
Source File: MenuConfigContent.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public MenuConfigContent(final String id, final Menu menu) { super(id); final RepeatingView mainMenuRepeater = new RepeatingView("mainMenuItem"); add(mainMenuRepeater); if (menu == null) { mainMenuRepeater.setVisible(false); log.error("Oups, menu is null. Configuration of favorite menu not possible."); return; } int counter = 0; if (menu.getMenuEntries() == null) { // Should only occur in maintenance mode! return; } for (final MenuEntry mainMenuEntry : menu.getMenuEntries()) { if (mainMenuEntry.hasSubMenuEntries() == false) { continue; } final WebMarkupContainer mainMenuContainer = new WebMarkupContainer(mainMenuRepeater.newChildId()); mainMenuRepeater.add(mainMenuContainer); if (counter++ % 5 == 0) { mainMenuContainer.add(AttributeModifier.append("class", "mm_clear")); } mainMenuContainer.add(new Label("label", new ResourceModel(mainMenuEntry.getI18nKey()))); final RepeatingView subMenuRepeater = new RepeatingView("menuItem"); mainMenuContainer.add(subMenuRepeater); for (final MenuEntry subMenuEntry : mainMenuEntry.getSubMenuEntries()) { final WebMarkupContainer subMenuContainer = new WebMarkupContainer(subMenuRepeater.newChildId()); subMenuRepeater.add(subMenuContainer); final AbstractLink link = NavAbstractPanel.getMenuEntryLink(subMenuEntry, false); if (link != null) { subMenuContainer.add(link); } else { subMenuContainer.setVisible(false); } } } }
Example 7
Source File: AbstractImportStoragePanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
protected void addActionLink(final RepeatingView actionLinkRepeater, final AbstractLink link, final String labelText, final String tooltip) { final WebMarkupContainer actionLinkContainer = new WebMarkupContainer(actionLinkRepeater.newChildId()); actionLinkRepeater.add(actionLinkContainer); final Label label = new Label("label", labelText); if (tooltip != null) { WicketUtils.addTooltip(label, tooltip); } actionLinkContainer.add(link.add(label)); }
Example 8
Source File: SetupImportForm.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("serial") protected void init() { add(createFeedbackPanel()); final GridBuilder gridBuilder = newGridBuilder(this, "flowform"); gridBuilder.newFormHeading(getString("import")); { // Upload dump file final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.setup.dumpFile")); fileUploadField = new FileUploadField(FileUploadPanel.WICKET_ID); fs.add(new FileUploadPanel(fs.newChildId(), fileUploadField)); } final RepeatingView actionButtons = new RepeatingView("buttons"); add(actionButtons); { final Button importButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("import")) { @Override public final void onSubmit() { parentPage.upload(); } }; final SingleButtonPanel importButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), importButton, getString("import"), SingleButtonPanel.DEFAULT_SUBMIT); actionButtons.add(importButtonPanel); } }
Example 9
Source File: GuidelinesDialogContent.java From webanno with Apache License 2.0 | 5 votes |
public GuidelinesDialogContent(String aId, final ModalWindow modalWindow, final IModel<AnnotatorState> aModel) { super(aId); // Overall progress by Projects RepeatingView guidelineRepeater = new RepeatingView("guidelineRepeater"); add(guidelineRepeater); for (String guidelineFileName : projectService .listGuidelines(aModel.getObject().getProject())) { AbstractItem item = new AbstractItem(guidelineRepeater.newChildId()); guidelineRepeater.add(item); // Add a popup window link to display annotation guidelines PopupSettings popupSettings = new PopupSettings(RESIZABLE | SCROLLBARS) .setHeight(500) .setWidth(700); IResourceStream stream = new FileResourceStream(projectService .getGuideline(aModel.getObject().getProject(), guidelineFileName)); ResourceStreamResource resource = new ResourceStreamResource(stream); ResourceLink<Void> rlink = new ResourceLink<>("guideine", resource); rlink.setPopupSettings(popupSettings); item.add(new Label("guidelineName", guidelineFileName)); item.add(rlink); } add(new LambdaAjaxLink("cancel", (target) -> modalWindow.close(target))); }
Example 10
Source File: SimpleUserListPanel.java From onedev with MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); RepeatingView usersView = new RepeatingView("users"); for (User user: getUsers()) { WebMarkupContainer container = new WebMarkupContainer(usersView.newChildId()); container.add(new UserAvatar("avatar", user)); container.add(new Label("name", user.getDisplayName())); usersView.add(container); } add(usersView); }
Example 11
Source File: FieldListViewPanel.java From onedev with MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); RepeatingView fieldsView = new RepeatingView("fields"); for (FieldSupply field: fields) { WebMarkupContainer container = new WebMarkupContainer(fieldsView.newChildId()); container.add(new Label("name", field.getName())); if (field.getValueProvider() instanceof SpecifiedValue) { if (field.isSecret()) container.add(new Label("valueProvider", SpecifiedValue.SECRET_DISPLAY_NAME)); else container.add(new Label("valueProvider", SpecifiedValue.DISPLAY_NAME)); List<String> value = field.getValueProvider().getValue(); if (value.size() == 0) container.add(new Label("value", "<i>Empty</i>").setEscapeModelStrings(false)); else if (value.size() == 1) container.add(new Label("value", value.iterator().next())); else container.add(new Label("value", value.toString())); } else if (field.getValueProvider() instanceof ScriptingValue) { if (field.isSecret()) container.add(new Label("valueProvider", ScriptingValue.SECRET_DISPLAY_NAME)); else container.add(new Label("valueProvider", ScriptingValue.DISPLAY_NAME)); container.add(PropertyContext.view("value", field.getValueProvider(), "scriptName")); } else { container.add(new WebMarkupContainer("value")); } fieldsView.add(container); } add(fieldsView); }
Example 12
Source File: BeanListPropertyEditor.java From onedev with MIT License | 5 votes |
private WebMarkupContainer addRow(Serializable element) { WebMarkupContainer row = new WebMarkupContainer(rows.newChildId()); row.setOutputMarkupId(true); rows.add(row); RepeatingView columns = new RepeatingView("properties"); row.add(columns); for (PropertyContext<Serializable> propertyContext: propertyContexts) { WebMarkupContainer column = new WebMarkupContainer(columns.newChildId()); column.add(AttributeAppender.append("class", "property-" + propertyContext.getPropertyName())); columns.add(column); Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element); PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue)); column.add(propertyEditor); column.add(new FencedFeedbackPanel("feedback", propertyEditor)); } row.add(new AjaxButton("deleteElement") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { super.onSubmit(target, form); markFormDirty(target); target.appendJavaScript($(row).chain("remove").get()); rows.remove(row); target.add(noElements); onPropertyUpdating(target); } }.setDefaultFormProcessing(false)); return row; }
Example 13
Source File: DynaFormPanel.java From yes-cart with Apache License 2.0 | 4 votes |
/** * Construct dynamic form. * * @param id component id. * @param customerModel customer model */ public DynaFormPanel(final String id, final IModel<Customer> customerModel) { super(id, customerModel); final Shop shop = getCurrentShop(); final Customer customer = (Customer) getDefaultModelObject(); final List<Pair<AttrValueWithAttribute, Boolean>> attrValueCollection = customerService.getCustomerProfileAttributes(shop, customer); final Form form = new Form<Object>(FORM) { @Override protected void onSubmit() { LOG.debug("Attributes will be updated for customer [{}]", customer.getEmail()); final Map<String, String> values = new HashMap<>(); for (Pair<? extends AttrValueWithAttribute, Boolean> av : attrValueCollection) { LOG.debug("Attribute with code [{}] has value [{}], readonly [{}]", av.getFirst().getAttribute().getCode(), av.getFirst().getVal(), av.getSecond() ); if (av.getSecond() != null && !av.getSecond()) { if ("salutation".equals(av.getFirst().getAttribute().getCode())) { customer.setSalutation(av.getFirst().getVal()); } else if ("firstname".equals(av.getFirst().getAttribute().getCode())) { if (StringUtils.isNotBlank(av.getFirst().getVal())) { customer.setFirstname(av.getFirst().getVal()); } } else if ("middlename".equals(av.getFirst().getAttribute().getCode())) { customer.setMiddlename(av.getFirst().getVal()); } else if ("lastname".equals(av.getFirst().getAttribute().getCode())) { if (StringUtils.isNotBlank(av.getFirst().getVal())) { customer.setLastname(av.getFirst().getVal()); } } else if ("companyname1".equals(av.getFirst().getAttribute().getCode())) { customer.setCompanyName1(av.getFirst().getVal()); } else if ("companyname2".equals(av.getFirst().getAttribute().getCode())) { customer.setCompanyName2(av.getFirst().getVal()); } else if ("companydepartment".equals(av.getFirst().getAttribute().getCode())) { customer.setCompanyDepartment(av.getFirst().getVal()); } else if (!av.getFirst().getAttribute().isMandatory() || StringUtils.isNotBlank(av.getFirst().getVal())) { values.put(av.getFirst().getAttribute().getCode(), av.getFirst().getVal()); } } } customerService.updateCustomerAttributes(getCurrentShop(), customer, values); info(getLocalizer().getString("profileUpdated", this)); } }; addOrReplace(form); RepeatingView fields = new RepeatingView(FIELDS); form.add(fields); final String lang = getLocale().getLanguage(); for (Pair<? extends AttrValueWithAttribute, Boolean> attrValue : attrValueCollection) { WebMarkupContainer row = new WebMarkupContainer(fields.newChildId()); row.add(getLabel(attrValue.getFirst(), lang)); row.add(getEditor(attrValue.getFirst(), attrValue.getSecond())); fields.add(row); } form.add( new SubmitLink(SAVE_LINK) ); form.add(new Label(CONTENT, "")); form.setVisible(!attrValueCollection.isEmpty()); }
Example 14
Source File: ViewsFunctionBoxPanel.java From ontopia with Apache License 2.0 | 4 votes |
public ViewsFunctionBoxPanel(String id, TopicModel<Topic> topicModel, TopicTypeModel topicTypeModel, FieldsViewModel fieldsViewModel) { super(id); add(new Label("title", new ResourceModel("views.list.header"))); Topic topic = topicModel.getTopic(); TopicMap tm = topic.getTopicMap(); TopicType topicType = topicTypeModel.getTopicType(); FieldsView fieldsView = fieldsViewModel.getFieldsView(); Collection<FieldsView> views = topicType.getFieldViews(fieldsView); if (views.isEmpty()) setVisible(false); FieldsView currentView = fieldsViewModel.getFieldsView(); FieldsView defaultView = FieldsView.getDefaultFieldsView(topicType.getTopicMap()); if (currentView == null) currentView = defaultView; RepeatingView rv = new RepeatingView("rows"); add(rv); for (FieldsView view : views) { WebMarkupContainer parent = new WebMarkupContainer(rv.newChildId()); rv.add(parent); Map<String,String> pageParametersMap = new HashMap<String,String>(); pageParametersMap.put("topicMapId", tm.getId()); pageParametersMap.put("topicId", topic.getId()); pageParametersMap.put("topicTypeId", topicType.getId()); if (!Objects.equals(view, defaultView)) pageParametersMap.put("viewId", view.getId()); if (topic.isOntologyTopic()) pageParametersMap.put("ontology", "true"); String viewName = view.getName(); OntopolyBookmarkablePageLink link = new OntopolyBookmarkablePageLink("link", InstancePage.class, new PageParameters(pageParametersMap), viewName); link.setEnabled(!Objects.equals(currentView, view)); parent.add(link); } }
Example 15
Source File: TopicTypesFunctionBoxPanel.java From ontopia with Apache License 2.0 | 4 votes |
public TopicTypesFunctionBoxPanel(String id, TopicModel<Topic> topicModel, TopicTypeModel topicTypeModel, FieldsViewModel fieldsViewModel) { super(id); add(new Label("title", new ResourceModel("topictypes.list.header"))); List<TopicType> types = topicModel.getTopic().getTopicTypes(); if (types.isEmpty()) setVisible(false); TopicType currentTopicType = topicTypeModel.getTopicType(); FieldsView currentView = fieldsViewModel.getFieldsView(); RepeatingView rv = new RepeatingView("rows"); add(rv); Iterator<TopicType> iter = types.iterator(); while (iter.hasNext()) { TopicType topicType = iter.next(); boolean isCurrentTopicType = Objects.equals(currentTopicType, topicType); WebMarkupContainer parent = new WebMarkupContainer(rv.newChildId()); rv.add(parent); Topic topic = topicModel.getTopic(); TopicMap tm = topic.getTopicMap(); Map<String,String> pageParametersMap = new HashMap<String,String>(); pageParametersMap.put("topicMapId", tm.getId()); pageParametersMap.put("topicId", topic.getId()); pageParametersMap.put("topicTypeId", topicType.getId()); if (currentView != null && isCurrentTopicType) pageParametersMap.put("viewId", currentView.getId()); String linkText = topicType.getName(); OntopolyBookmarkablePageLink link = new OntopolyBookmarkablePageLink("link", InstancePage.class, new PageParameters(pageParametersMap), linkText); link.setEnabled(!isCurrentTopicType); parent.add(link); } }
Example 16
Source File: AbstractImportStoragePanel.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
public void refresh() { if (errorPropertiesTable != null) { remove(errorPropertiesTable); } if (storageHeadingLabel != null) { remove(storageHeadingLabel); } add(storageHeadingLabel = new Label("storageHeading", "Import storage: " + (storage != null ? storage.getFilename() : ""))) .setRenderBodyOnly(true); add(errorPropertiesTable = new WebMarkupContainer("errorPropertiesTable")); if (MapUtils.isNotEmpty(errorProperties) == true) { final RepeatingView errorPropertiesView = new RepeatingView("errorProperties"); errorPropertiesTable.add(errorPropertiesView); for (final Map.Entry<String, Set<Object>> entry : errorProperties.entrySet()) { final WebMarkupContainer entryContainer = new WebMarkupContainer(errorPropertiesView.newChildId()); errorPropertiesView.add(entryContainer); entryContainer.add(new Label("propertyKey", entry.getKey())); final StringBuffer buf = new StringBuffer(); boolean first = true; for (final Object value : entry.getValue()) { first = StringHelper.append(buf, first, String.valueOf(value), ", "); } entryContainer.add(new Label("propertyItems", buf.toString())); } } else { errorPropertiesTable.setVisible(false); } if (errorPropertiesTable == null) { add(errorPropertiesTable = new WebMarkupContainer("errorPropertiesTable")).setVisible(false); } if (storageHeadingLabel == null) { add(storageHeadingLabel = (Label) new Label("storageHeading", "[invisible]").setVisible(false)); } sheetRepeatingView.removeAll(); if (storage.getSheets() != null) { for (final ImportedSheet< ? > sheet : storage.getSheets()) { addSheet(sheet); } } }
Example 17
Source File: SystemUpdateForm.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("serial") protected void updateEntryRows() { scripts.removeAll(); final RepeatingView scriptRows = new RepeatingView("scriptRows"); scripts.add(scriptRows); final SortedSet<UpdateEntry> updateEntries = parentPage.myDatabaseUpdater.getSystemUpdater().getUpdateEntries(); if (updateEntries == null) { return; } boolean odd = true; for (final UpdateEntry updateEntry : updateEntries) { if (showOldUpdateScripts == false && updateEntry.getPreCheckStatus() == UpdatePreCheckStatus.ALREADY_UPDATED) { continue; } final Version version = updateEntry.getVersion(); final WebMarkupContainer item = new WebMarkupContainer(scriptRows.newChildId()); scriptRows.add(item); if (odd == true) { item.add(AttributeModifier.append("class", "odd")); } else { item.add(AttributeModifier.append("class", "even")); } odd = !odd; item.add(new Label("regionId", updateEntry.getRegionId())); if (updateEntry.isInitial() == true) { item.add(new Label("version", "initial")); } else { item.add(new Label("version", version.toString())); } final String description = updateEntry.getDescription(); item.add(new Label("description", StringUtils.isBlank(description) == true ? "" : description)); item.add(new Label("date", updateEntry.getDate())); final String preCheckResult = updateEntry.getPreCheckResult(); item.add(new Label("preCheckResult", HtmlHelper.escapeHtml(preCheckResult, true))); if (updateEntry.getPreCheckStatus() == UpdatePreCheckStatus.READY_FOR_UPDATE) { final Button updateButton = new Button("button", new Model<String>("update")) { @Override public final void onSubmit() { parentPage.update(updateEntry); } }; item.add(new SingleButtonPanel("update", updateButton, "update")); } else { final String runningResult = updateEntry.getRunningResult(); item.add(new Label("update", HtmlHelper.escapeHtml(runningResult, true))); } } }
Example 18
Source File: BuildSpecBlobViewPanel.java From onedev with MIT License | 4 votes |
@Override protected void onInitialize() { super.onInitialize(); try { Blob blob = context.getProject().getBlob(context.getBlobIdent(), true); BuildSpec buildSpec = BuildSpec.parse(blob.getBytes()); if (buildSpec != null) { Fragment validFrag = new Fragment("content", "validFrag", this); if (!buildSpec.getJobs().isEmpty()) { Fragment hasJobsFrag = new Fragment("jobs", "hasJobsFrag", this); RepeatingView navsView = new RepeatingView("navs"); RepeatingView jobsView = new RepeatingView("contents"); for (Job job: buildSpec.getJobs()) { WebMarkupContainer nav = new WebMarkupContainer(navsView.newChildId()); nav.add(new Label("jobName", job.getName())); nav.add(AttributeAppender.append("data-name", job.getName())); nav.add(new RunJobLink("run", context.getCommit().copy(), job.getName()) { @Override protected Project getProject() { return context.getProject(); } }); navsView.add(nav); jobsView.add(BeanContext.view(jobsView.newChildId(), job)); } hasJobsFrag.add(navsView); hasJobsFrag.add(jobsView); validFrag.add(hasJobsFrag); } else { validFrag.add(new Label("jobs", "No jobs defined").add(AttributeAppender.append("class", "not-defined"))); } if (!buildSpec.getProperties().isEmpty()) validFrag.add(PropertyContext.view("properties", buildSpec, "properties")); else validFrag.add(new Label("properties", "No properties defined").add(AttributeAppender.append("class", "not-defined"))); add(validFrag); } else { add(new Label("content", "Build spec not defined").add(AttributeAppender.append("class", "not-defined"))); } } catch (Exception e) { Fragment invalidFrag = new Fragment("content", "invalidFrag", this); invalidFrag.add(new MultilineLabel("errorMessage", Throwables.getStackTraceAsString(e))); add(invalidFrag); } add(selectBehavior = new AbstractPostAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = RequestCycle.get().getRequest().getPostParameters(); String selection = params.getParameterValue("selection").toString(); String position = BuildSpecRendererProvider.getPosition(selection); context.pushState(target, context.getBlobIdent(), position); } }); }
Example 19
Source File: FieldListEditPanel.java From onedev with MIT License | 4 votes |
private Component newFieldsView(Class<?> fieldBeanClass) { RepeatingView fieldsView = new RepeatingView("fields"); fieldsView.setDefaultModel(Model.of(fieldBeanClass.getName())); BeanDescriptor beanDescriptor = new BeanDescriptor(fieldBeanClass); for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) { for (PropertyDescriptor property: groupProperties) { if (getFieldSpecs().containsKey(property.getDisplayName())) { WebMarkupContainer container = new WebMarkupContainer(fieldsView.newChildId()); FieldSupply field = fields.get(property.getDisplayName()); if (field != null) { container.add(newValueEditor("value", property, field.getValueProvider())); container.setDefaultModel(Model.of(field.getValueProvider().getClass())); } else { container.add(newValueEditor("value", property, newSpecifiedValueProvider(property))); container.setDefaultModel(Model.of(SpecifiedValue.class)); } container.add(new Label("name", property.getDisplayName())); String required; if (property.isPropertyRequired() && property.getPropertyClass() != boolean.class && property.getPropertyClass() != Boolean.class) { required = "*"; } else { required = " "; } container.add(new Label("required", required).setEscapeModelStrings(false)); boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null; List<String> choices = new ArrayList<>(); if (isSecret) { choices.add(SpecifiedValue.SECRET_DISPLAY_NAME); choices.add(ScriptingValue.SECRET_DISPLAY_NAME); choices.add(Ignore.DISPLAY_NAME); } else { choices.add(SpecifiedValue.DISPLAY_NAME); choices.add(ScriptingValue.DISPLAY_NAME); choices.add(Ignore.DISPLAY_NAME); } DropDownChoice<String> valueProviderChoice = new DropDownChoice<String>("valueProvider", new IModel<String>() { @Override public void detach() { } @Override public String getObject() { Class<?> valueProviderClass = (Class<?>) container.getDefaultModelObject(); if (valueProviderClass == SpecifiedValue.class) return isSecret?SpecifiedValue.SECRET_DISPLAY_NAME:SpecifiedValue.DISPLAY_NAME; else if (valueProviderClass == ScriptingValue.class) return isSecret?ScriptingValue.SECRET_DISPLAY_NAME:ScriptingValue.DISPLAY_NAME; else return Ignore.DISPLAY_NAME; } @Override public void setObject(String object) { ValueProvider valueProvider; if (object.equals(SpecifiedValue.DISPLAY_NAME) || object.equals(SpecifiedValue.SECRET_DISPLAY_NAME)) valueProvider = newSpecifiedValueProvider(property); else if (object.equals(ScriptingValue.DISPLAY_NAME) || object.equals(ScriptingValue.SECRET_DISPLAY_NAME)) valueProvider = new ScriptingValue(); else valueProvider = new Ignore(); container.replace(newValueEditor("value", property, valueProvider)); container.setDefaultModelObject(valueProvider.getClass()); } }, choices); valueProviderChoice.setNullValid(false); valueProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){ @Override protected void onUpdate(AjaxRequestTarget target) { onPropertyUpdating(target); target.add(container); } }); container.add(valueProviderChoice); container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false)); container.add(new FencedFeedbackPanel("feedback", container)); container.setOutputMarkupId(true); fieldsView.add(container); } } } return fieldsView; }
Example 20
Source File: ParamListEditPanel.java From onedev with MIT License | 4 votes |
private Component newParamsView(Class<?> paramBeanClass) { RepeatingView paramsView = new RepeatingView("params"); paramsView.setDefaultModel(Model.of(paramBeanClass.getName())); BeanDescriptor beanDescriptor = new BeanDescriptor(paramBeanClass); for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) { for (PropertyDescriptor property: groupProperties) { WebMarkupContainer container = new WebMarkupContainer(paramsView.newChildId()); container.add(new Label("name", property.getDisplayName())); ParamSupply param = params.get(property.getDisplayName()); if (param != null) { container.add(newValuesEditor("values", property, param.getValuesProvider())); container.setDefaultModel(Model.of(param.getValuesProvider().getClass())); } else { container.add(newValuesEditor("values", property, newSpecifiedValuesProvider(property))); container.setDefaultModel(Model.of(SpecifiedValues.class)); } String required; if (property.isPropertyRequired() && property.getPropertyClass() != boolean.class && property.getPropertyClass() != Boolean.class) { required = "*"; } else { required = " "; } container.add(new Label("required", required).setEscapeModelStrings(false)); boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null; List<String> choices = new ArrayList<>(); if (isSecret) { choices.add(SpecifiedValues.SECRET_DISPLAY_NAME); choices.add(ScriptingValues.SECRET_DISPLAY_NAME); choices.add(Ignore.DISPLAY_NAME); } else { choices.add(SpecifiedValues.DISPLAY_NAME); choices.add(ScriptingValues.DISPLAY_NAME); choices.add(Ignore.DISPLAY_NAME); } DropDownChoice<String> valuesProviderChoice = new DropDownChoice<String>("valuesProvider", new IModel<String>() { @Override public void detach() { } @Override public String getObject() { Class<?> valuesProviderClass = (Class<?>) container.getDefaultModelObject(); if (valuesProviderClass == SpecifiedValues.class) return isSecret?SpecifiedValues.SECRET_DISPLAY_NAME:SpecifiedValues.DISPLAY_NAME; else if (valuesProviderClass == ScriptingValues.class) return isSecret?ScriptingValues.SECRET_DISPLAY_NAME:ScriptingValues.DISPLAY_NAME; else return Ignore.DISPLAY_NAME; } @Override public void setObject(String object) { ValuesProvider valuesProvider; if (object.equals(SpecifiedValues.DISPLAY_NAME) || object.equals(SpecifiedValues.SECRET_DISPLAY_NAME)) valuesProvider = newSpecifiedValuesProvider(property); else if (object.equals(ScriptingValues.DISPLAY_NAME) || object.equals(ScriptingValues.SECRET_DISPLAY_NAME)) valuesProvider = new ScriptingValues(); else valuesProvider = new Ignore(); container.replace(newValuesEditor("values", property, valuesProvider)); container.setDefaultModelObject(valuesProvider.getClass()); } }, choices); valuesProviderChoice.setNullValid(false); valuesProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){ @Override protected void onUpdate(AjaxRequestTarget target) { onPropertyUpdating(target); target.add(container); } }); container.add(valuesProviderChoice); container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false)); container.add(new FencedFeedbackPanel("feedback", container)); container.setOutputMarkupId(true); paramsView.add(container); } } return paramsView; }