List of usage examples for org.apache.wicket.model Model ofList
public static <C> IModel<List<C>> ofList(final List<C> list)
From source file:com.cubeia.backoffice.web.user.UserSummary.java
License:Open Source License
private ListView<Account> createAccountListView(AccountQueryResult accountResult) { log.debug("account result: {}", accountResult); List<Account> accounts = accountResult.getAccounts(); if (accounts == null) { accounts = new ArrayList<Account>(); }//w w w . j ava 2 s .com HashSet<Account> accountSet = new HashSet<Account>(accounts); List<Account> accountList = new ArrayList<Account>(accountSet); Collections.sort(accountList, Collections.reverseOrder(new Comparator<Account>() { @Override public int compare(Account a1, Account a2) { return a1.getType().name().compareTo(a2.getType().name()); } })); return new ListView<Account>("accounts", Model.ofList(accountList)) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void populateItem(ListItem<Account> item) { final Account account = item.getModelObject(); item.add(new LabelLinkPanel("accountId", "" + account.getId(), "View account " + account.getId(), AccountDetails.class, params(PARAM_ACCOUNT_ID, account.getId()))); item.add(new Label("name", new PropertyModel<String>(account, "information.name"))); item.add(new Label("currency", new PropertyModel<String>(account, "currencyCode"))); item.add(new Label("created", new DateDisplayModel(account, "created"))); item.add(new Label("type", new PropertyModel<String>(account, "type"))); item.add(new Label("balance", new Model<BigDecimal>() { public BigDecimal getObject() { BigDecimal amount; try { amount = walletService.getAccountBalance(account.getId()).getBalance().getAmount(); } catch (AccountNotFoundException e) { throw new RuntimeException(e); } return amount; }; })); item.add(new OddEvenRowsAttributeModifier(item.getIndex())); } }; }
From source file:com.cubeia.games.poker.admin.wicket.pages.user.UserSummary.java
License:Open Source License
private ListView<Account> createAccountListView(AccountQueryResult accountResult) { log.debug("account result: {}", accountResult); List<Account> accounts = accountResult.getAccounts(); if (accounts == null) { accounts = new ArrayList<Account>(); }//from w w w . ja v a 2 s . c o m HashSet<Account> accountSet = new HashSet<Account>(accounts); List<Account> accountList = new ArrayList<Account>(accountSet); Collections.sort(accountList, Collections.reverseOrder(new Comparator<Account>() { @Override public int compare(Account a1, Account a2) { return a1.getType().name().compareTo(a2.getType().name()); } })); return new ListView<Account>("accounts", Model.ofList(accountList)) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void populateItem(ListItem<Account> item) { final Account account = item.getModelObject(); item.add(new LabelLinkPanel("accountId", "" + account.getId(), "View account " + account.getId(), AccountDetails.class, params(AccountDetails.PARAM_ACCOUNT_ID, account.getId()))); item.add(new Label("name", new PropertyModel<String>(account, "information.name"))); item.add(new Label("currency", new PropertyModel<String>(account, "currencyCode"))); item.add(new Label("created", new DateDisplayModel(account, "created"))); item.add(new Label("type", new PropertyModel<String>(account, "type"))); item.add(new Label("balance", new Model<BigDecimal>() { public BigDecimal getObject() { BigDecimal amount; try { amount = walletService.getAccountBalance(account.getId()).getBalance().getAmount(); } catch (AccountNotFoundException e) { throw new RuntimeException(e); } return amount; }; })); item.add(new OddEvenRowsAttributeModifier(item.getIndex())); } }; }
From source file:com.customeric.panels.LeadActivities.java
public LeadActivities(String id, IModel<List<? extends Leads>> leadLists) { super(id, leadLists); if (leadLists == null) { leadLists = Model.ofList(DocamineServiceFactory.getLeadsJpaController().findLeadsEntities()); }/*ww w .j a v a 2 s . c o m*/ leadList = new ListView<Leads>("leadList", leadLists) { @Override protected void populateItem(ListItem<Leads> li) { li.add(new Label("leadId", li.getModelObject().getId() + "")); } }; add(leadList); }
From source file:com.evolveum.midpoint.web.component.assignment.AssignmentDataTablePanel.java
License:Apache License
private void addOrReplaceAssignmentsTable(WebMarkupContainer assignmentsContainer) { fillInRelationAssignmentsMap();//from www . j a v a 2s. c o m DropDownChoicePanel relation = WebComponentUtil.createEnumPanel(RelationTypes.class, ID_RELATION, WebComponentUtil.createReadonlyModelFromEnum(RelationTypes.class), relationModel, this, false); relation.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { relationModel.setObject((RelationTypes) relation.getBaseFormComponent().getConvertedInput()); addOrReplaceAssignmentsTable(getAssignmentsContainer()); target.add(AssignmentDataTablePanel.this.get(ID_ASSIGNMENTS).get(ID_ASSIGNMENTS_TABLE)); } }); relation.setOutputMarkupId(true); relation.setOutputMarkupPlaceholderTag(true); assignmentsContainer.addOrReplace(relation); AjaxButton showAllAssignmentsButton = new AjaxButton(ID_SHOW_ALL_ASSIGNMENTS_BUTTON, createStringResource("AssignmentTablePanel.menu.showAllAssignments")) { @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { showAllAssignments(ajaxRequestTarget); } }; assignmentsContainer.addOrReplace(showAllAssignmentsButton); ListDataProvider<AssignmentEditorDto> assignmentsProvider = new ListDataProvider<AssignmentEditorDto>(this, Model.ofList(relationAssignmentsMap.get(relationModel.getObject())), false) { private static final long serialVersionUID = 1L; @Override protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) { getAssignmentsStorage().setPaging(paging); } }; BoxedTablePanel<AssignmentEditorDto> assignmentTable = new BoxedTablePanel<AssignmentEditorDto>( ID_ASSIGNMENTS_TABLE, assignmentsProvider, initColumns(), UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE, (int) getPageBase().getItemsPerPage(UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE)) { private static final long serialVersionUID = 1L; // @Override // protected Item<AssignmentEditorDto> customizeNewRowItem(Item<AssignmentEditorDto> item, IModel<AssignmentEditorDto> model) { // item.add(AttributeModifier.append("class", AssignmentsUtil.createAssignmentStatusClassModel(model))); // return item; // } @Override public int getItemsPerPage() { return getPageBase().getSessionStorage().getUserProfile().getTables() .get(UserProfileStorage.TableId.ASSIGNMENTS_TAB_TABLE); } }; assignmentTable.setOutputMarkupId(true); assignmentTable.setCurrentPage(getAssignmentsStorage().getPaging()); assignmentsContainer.addOrReplace(assignmentTable); }
From source file:com.evolveum.midpoint.web.component.assignment.ConstructionDetailsPanelChainedModel.java
License:Apache License
private void initLayout() { CompoundPropertyModel constrModel = new CompoundPropertyModel(getModel()) { @Override//from w ww .j av a 2 s.co m public Object getObject() { Object o = super.getObject(); return o; } @Override public void setObject(Object o) { super.setObject(o); } }; Form<ConstructionType> form = new Form<ConstructionType>(ID_FORM, constrModel); form.setOutputMarkupId(true); DropDownChoice kindChoice = new DropDownChoice<>("kind", Model.ofList(Arrays.asList(ShadowKindType.values()))); kindChoice.setOutputMarkupId(true); kindChoice.add(new EmptyOnBlurAjaxFormUpdatingBehaviour() { @Override protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) { // ajaxRequestTarget.add(form); } }); // kindChoice.add(new AjaxEventBehavior("blur") { // @Override // protected void onEvent(AjaxRequestTarget ajaxRequestTarget) { // ajaxRequestTarget.add(form); // } // }); form.add(kindChoice); DropDownChoice intentDropdown = new DropDownChoice<>("intent", new IModel<List<String>>() { @Override public List<String> getObject() { List<String> availableIntentValues = new ArrayList<>(); try { if (resourceModel.getObject() == null) { return availableIntentValues; } RefinedResourceSchema refinedSchema = RefinedResourceSchema .getRefinedSchema(resourceModel.getObject()); if (refinedSchema != null) { ConstructionType m = (ConstructionType) constrModel.getObject(); ShadowKindType kind = m.getKind(); List<? extends RefinedObjectClassDefinition> definitions = refinedSchema .getRefinedDefinitions(kind); for (RefinedObjectClassDefinition def : definitions) { if (def.getIntent() != null) { availableIntentValues.add(def.getIntent()); } } } } catch (SchemaException ex) { LOGGER.error("Cannot get refined resource schema for resource {}. {}", resourceModel.getObject().getName().getOrig(), ex.getLocalizedMessage()); } return availableIntentValues; } @Override public void setObject(List<String> o) { // } @Override public void detach() { } }); intentDropdown.setOutputMarkupId(true); form.add(intentDropdown); add(form); // DropDownChoice kindDropDown = new DropDownChoice<ShadowKindType>(ID_KIND_FIELD, kindModel, Model.ofList(Arrays.asList(ShadowKindType.values()))){ // @Override // protected void onSelectionChanged(ShadowKindType newSelection) { // if (newSelection == null){ // ConstructionDetailsPanelChainedModel.this.getModelObject().setKind(null); // return; // } // if (newSelection instanceof ShadowKindType){ // ConstructionDetailsPanelChainedModel.this.getModelObject().setKind((ShadowKindType) newSelection); // } // } // }; // kindDropDown.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); // // kindDropDown.setOutputMarkupId(true); // add(kindDropDown); // // TextField intentDropDown = new TextField(ID_INTENT_FIELD, intentChoicesModel); // DropDownChoicePanel intentDropDown = new DropDownChoicePanel(ID_INTENT_FIELD, // PropertyModel.of(getModel(), ConstructionType.F_INTENT.getLocalPart()), intentChoicesModel); // intentDropDown.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); // intentDropDown.setOutputMarkupId(true); // add(intentDropDown); }
From source file:com.evolveum.midpoint.web.component.assignment.InducedEntitlementsPanel.java
License:Apache License
@Override protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initColumns() { List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>(); columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>( createStringResource("ConstructionType.kind")) { private static final long serialVersionUID = 1L; @Override/* w w w . j av a2s . c o m*/ public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId, final IModel<ContainerValueWrapper<AssignmentType>> rowModel) { item.add(new Label(componentId, getKindLabelModel(rowModel.getObject()))); } }); columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>( createStringResource("ConstructionType.intent")) { private static final long serialVersionUID = 1L; @Override public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId, final IModel<ContainerValueWrapper<AssignmentType>> rowModel) { item.add(new Label(componentId, getIntentLabelModel(rowModel.getObject()))); } }); columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>( createStringResource("ConstructionType.association")) { private static final long serialVersionUID = 1L; @Override public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId, final IModel<ContainerValueWrapper<AssignmentType>> rowModel) { String assocLabel = getAssociationLabel(rowModel.getObject()); //in case when association label contains "-" symbol, break-all words property will //wrap the label text incorrectly. In order to avoid this, we add additional style if (assocLabel != null && assocLabel.contains("-")) { item.add(AttributeModifier.append("style", "white-space: pre-line")); } item.add(new Label(componentId, Model.of(assocLabel))); } }); columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>( createStringResource("InducedEntitlements.value")) { private static final long serialVersionUID = 1L; @Override public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId, final IModel<ContainerValueWrapper<AssignmentType>> rowModel) { List<ShadowType> shadowsList = WebComponentUtil.loadReferencedObjectList( ExpressionUtil .getShadowRefValue(WebComponentUtil.getAssociationExpression(rowModel.getObject())), OPERATION_LOAD_SHADOW_OBJECT, InducedEntitlementsPanel.this.getPageBase()); MultiValueChoosePanel<ShadowType> valuesPanel = new MultiValueChoosePanel<ShadowType>(componentId, Model.ofList(shadowsList), Arrays.asList(ShadowType.class), false) { private static final long serialVersionUID = 1L; @Override protected ObjectFilter getCustomFilter() { ConstructionType construction = rowModel.getObject().getContainerValue().asContainerable() .getConstruction(); return WebComponentUtil.getShadowTypeFilterForAssociation(construction, OPERATION_LOAD_RESOURCE_OBJECT, InducedEntitlementsPanel.this.getPageBase()); } @Override protected void removePerformedHook(AjaxRequestTarget target, ShadowType shadow) { if (shadow != null && StringUtils.isNotEmpty(shadow.getOid())) { ExpressionType expression = WebComponentUtil .getAssociationExpression(rowModel.getObject()); ExpressionUtil.removeShadowRefEvaluatorValue(expression, shadow.getOid(), getPageBase().getPrismContext()); } } @Override protected void choosePerformedHook(AjaxRequestTarget target, List<ShadowType> selectedList) { ShadowType shadow = selectedList != null && selectedList.size() > 0 ? selectedList.get(0) : null; if (shadow != null && StringUtils.isNotEmpty(shadow.getOid())) { ExpressionType expression = WebComponentUtil .getAssociationExpression(rowModel.getObject(), true, getPrismContext()); ExpressionUtil.addShadowRefEvaluatorValue(expression, shadow.getOid(), InducedEntitlementsPanel.this.getPageBase().getPrismContext()); } } @Override protected void selectPerformed(AjaxRequestTarget target, List<ShadowType> chosenValues) { addPerformed(target, chosenValues); } }; valuesPanel.setOutputMarkupId(true); item.add(valuesPanel); } }); return columns; }
From source file:com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn.java
License:Apache License
private Component getPanel(String componentId, IModel<T> rowModel, int numberOfButtons, boolean isHeaderPanel) { List<InlineMenuItem> filteredMenuItems = new ArrayList<>(); for (InlineMenuItem menuItem : (rowModel != null && rowModel.getObject() instanceof InlineMenuable ? ((InlineMenuable) rowModel.getObject()).getMenuItems() : menuItems)) {//from w ww.ja v a 2 s. c om if (isHeaderPanel && !menuItem.isHeaderMenuItem()) { continue; } if (rowModel != null && menuItem.getAction() != null && menuItem.getAction() instanceof ColumnMenuAction) { ((ColumnMenuAction) menuItem.getAction()).setRowModel(rowModel); } filteredMenuItems.add(menuItem); } if (rowModel != null && rowModel.getObject() instanceof InlineMenuable && ((InlineMenuable) rowModel.getObject()) != null) { ((InlineMenuable) rowModel.getObject()).getMenuItems().clear(); ((InlineMenuable) rowModel.getObject()).getMenuItems().addAll(filteredMenuItems); } List<ButtonInlineMenuItem> buttonMenuItems = new ArrayList<>(); menuItems.forEach(menuItem -> { if (menuItem instanceof ButtonInlineMenuItem) { if (isHeaderPanel && !menuItem.isHeaderMenuItem()) { return; } buttonMenuItems.add((ButtonInlineMenuItem) menuItem); } }); return new MenuMultiButtonPanel<T>(componentId, rowModel, numberOfButtons, Model.ofList(filteredMenuItems)) { private static final long serialVersionUID = 1L; @Override protected AjaxIconButton createButton(int index, String componentId, IModel<T> model) { AjaxIconButton btn = buildDefaultButton(componentId, new Model<>(getButtonIconCss(index, buttonMenuItems)), new Model<>(getButtonTitle(index, buttonMenuItems)), new Model<>(getButtonCssClass()), target -> { setRowModelToButtonAction(rowModel, buttonMenuItems); buttonMenuItemClickPerformed(index, buttonMenuItems, target); }); btn.showTitleAsLabel(false); btn.add(new EnableBehaviour(() -> isButtonMenuItemEnabled(model))); return btn; } }; }
From source file:com.evolveum.midpoint.web.component.search.SearchPanel.java
License:Apache License
private void initLayout() { moreDialogModel = new LoadableModel<MoreDialogDto>(false) { @Override// ww w.jav a 2s . c o m protected MoreDialogDto load() { MoreDialogDto dto = new MoreDialogDto(); dto.setProperties(createPropertiesList()); return dto; } }; Form form = new Form(ID_FORM); add(form); ListView items = new ListView<SearchItem>(ID_ITEMS, new PropertyModel<List<SearchItem>>(getModel(), Search.F_ITEMS)) { @Override protected void populateItem(ListItem<SearchItem> item) { SearchItemPanel searchItem = new SearchItemPanel(ID_ITEM, item.getModel()); item.add(searchItem); } }; items.add(createAdvancedVisibleBehaviour(false)); form.add(items); WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP); moreGroup.add(createAdvancedVisibleBehaviour(false)); form.add(moreGroup); AjaxLink more = new AjaxLink(ID_MORE) { @Override public void onClick(AjaxRequestTarget target) { Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE)); Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER)); togglePopover(target, button, popover, 14); } }; more.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { Search search = getModelObject(); return !search.getAvailableDefinitions().isEmpty(); } }); more.setOutputMarkupId(true); moreGroup.add(more); WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER); searchContainer.setOutputMarkupId(true); form.add(searchContainer); AjaxSubmitButton searchSimple = new AjaxSubmitButton(ID_SEARCH_SIMPLE) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { searchPerformed(target); } }; searchSimple.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { Search search = getModelObject(); if (!search.isShowAdvanced()) { return true; } PrismContext ctx = getPageBase().getPrismContext(); return search.isAdvancedQueryValid(ctx); } @Override public boolean isVisible() { return !getModelObject().isShowAdvanced() || !queryPlagroundAccessible; } }); searchSimple.setOutputMarkupId(true); searchContainer.add(searchSimple); WebMarkupContainer searchDropdown = new WebMarkupContainer(ID_SEARCH_DROPDOWN); searchDropdown.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return getModelObject().isShowAdvanced() && queryPlagroundAccessible; } }); searchContainer.add(searchDropdown); AjaxSubmitButton searchButtonBeforeDropdown = new AjaxSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { searchPerformed(target); } }; searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { Search search = getModelObject(); if (!search.isShowAdvanced()) { return true; } PrismContext ctx = getPageBase().getPrismContext(); return search.isAdvancedQueryValid(ctx); } }); searchDropdown.add(searchButtonBeforeDropdown); List<InlineMenuItem> searchItems = new ArrayList<>(); InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.search"), new InlineMenuItemAction() { @Override public void onClick(AjaxRequestTarget target) { PrismContext ctx = getPageBase().getPrismContext(); if (getModelObject().isAdvancedQueryValid(ctx)) { searchPerformed(target); } } }); searchItems.add(searchItem); searchItem = new InlineMenuItem(createStringResource("SearchPanel.debug"), new InlineMenuItemAction() { @Override public void onClick(AjaxRequestTarget target) { debugPerformed(); } }); searchItems.add(searchItem); ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) { @Override protected void populateItem(ListItem<InlineMenuItem> item) { WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel()); menuItemBody.setRenderBodyOnly(true); item.add(menuItemBody); } }; searchDropdown.add(li); AjaxButton advanced = new AjaxButton(ID_ADVANCED, createAdvancedModel()) { @Override public void onClick(AjaxRequestTarget target) { advancedPerformed(target); } }; advanced.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return advancedSearch; } }); form.add(advanced); initPopover(); WebMarkupContainer advancedGroup = new WebMarkupContainer(ID_ADVANCED_GROUP); advancedGroup.add(createAdvancedVisibleBehaviour(true)); advancedGroup.add(AttributeAppender.append("class", createAdvancedGroupStyle())); advancedGroup.setOutputMarkupId(true); form.add(advancedGroup); Label advancedCheck = new Label(ID_ADVANCED_CHECK); advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle())); advancedGroup.add(advancedCheck); final TextArea advancedArea = new TextArea(ID_ADVANCED_AREA, new PropertyModel(getModel(), Search.F_ADVANCED_QUERY)); advancedArea.add(new AjaxFormComponentUpdatingBehavior("keyup") { @Override protected void onUpdate(AjaxRequestTarget target) { updateAdvancedArea(advancedArea, target); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setThrottlingSettings( new ThrottlingSettings(ID_ADVANCED_AREA, Duration.milliseconds(500), true)); } }); advancedGroup.add(advancedArea); Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR)); advancedError.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { Search search = getModelObject(); if (!search.isShowAdvanced()) { return false; } return StringUtils.isNotEmpty(search.getAdvancedError()); } }); advancedGroup.add(advancedError); }
From source file:com.evolveum.midpoint.web.page.admin.reports.component.AuditLogViewerPanel.java
License:Apache License
private void initParametersPanel(Form mainForm) { WebMarkupContainer parametersPanel = new WebMarkupContainer(ID_PARAMETERS_PANEL); parametersPanel.setOutputMarkupId(true); mainForm.add(parametersPanel);// w w w .jav a 2s . c o m DatePanel from = new DatePanel(ID_FROM, new PropertyModel<>(getModel(), AuditSearchDto.F_FROM)); DateValidator dateFromValidator = WebComponentUtil.getRangeValidator(mainForm, ItemPath.create(AuditSearchDto.F_FROM)); dateFromValidator.setMessageKey("AuditLogViewerPanel.dateValidatorMessage"); dateFromValidator.setDateFrom((DateTimeField) from.getBaseFormComponent()); for (FormComponent<?> formComponent : from.getFormComponents()) { formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); } from.setOutputMarkupId(true); parametersPanel.add(from); DatePanel to = new DatePanel(ID_TO, new PropertyModel<>(getModel(), AuditSearchDto.F_TO)); DateValidator dateToValidator = WebComponentUtil.getRangeValidator(mainForm, ItemPath.create(AuditSearchDto.F_FROM)); dateToValidator.setMessageKey("AuditLogViewerPanel.dateValidatorMessage"); dateToValidator.setDateTo((DateTimeField) to.getBaseFormComponent()); for (FormComponent<?> formComponent : to.getFormComponents()) { formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); } to.setOutputMarkupId(true); parametersPanel.add(to); ItemPathPanel changedItemPanel = new ItemPathPanel(ID_CHANGED_ITEM, new PropertyModel<>(getModel(), AuditSearchDto.F_CHANGED_ITEM)); changedItemPanel.setOutputMarkupId(true); parametersPanel.add(changedItemPanel); TextPanel<String> hostIdentifier = new TextPanel<>(ID_HOST_IDENTIFIER, new PropertyModel<>(getModel(), AuditSearchDto.F_HOST_IDENTIFIER)); hostIdentifier.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior()); hostIdentifier.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); hostIdentifier.setOutputMarkupId(true); parametersPanel.add(hostIdentifier); DropDownChoicePanel<AuditEventTypeType> eventType = new DropDownChoicePanel<>(ID_EVENT_TYPE, new PropertyModel<>(getModel(), AuditSearchDto.F_EVENT_TYPE), new ListModel<>(Arrays.asList(AuditEventTypeType.values())), new EnumChoiceRenderer<>(), true); eventType.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior()); eventType.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); eventType.setOutputMarkupId(true); parametersPanel.add(eventType); WebMarkupContainer eventStage = new WebMarkupContainer(ID_EVENT_STAGE); eventStage.setOutputMarkupId(true); eventStage.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return !isHistory; } }); parametersPanel.add(eventStage); ListModel<AuditEventStageType> eventStageListModel = new ListModel<>( Arrays.asList(AuditEventStageType.values())); PropertyModel<AuditEventStageType> eventStageModel = new PropertyModel<>(getModel(), AuditSearchDto.F_EVENT_STAGE); DropDownChoicePanel<AuditEventStageType> eventStageField = new DropDownChoicePanel<>(ID_EVENT_STAGE_FIELD, eventStageModel, eventStageListModel, new EnumChoiceRenderer<>(), true); eventStageField.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior()); eventStageField.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); eventStageField.setOutputMarkupId(true); eventStage.add(eventStageField); ListModel<OperationResultStatusType> outcomeListModel = new ListModel<>( Arrays.asList(OperationResultStatusType.values())); PropertyModel<OperationResultStatusType> outcomeModel = new PropertyModel<>(getModel(), AuditSearchDto.F_OUTCOME); DropDownChoicePanel<OperationResultStatusType> outcome = new DropDownChoicePanel<>(ID_OUTCOME, outcomeModel, outcomeListModel, new EnumChoiceRenderer<>(), true); outcome.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior()); outcome.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); outcome.setOutputMarkupId(true); parametersPanel.add(outcome); List<String> channelList = WebComponentUtil.getChannelList(); List<QName> channelQnameList = new ArrayList<>(); for (int i = 0; i < channelList.size(); i++) { String channel = channelList.get(i); if (channel != null) { QName channelQName = QNameUtil.uriToQName(channel); channelQnameList.add(channelQName); } } // ListModel<QName> channelListModel = new ListModel<>(channelQnameList); PropertyModel<Channel> channelModel = new PropertyModel<>(getModel(), AuditSearchDto.F_CHANNEL); DropDownChoicePanel<Channel> channel = new DropDownChoicePanel<>(ID_CHANNEL, channelModel, Model.ofList(Arrays.asList(Channel.values())), new EnumChoiceRenderer<>(), true); channel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior()); channel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); channel.setOutputMarkupId(true); parametersPanel.add(channel); List<Class<? extends ObjectType>> allowedClasses = new ArrayList<>(); allowedClasses.add(UserType.class); MultiValueChoosePanel<ObjectType> chooseInitiatorPanel = new SingleValueChoosePanel<>(ID_INITIATOR_NAME, allowedClasses, objectReferenceTransformer, new PropertyModel<>(getModel(), AuditSearchDto.F_INITIATOR_NAME)); parametersPanel.add(chooseInitiatorPanel); WebMarkupContainer targetOwnerName = new WebMarkupContainer(ID_TARGET_OWNER_NAME); targetOwnerName.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return !isHistory; } }); parametersPanel.add(targetOwnerName); MultiValueChoosePanel<ObjectType> chooseTargetOwnerPanel = new SingleValueChoosePanel<>( ID_TARGET_OWNER_NAME_FIELD, allowedClasses, objectReferenceTransformer, new PropertyModel<>(getModel(), AuditSearchDto.F_TARGET_OWNER_NAME)); targetOwnerName.add(chooseTargetOwnerPanel); WebMarkupContainer targetName = new WebMarkupContainer(ID_TARGET_NAME); targetName.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return !isHistory; } }); parametersPanel.add(targetName); List<Class<? extends ObjectType>> allowedClassesAll = new ArrayList<>(); allowedClassesAll.addAll(ObjectTypes.getAllObjectTypes()); MultiValueChoosePanel<ObjectType> chooseTargetPanel = new MultiValueChoosePanel<>(ID_TARGET_NAME_FIELD, new PropertyModel<>(getModel(), AuditSearchDto.F_TARGET_NAMES_OBJECTS), allowedClassesAll); chooseTargetPanel.setOutputMarkupId(true); targetName.add(chooseTargetPanel); AjaxSubmitButton searchButton = new AjaxSubmitButton(ID_SEARCH_BUTTON, createStringResource("BasicSearchPanel.search")) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { updateAuditSearchStorage(getModel().getObject()); searchUpdatePerformed(target); } @Override protected void onError(AjaxRequestTarget target) { target.add(getPageBase().getFeedbackPanel()); } }; searchButton.setOutputMarkupId(true); parametersPanel.add(searchButton); AjaxSubmitButton resetSearchButton = new AjaxSubmitButton(ID_RESET_SEARCH_BUTTON, createStringResource("AuditLogViewerPanel.resetSearchButton")) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { resetAuditSearchStorage(); searchUpdatePerformed(target); } @Override protected void onError(AjaxRequestTarget target) { target.add(getPageBase().getFeedbackPanel()); } }; resetSearchButton.setOutputMarkupId(true); parametersPanel.add(resetSearchButton); WebMarkupContainer valueRefTargetNameContainer = new WebMarkupContainer(ID_VALUE_REF_TARGET_NAMES); valueRefTargetNameContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !isHistory; } }); parametersPanel.add(valueRefTargetNameContainer); MultiValueChoosePanel<ObjectType> chooseValueRefTargetNamePanel = new MultiValueChoosePanel<>( ID_VALUE_REF_TARGET_NAMES_FIELD, new PropertyModel<>(getModel(), AuditSearchDto.F_VALUE_REF_TARGET_NAME), allowedClassesAll); chooseValueRefTargetNamePanel.setOutputMarkupId(true); valueRefTargetNameContainer.add(chooseValueRefTargetNamePanel); }
From source file:com.evolveum.midpoint.web.page.admin.roles.AbstractRoleMemberPanel.java
License:Apache License
private <V> DropDownFormGroup<V> createDropDown(String id, IModel<V> defaultModel, final List<V> values, IChoiceRenderer<V> renderer, String labelKey, String tooltipKey) { DropDownFormGroup<V> listSelect = new DropDownFormGroup<V>(id, defaultModel, Model.ofList(values), renderer, createStringResource(labelKey), tooltipKey, false, "col-md-4", "col-md-8", true); listSelect.getInput().add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override/*from w ww. j a v a 2s. co m*/ protected void onUpdate(AjaxRequestTarget target) { refreshAll(target); } }); listSelect.setOutputMarkupId(true); return listSelect; }