List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink setVisible
public final Component setVisible(final boolean visible)
From source file:org.apache.syncope.client.console.panels.PlainAttrsPanel.java
License:Apache License
public <T extends AbstractAttributableTO> PlainAttrsPanel(final String id, final T entityTO, final Form<?> form, final Mode mode, final AttrTemplatesPanel attrTemplates) { super(id);//from w w w. j a va 2s. c o m this.entityTO = entityTO; this.mode = mode; this.attrTemplates = attrTemplates; this.setOutputMarkupId(true); setSchemas(); setAttrs(); add(new AltListView<AttrTO>("schemas", new PropertyModel<List<? extends AttrTO>>(entityTO, "attrs")) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<AttrTO> item) { final AttrTO attributeTO = (AttrTO) item.getDefaultModelObject(); final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); item.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (mode != Mode.TEMPLATE) { questionMarkJexlHelp.setVisible(false); } item.add(new Label("name", attributeTO.getSchema())); final FieldPanel panel = getFieldPanel(schemas.get(attributeTO.getSchema()), form, attributeTO); if (mode == Mode.TEMPLATE || !schemas.get(attributeTO.getSchema()).isMultivalue()) { item.add(panel); } else { item.add(new MultiFieldPanel<String>("panel", new PropertyModel<List<String>>(attributeTO, "values"), panel)); } } }); }
From source file:org.apache.syncope.client.console.panels.ResourceDetailsPanel.java
License:Apache License
public ResourceDetailsPanel(final String id, final ResourceTO resourceTO, final List<String> actionClassNames, final boolean createFlag) { super(id);/*from www.j a v a2 s . co m*/ setOutputMarkupId(true); final AjaxTextFieldPanel resourceName = new AjaxTextFieldPanel("name", new ResourceModel("name", "name").getObject(), new PropertyModel<String>(resourceTO, "key")); resourceName.setEnabled(createFlag); resourceName.addRequiredLabel(); add(resourceName); final AjaxCheckBoxPanel enforceMandatoryCondition = new AjaxCheckBoxPanel("enforceMandatoryCondition", new ResourceModel("enforceMandatoryCondition", "enforceMandatoryCondition").getObject(), new PropertyModel<Boolean>(resourceTO, "enforceMandatoryCondition")); add(enforceMandatoryCondition); final AjaxCheckBoxPanel propagationPrimary = new AjaxCheckBoxPanel("propagationPrimary", new ResourceModel("propagationPrimary", "propagationPrimary").getObject(), new PropertyModel<Boolean>(resourceTO, "propagationPrimary")); add(propagationPrimary); final SpinnerFieldPanel<Integer> propagationPriority = new SpinnerFieldPanel<>("propagationPriority", "propagationPriority", Integer.class, new PropertyModel<Integer>(resourceTO, "propagationPriority"), null, null); add(propagationPriority); final AjaxDropDownChoicePanel<PropagationMode> propagationMode = new AjaxDropDownChoicePanel<>( "propagationMode", new ResourceModel("propagationMode", "propagationMode").getObject(), new PropertyModel<PropagationMode>(resourceTO, "propagationMode")); propagationMode.setChoices(Arrays.asList(PropagationMode.values())); add(propagationMode); final AjaxCheckBoxPanel randomPwdIfNotProvided = new AjaxCheckBoxPanel("randomPwdIfNotProvided", new ResourceModel("randomPwdIfNotProvided", "randomPwdIfNotProvided").getObject(), new PropertyModel<Boolean>(resourceTO, "randomPwdIfNotProvided")); add(randomPwdIfNotProvided); final WebMarkupContainer propagationActionsClassNames = new WebMarkupContainer( "propagationActionsClassNames"); propagationActionsClassNames.setOutputMarkupId(true); add(propagationActionsClassNames); final AjaxLink<Void> first = new IndicatingAjaxLink<Void>("first") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().add(StringUtils.EMPTY); setVisible(false); target.add(propagationActionsClassNames); } }; first.setOutputMarkupPlaceholderTag(true); first.setVisible(resourceTO.getPropagationActionsClassNames().isEmpty()); propagationActionsClassNames.add(first); final ListView<String> actionsClasses = new ListView<String>("actionsClasses", new PropertyModel<List<String>>(resourceTO, "propagationActionsClassNames")) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(final ListItem<String> item) { final String className = item.getModelObject(); final DropDownChoice<String> actionsClass = new DropDownChoice<>("actionsClass", new Model<>(className), actionClassNames); actionsClass.setNullValid(true); actionsClass.setRequired(true); actionsClass.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_BLUR) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().set(item.getIndex(), actionsClass.getModelObject()); } }); actionsClass.setRequired(true); actionsClass.setOutputMarkupId(true); actionsClass.setRequired(true); item.add(actionsClass); AjaxLink<Void> minus = new IndicatingAjaxLink<Void>("drop") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().remove(className); first.setVisible(resourceTO.getPropagationActionsClassNames().isEmpty()); target.add(propagationActionsClassNames); } }; item.add(minus); final AjaxLink<Void> plus = new IndicatingAjaxLink<Void>("add") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().add(StringUtils.EMPTY); target.add(propagationActionsClassNames); } }; plus.setOutputMarkupPlaceholderTag(true); plus.setVisible(item.getIndex() == resourceTO.getPropagationActionsClassNames().size() - 1); item.add(plus); } }; propagationActionsClassNames.add(actionsClasses); final AjaxDropDownChoicePanel<TraceLevel> createTraceLevel = new AjaxDropDownChoicePanel<>( "createTraceLevel", new ResourceModel("createTraceLevel", "createTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "createTraceLevel")); createTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(createTraceLevel); final AjaxDropDownChoicePanel<TraceLevel> updateTraceLevel = new AjaxDropDownChoicePanel<>( "updateTraceLevel", new ResourceModel("updateTraceLevel", "updateTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "updateTraceLevel")); updateTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(updateTraceLevel); final AjaxDropDownChoicePanel<TraceLevel> deleteTraceLevel = new AjaxDropDownChoicePanel<>( "deleteTraceLevel", new ResourceModel("deleteTraceLevel", "deleteTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "deleteTraceLevel")); deleteTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(deleteTraceLevel); final AjaxDropDownChoicePanel<TraceLevel> syncTraceLevel = new AjaxDropDownChoicePanel<>("syncTraceLevel", new ResourceModel("syncTraceLevel", "syncTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "syncTraceLevel")); syncTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(syncTraceLevel); final IModel<List<ConnInstanceTO>> connectors = new LoadableDetachableModel<List<ConnInstanceTO>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<ConnInstanceTO> load() { return connRestClient.getAllConnectors(); } }; connInstanceTO = getConectorInstanceTO(connectors.getObject(), resourceTO); final AjaxDropDownChoicePanel<ConnInstanceTO> conn = new AjaxDropDownChoicePanel<>("connector", new ResourceModel("connector", "connector").getObject(), new PropertyModel<ConnInstanceTO>(this, "connInstanceTO")); conn.setChoices(connectors.getObject()); conn.setChoiceRenderer(new ChoiceRenderer("displayName", "key")); conn.getField().setModel(new IModel<ConnInstanceTO>() { private static final long serialVersionUID = -4202872830392400310L; @Override public ConnInstanceTO getObject() { return connInstanceTO; } @Override public void setObject(final ConnInstanceTO connector) { resourceTO.setConnectorId(connector.getKey()); connInstanceTO = connector; } @Override public void detach() { } }); conn.addRequiredLabel(); conn.setEnabled(createFlag); conn.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new DetailsModEvent(target)); } }); add(conn); }
From source file:org.apache.syncope.client.console.panels.RoleDetailsPanel.java
License:Apache License
public RoleDetailsPanel(final String id, final RoleTO roleTO, final boolean templateMode) { super(id);/*w w w .ja va 2s . c o m*/ ownerContainer = new WebMarkupContainer("ownerContainer"); ownerContainer.setOutputMarkupId(true); this.add(ownerContainer); final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin"); userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal"); this.add(userOwnerSelectWin); final ModalWindow roleOwnerSelectWin = new ModalWindow("roleOwnerSelectWin"); roleOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); roleOwnerSelectWin.setCookieName("create-roleOwnerSelect-modal"); this.add(roleOwnerSelectWin); final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin"); parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); parentSelectWin.setCookieName("create-parentSelect-modal"); this.add(parentSelectWin); if (templateMode) { parentFragment = new Fragment("parent", "parentFragment", this); parentModel = new ParentModel(roleTO); @SuppressWarnings("unchecked") final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel); parent.setReadOnly(true); parent.setOutputMarkupId(true); parentFragment.add(parent); final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, ParentSelectPayload.class); } }); parentSelectWin.show(target); } }; parentFragment.add(parentSelect); final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentModel.setObject(null); target.add(parent); } }; parentFragment.add(parentReset); } else { parentFragment = new Fragment("parent", "emptyFragment", this); } parentFragment.setOutputMarkupId(true); this.add(parentFragment); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(roleTO, "key")); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); this.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { name.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } this.add(name); userOwnerModel = new OwnerModel(roleTO, AttributableType.USER); @SuppressWarnings("unchecked") final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel); userOwner.setReadOnly(true); userOwner.setOutputMarkupId(true); ownerContainer.add(userOwner); final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin); } }); userOwnerSelectWin.show(target); } }; ownerContainer.add(userOwnerSelect); final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerModel.setObject(null); target.add(userOwner); } }; ownerContainer.add(userOwnerReset); roleOwnerModel = new OwnerModel(roleTO, AttributableType.ROLE); @SuppressWarnings("unchecked") final AjaxTextFieldPanel roleOwner = new AjaxTextFieldPanel("roleOwner", "roleOwner", roleOwnerModel); roleOwner.setReadOnly(true); roleOwner.setOutputMarkupId(true); ownerContainer.add(roleOwner); final AjaxLink<Void> roleOwnerSelect = new IndicatingAjaxLink<Void>("roleOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, RoleOwnerSelectPayload.class); } }); parentSelectWin.show(target); } }; ownerContainer.add(roleOwnerSelect); final IndicatingAjaxLink<Void> roleOwnerReset = new IndicatingAjaxLink<Void>("roleOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { roleOwnerModel.setObject(null); target.add(roleOwner); } }; ownerContainer.add(roleOwnerReset); final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner", new PropertyModel<Boolean>(roleTO, "inheritOwner")); this.add(inhOwner); final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates", new PropertyModel<Boolean>(roleTO, "inheritTemplates")); inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rPlainAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rDerAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rVirAttrTemplates, target)); } }); this.add(inhTemplates); }
From source file:org.apache.syncope.client.console.panels.SearchView.java
License:Apache License
@Override protected void populateItem(final ListItem<SearchClause> item) { final SearchClause searchClause = item.getModelObject(); final DropDownChoice<SearchClause.Operator> operator = new DropDownChoice<SearchClause.Operator>("operator", new PropertyModel<SearchClause.Operator>(searchClause, "operator"), Arrays.asList(SearchClause.Operator.values())); operator.setOutputMarkupPlaceholderTag(true); operator.setNullValid(false);//from www.j av a 2 s .c o m operator.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(operator); if (item.getIndex() == 0) { operator.setVisible(false); } final DropDownChoice<SearchClause.Type> type = new DropDownChoice<SearchClause.Type>("type", new PropertyModel<SearchClause.Type>(searchClause, "type"), types); type.setOutputMarkupId(true); type.setRequired(required); type.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.add(searchFormContainer); } }); item.add(type); @SuppressWarnings("unchecked") final DropDownChoice<String> property = new DropDownChoice<String>("property", new PropertyModel<String>(searchClause, "property"), (IModel) null); property.setOutputMarkupId(true); property.setRequired(required); property.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(property); final TextField<String> value = new TextField<String>("value", new PropertyModel<String>(searchClause, "value")); value.setOutputMarkupId(true); value.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(value); final DropDownChoice<SearchClause.Comparator> comparator = new DropDownChoice<SearchClause.Comparator>( "comparator", new PropertyModel<SearchClause.Comparator>(searchClause, "comparator"), Collections.<SearchClause.Comparator>emptyList()); comparator.setOutputMarkupId(true); comparator.setNullValid(false); comparator.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (type.getModelObject() == SearchClause.Type.ATTRIBUTE) { if (comparator.getModelObject() == SearchClause.Comparator.IS_NULL || comparator.getModelObject() == SearchClause.Comparator.IS_NOT_NULL) { value.setModelObject(null); value.setEnabled(false); } else { value.setEnabled(true); } target.add(value); } } }); comparator.setRequired(required); item.add(comparator); AjaxLink<Void> drop = new IndicatingAjaxLink<Void>("drop") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { SearchView.this.getModel().getObject().remove(item.getModelObject()); target.add(searchFormContainer); } }; item.add(drop); if (item.getIndex() == 0) { drop.setVisible(false); drop.setEnabled(false); } else { drop.setVisible(true); drop.setEnabled(true); } final AjaxLink<Void> add = new IndicatingAjaxLink<Void>("add") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { SearchClause clause = new SearchClause(); SearchView.this.getModel().getObject().add(clause); target.add(searchFormContainer); } }; item.add(add); if (searchClause == null || searchClause.getType() == null) { property.setChoices(Collections.<String>emptyList()); } else { switch (searchClause.getType()) { case ATTRIBUTE: final List<String> names = new ArrayList<String>(dnames.getObject()); if (anames.getObject() != null && !anames.getObject().isEmpty()) { names.addAll(anames.getObject()); } Collections.sort(names); property.setChoices(names); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { return Arrays.asList(SearchClause.Comparator.values()); } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case IS_NULL: display = "NULL"; break; case IS_NOT_NULL: display = "NOT NULL"; break; case EQUALS: display = "=="; break; case NOT_EQUALS: display = "!="; break; case LESS_THAN: display = "<"; break; case LESS_OR_EQUALS: display = "<="; break; case GREATER_THAN: display = ">"; break; case GREATER_OR_EQUALS: display = ">="; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, int index) { return getDisplayValue(object).toString(); } }); if (!comparator.isEnabled()) { comparator.setEnabled(true); comparator.setRequired(true); } if (!value.isEnabled()) { value.setEnabled(true); } break; case MEMBERSHIP: property.setChoices(groupNames); property.setChoiceRenderer(new IChoiceRenderer<String>() { private static final long serialVersionUID = -4288397951948436434L; @Override public Object getDisplayValue(final String object) { return object; } @Override public String getIdValue(final String object, final int index) { return object; } }); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>(); comparators.add(SearchClause.Comparator.EQUALS); comparators.add(SearchClause.Comparator.NOT_EQUALS); return comparators; } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case EQUALS: display = "IN"; break; case NOT_EQUALS: display = "NOT IN"; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, final int index) { return getDisplayValue(object).toString(); } }); value.setEnabled(false); value.setModelObject(""); break; case RESOURCE: property.setChoices(resourceNames); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>(); comparators.add(SearchClause.Comparator.EQUALS); comparators.add(SearchClause.Comparator.NOT_EQUALS); return comparators; } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case EQUALS: display = "HAS"; break; case NOT_EQUALS: display = "HAS NOT"; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, final int index) { return getDisplayValue(object).toString(); } }); value.setEnabled(false); value.setModelObject(""); break; case ENTITLEMENT: property.setChoices(entitlements); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>(); comparators.add(SearchClause.Comparator.EQUALS); comparators.add(SearchClause.Comparator.NOT_EQUALS); return comparators; } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case EQUALS: display = "HAS"; break; case NOT_EQUALS: display = "HAS NOT"; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, final int index) { return getDisplayValue(object).toString(); } }); value.setEnabled(false); value.setModelObject(""); break; default: property.setChoices(Collections.<String>emptyList()); } } }
From source file:org.apache.syncope.client.console.panels.UserDetailsPanel.java
License:Apache License
public UserDetailsPanel(final String id, final UserTO userTO, final Form form, final boolean resetPassword, final boolean templateMode) { super(id);//w ww . j a v a 2s .com // ------------------------ // Username // ------------------------ final FieldPanel<String> username = new AjaxTextFieldPanel("username", "username", new PropertyModel<String>(userTO, "username")); final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("usernameJexlHelp"); final AjaxLink<?> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "usernameQuestionMarkJexlHelp"); add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { username.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } add(username); // ------------------------ // ------------------------ // Password // ------------------------ final WebMarkupContainer pwdJexlHelp = JexlHelpUtils.getJexlHelpWebContainer("pwdJexlHelp"); final AjaxLink<?> pwdQuestionMarkJexlHelp = JexlHelpUtils.getAjaxLink(pwdJexlHelp, "pwdQuestionMarkJexlHelp"); add(pwdQuestionMarkJexlHelp); pwdQuestionMarkJexlHelp.add(pwdJexlHelp); FieldPanel<String> password; Label confirmPasswordLabel = new Label("confirmPasswordLabel", new ResourceModel("confirmPassword")); FieldPanel<String> confirmPassword; if (templateMode) { password = new AjaxTextFieldPanel("password", "password", new PropertyModel<String>(userTO, "password")); confirmPasswordLabel.setVisible(false); confirmPassword = new AjaxTextFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); confirmPassword.setEnabled(false); confirmPassword.setVisible(false); } else { pwdQuestionMarkJexlHelp.setVisible(false); password = new AjaxPasswordFieldPanel("password", "password", new PropertyModel<String>(userTO, "password")); ((PasswordTextField) password.getField()).setResetPassword(resetPassword); confirmPassword = new AjaxPasswordFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); if (!resetPassword) { confirmPassword.getField().setModelObject(userTO.getPassword()); } ((PasswordTextField) confirmPassword.getField()).setResetPassword(resetPassword); form.add(new EqualPasswordInputValidator(password.getField(), confirmPassword.getField())); } add(password); add(confirmPasswordLabel); add(confirmPassword); final WebMarkupContainer mandatoryPassword = new WebMarkupContainer("mandatory_pwd"); mandatoryPassword.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { if (userTO.getKey() > 0) { tag.put("style", "display:none;"); } } }); add(mandatoryPassword); // ------------------------ }
From source file:org.apache.syncope.console.pages.AbstractSyncTaskModalPage.java
License:Apache License
public AbstractSyncTaskModalPage(final ModalWindow window, final AbstractSyncTaskTO taskTO, final PageReference pageRef) { super(window, taskTO, pageRef); final AjaxDropDownChoicePanel<String> resource = new AjaxDropDownChoicePanel<String>("resource", getString("resourceName"), new PropertyModel<String>(taskTO, "resource")); resource.setChoices(allResources.getObject()); resource.setChoiceRenderer(new SelectChoiceRenderer<String>()); resource.addRequiredLabel();/*w ww. ja v a2 s . c o m*/ resource.setEnabled(taskTO.getId() == 0); resource.setStyleSheet("ui-widget-content ui-corner-all long_dynamicsize"); profile.add(resource); final WebMarkupContainer syncActionsClassNames = new WebMarkupContainer("syncActionsClassNames"); syncActionsClassNames.setOutputMarkupId(true); profile.add(syncActionsClassNames); final AjaxLink<Void> first = new IndicatingAjaxLink<Void>("first") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { taskTO.getActionsClassNames().add(StringUtils.EMPTY); setVisible(false); target.add(syncActionsClassNames); } }; first.setOutputMarkupPlaceholderTag(true); first.setVisible(taskTO.getActionsClassNames().isEmpty()); syncActionsClassNames.add(first); final ListView<String> actionsClasses = new ListView<String>("actionsClasses", new PropertyModel<List<String>>(taskTO, "actionsClassNames")) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(final ListItem<String> item) { final String className = item.getModelObject(); final DropDownChoice<String> actionsClass = new DropDownChoice<String>("actionsClass", new Model<String>(className), syncActionsClasses.getObject()); actionsClass.setNullValid(true); actionsClass.setRequired(true); actionsClass.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { taskTO.getActionsClassNames().set(item.getIndex(), actionsClass.getModelObject()); target.add(syncActionsClassNames); } }); actionsClass.setRequired(true); actionsClass.setOutputMarkupId(true); actionsClass.setRequired(true); item.add(actionsClass); AjaxLink<Void> minus = new IndicatingAjaxLink<Void>("drop") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { taskTO.getActionsClassNames().remove(className); first.setVisible(taskTO.getActionsClassNames().isEmpty()); target.add(syncActionsClassNames); } }; item.add(minus); final AjaxLink<Void> plus = new IndicatingAjaxLink<Void>("add") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { taskTO.getActionsClassNames().add(StringUtils.EMPTY); target.add(syncActionsClassNames); } }; plus.setOutputMarkupPlaceholderTag(true); plus.setVisible(item.getIndex() == taskTO.getActionsClassNames().size() - 1); item.add(plus); } }; syncActionsClassNames.add(actionsClasses); syncActionsClassNames.setEnabled(!syncActionsClasses.getObject().isEmpty()); final AjaxCheckBoxPanel creates = new AjaxCheckBoxPanel("performCreate", getString("creates"), new PropertyModel<Boolean>(taskTO, "performCreate")); profile.add(creates); final AjaxCheckBoxPanel updates = new AjaxCheckBoxPanel("performUpdate", getString("updates"), new PropertyModel<Boolean>(taskTO, "performUpdate")); profile.add(updates); final AjaxCheckBoxPanel deletes = new AjaxCheckBoxPanel("performDelete", getString("updates"), new PropertyModel<Boolean>(taskTO, "performDelete")); profile.add(deletes); final AjaxCheckBoxPanel syncStatus = new AjaxCheckBoxPanel("syncStatus", getString("syncStatus"), new PropertyModel<Boolean>(taskTO, "syncStatus")); profile.add(syncStatus); matchingRule = new AjaxDropDownChoicePanel<MatchingRule>("matchingRule", "matchingRule", new PropertyModel<MatchingRule>(taskTO, "matchingRule")); matchingRule.setChoices(Arrays.asList(MatchingRule.values())); ((DropDownChoice) matchingRule.getField()).setNullValid(false); unmatchingRule = new AjaxDropDownChoicePanel<UnmatchingRule>("unmatchingRule", "unmatchingRule", new PropertyModel<UnmatchingRule>(taskTO, "unmatchingRule")); unmatchingRule.setChoices(Arrays.asList(UnmatchingRule.values())); ((DropDownChoice) unmatchingRule.getField()).setNullValid(false); }
From source file:org.apache.syncope.console.pages.panels.AttributesPanel.java
License:Apache License
public <T extends AbstractAttributableTO> AttributesPanel(final String id, final T entityTO, final Form form, final boolean templateMode, final AttrTemplatesPanel attrTemplates) { super(id);/*www. ja v a 2 s .c om*/ this.entityTO = entityTO; this.templateMode = templateMode; this.attrTemplates = attrTemplates; this.setOutputMarkupId(true); setSchemas(); setAttrs(); final ListView<AttributeTO> attributeView = new AltListView<AttributeTO>("schemas", new PropertyModel<List<? extends AttributeTO>>(entityTO, "attrs")) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<AttributeTO> item) { final AttributeTO attributeTO = (AttributeTO) item.getDefaultModelObject(); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); item.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { questionMarkJexlHelp.setVisible(false); } item.add(new Label("name", attributeTO.getSchema())); final FieldPanel panel = getFieldPanel(schemas.get(attributeTO.getSchema()), form, attributeTO); if (templateMode || !schemas.get(attributeTO.getSchema()).isMultivalue()) { item.add(panel); } else { item.add(new MultiFieldPanel<String>("panel", new PropertyModel<List<String>>(attributeTO, "values"), panel)); } } }; add(attributeView); }
From source file:org.apache.syncope.console.pages.panels.ResourceDetailsPanel.java
License:Apache License
public ResourceDetailsPanel(final String id, final ResourceTO resourceTO, final List<String> actionClassNames, final boolean createFlag) { super(id);/*from ww w . j av a 2 s .c o m*/ setOutputMarkupId(true); final AjaxTextFieldPanel resourceName = new AjaxTextFieldPanel("name", new ResourceModel("name", "name").getObject(), new PropertyModel<String>(resourceTO, "name")); resourceName.setEnabled(createFlag); resourceName.addRequiredLabel(); add(resourceName); final AjaxCheckBoxPanel enforceMandatoryCondition = new AjaxCheckBoxPanel("enforceMandatoryCondition", new ResourceModel("enforceMandatoryCondition", "enforceMandatoryCondition").getObject(), new PropertyModel<Boolean>(resourceTO, "enforceMandatoryCondition")); add(enforceMandatoryCondition); final AjaxCheckBoxPanel propagationPrimary = new AjaxCheckBoxPanel("propagationPrimary", new ResourceModel("propagationPrimary", "propagationPrimary").getObject(), new PropertyModel<Boolean>(resourceTO, "propagationPrimary")); add(propagationPrimary); final SpinnerFieldPanel<Integer> propagationPriority = new SpinnerFieldPanel<Integer>("propagationPriority", "propagationPriority", Integer.class, new PropertyModel<Integer>(resourceTO, "propagationPriority"), null, null); add(propagationPriority); final AjaxDropDownChoicePanel<PropagationMode> propagationMode = new AjaxDropDownChoicePanel<PropagationMode>( "propagationMode", new ResourceModel("propagationMode", "propagationMode").getObject(), new PropertyModel<PropagationMode>(resourceTO, "propagationMode")); propagationMode.setChoices(Arrays.asList(PropagationMode.values())); add(propagationMode); final AjaxCheckBoxPanel randomPwdIfNotProvided = new AjaxCheckBoxPanel("randomPwdIfNotProvided", new ResourceModel("randomPwdIfNotProvided", "randomPwdIfNotProvided").getObject(), new PropertyModel<Boolean>(resourceTO, "randomPwdIfNotProvided")); add(randomPwdIfNotProvided); final WebMarkupContainer propagationActionsClassNames = new WebMarkupContainer( "propagationActionsClassNames"); propagationActionsClassNames.setOutputMarkupId(true); add(propagationActionsClassNames); final AjaxLink<Void> first = new IndicatingAjaxLink<Void>("first") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().add(StringUtils.EMPTY); setVisible(false); target.add(propagationActionsClassNames); } }; first.setOutputMarkupPlaceholderTag(true); first.setVisible(resourceTO.getPropagationActionsClassNames().isEmpty()); propagationActionsClassNames.add(first); final ListView<String> actionsClasses = new ListView<String>("actionsClasses", new PropertyModel<List<String>>(resourceTO, "propagationActionsClassNames")) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(final ListItem<String> item) { final String className = item.getModelObject(); final DropDownChoice<String> actionsClass = new DropDownChoice<String>("actionsClass", new Model<String>(className), actionClassNames); actionsClass.setNullValid(true); actionsClass.setRequired(true); actionsClass.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_BLUR) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().set(item.getIndex(), actionsClass.getModelObject()); } }); actionsClass.setRequired(true); actionsClass.setOutputMarkupId(true); actionsClass.setRequired(true); item.add(actionsClass); AjaxLink<Void> minus = new IndicatingAjaxLink<Void>("drop") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().remove(className); first.setVisible(resourceTO.getPropagationActionsClassNames().isEmpty()); target.add(propagationActionsClassNames); } }; item.add(minus); final AjaxLink<Void> plus = new IndicatingAjaxLink<Void>("add") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { resourceTO.getPropagationActionsClassNames().add(StringUtils.EMPTY); target.add(propagationActionsClassNames); } }; plus.setOutputMarkupPlaceholderTag(true); plus.setVisible(item.getIndex() == resourceTO.getPropagationActionsClassNames().size() - 1); item.add(plus); } }; propagationActionsClassNames.add(actionsClasses); final AjaxDropDownChoicePanel<TraceLevel> createTraceLevel = new AjaxDropDownChoicePanel<TraceLevel>( "createTraceLevel", new ResourceModel("createTraceLevel", "createTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "createTraceLevel")); createTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(createTraceLevel); final AjaxDropDownChoicePanel<TraceLevel> updateTraceLevel = new AjaxDropDownChoicePanel<TraceLevel>( "updateTraceLevel", new ResourceModel("updateTraceLevel", "updateTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "updateTraceLevel")); updateTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(updateTraceLevel); final AjaxDropDownChoicePanel<TraceLevel> deleteTraceLevel = new AjaxDropDownChoicePanel<TraceLevel>( "deleteTraceLevel", new ResourceModel("deleteTraceLevel", "deleteTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "deleteTraceLevel")); deleteTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(deleteTraceLevel); final AjaxDropDownChoicePanel<TraceLevel> syncTraceLevel = new AjaxDropDownChoicePanel<TraceLevel>( "syncTraceLevel", new ResourceModel("syncTraceLevel", "syncTraceLevel").getObject(), new PropertyModel<TraceLevel>(resourceTO, "syncTraceLevel")); syncTraceLevel.setChoices(Arrays.asList(TraceLevel.values())); add(syncTraceLevel); final IModel<List<ConnInstanceTO>> connectors = new LoadableDetachableModel<List<ConnInstanceTO>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<ConnInstanceTO> load() { return connRestClient.getAllConnectors(); } }; connInstanceTO = getConectorInstanceTO(connectors.getObject(), resourceTO); final AjaxDropDownChoicePanel<ConnInstanceTO> conn = new AjaxDropDownChoicePanel<ConnInstanceTO>( "connector", new ResourceModel("connector", "connector").getObject(), new PropertyModel<ConnInstanceTO>(this, "connInstanceTO")); conn.setChoices(connectors.getObject()); conn.setChoiceRenderer(new ChoiceRenderer("displayName", "id")); conn.getField().setModel(new IModel<ConnInstanceTO>() { private static final long serialVersionUID = -4202872830392400310L; @Override public ConnInstanceTO getObject() { return connInstanceTO; } @Override public void setObject(final ConnInstanceTO connector) { resourceTO.setConnectorId(connector.getId()); connInstanceTO = connector; } @Override public void detach() { } }); conn.addRequiredLabel(); conn.setEnabled(createFlag); conn.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new DetailsModEvent(target)); } }); add(conn); }
From source file:org.apache.syncope.console.pages.panels.RoleDetailsPanel.java
License:Apache License
public RoleDetailsPanel(final String id, final RoleTO roleTO, final boolean templateMode) { super(id);//from w w w. j av a2s .co m ownerContainer = new WebMarkupContainer("ownerContainer"); ownerContainer.setOutputMarkupId(true); this.add(ownerContainer); final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin"); userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal"); this.add(userOwnerSelectWin); final ModalWindow roleOwnerSelectWin = new ModalWindow("roleOwnerSelectWin"); roleOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); roleOwnerSelectWin.setCookieName("create-roleOwnerSelect-modal"); this.add(roleOwnerSelectWin); final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin"); parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); parentSelectWin.setCookieName("create-parentSelect-modal"); this.add(parentSelectWin); if (templateMode) { parentFragment = new Fragment("parent", "parentFragment", this); parentModel = new ParentModel(roleTO); @SuppressWarnings("unchecked") final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel); parent.setReadOnly(true); parent.setOutputMarkupId(true); parentFragment.add(parent); final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, ParentSelectPayload.class); } }); parentSelectWin.show(target); } }; parentFragment.add(parentSelect); final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentModel.setObject(null); target.add(parent); } }; parentFragment.add(parentReset); } else { parentFragment = new Fragment("parent", "emptyFragment", this); } parentFragment.setOutputMarkupId(true); this.add(parentFragment); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(roleTO, "name")); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); this.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { name.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } this.add(name); userOwnerModel = new OwnerModel(roleTO, AttributableType.USER); @SuppressWarnings("unchecked") final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel); userOwner.setReadOnly(true); userOwner.setOutputMarkupId(true); ownerContainer.add(userOwner); final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin); } }); userOwnerSelectWin.show(target); } }; ownerContainer.add(userOwnerSelect); final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerModel.setObject(null); target.add(userOwner); } }; ownerContainer.add(userOwnerReset); roleOwnerModel = new OwnerModel(roleTO, AttributableType.ROLE); @SuppressWarnings("unchecked") final AjaxTextFieldPanel roleOwner = new AjaxTextFieldPanel("roleOwner", "roleOwner", roleOwnerModel); roleOwner.setReadOnly(true); roleOwner.setOutputMarkupId(true); ownerContainer.add(roleOwner); final AjaxLink<Void> roleOwnerSelect = new IndicatingAjaxLink<Void>("roleOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, RoleOwnerSelectPayload.class); } }); parentSelectWin.show(target); } }; ownerContainer.add(roleOwnerSelect); final IndicatingAjaxLink<Void> roleOwnerReset = new IndicatingAjaxLink<Void>("roleOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { roleOwnerModel.setObject(null); target.add(roleOwner); } }; ownerContainer.add(roleOwnerReset); final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner", new PropertyModel<Boolean>(roleTO, "inheritOwner")); this.add(inhOwner); final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates", new PropertyModel<Boolean>(roleTO, "inheritTemplates")); inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rDerAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rVirAttrTemplates, target)); } }); this.add(inhTemplates); }
From source file:org.apache.syncope.console.pages.panels.SearchView.java
License:Apache License
@Override protected void populateItem(final ListItem<SearchClause> item) { final SearchClause searchClause = item.getModelObject(); final DropDownChoice<SearchClause.Operator> operator = new DropDownChoice<SearchClause.Operator>("operator", new PropertyModel<SearchClause.Operator>(searchClause, "operator"), Arrays.asList(SearchClause.Operator.values())); operator.setOutputMarkupPlaceholderTag(true); operator.setNullValid(false);/* www .j a v a2 s. c o m*/ operator.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(operator); if (item.getIndex() == 0) { operator.setVisible(false); } final DropDownChoice<SearchClause.Type> type = new DropDownChoice<SearchClause.Type>("type", new PropertyModel<SearchClause.Type>(searchClause, "type"), types); type.setOutputMarkupId(true); type.setRequired(required); type.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.add(searchFormContainer); } }); item.add(type); @SuppressWarnings("unchecked") final DropDownChoice<String> property = new DropDownChoice<String>("property", new PropertyModel<String>(searchClause, "property"), (IModel) null); property.setOutputMarkupId(true); property.setRequired(required); property.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(property); final TextField<String> value = new TextField<String>("value", new PropertyModel<String>(searchClause, "value")); value.setOutputMarkupId(true); value.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(value); final DropDownChoice<SearchClause.Comparator> comparator = new DropDownChoice<SearchClause.Comparator>( "comparator", new PropertyModel<SearchClause.Comparator>(searchClause, "comparator"), Collections.<SearchClause.Comparator>emptyList()); comparator.setOutputMarkupId(true); comparator.setNullValid(false); comparator.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (type.getModelObject() == SearchClause.Type.ATTRIBUTE) { if (comparator.getModelObject() == SearchClause.Comparator.IS_NULL || comparator.getModelObject() == SearchClause.Comparator.IS_NOT_NULL) { value.setModelObject(null); value.setEnabled(false); } else { value.setEnabled(true); } target.add(value); } } }); comparator.setRequired(required); item.add(comparator); AjaxLink<Void> drop = new IndicatingAjaxLink<Void>("drop") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { SearchView.this.getModel().getObject().remove(item.getModelObject()); target.add(searchFormContainer); } }; item.add(drop); if (item.getIndex() == 0) { drop.setVisible(false); drop.setEnabled(false); } else { drop.setVisible(true); drop.setEnabled(true); } final AjaxLink<Void> add = new IndicatingAjaxLink<Void>("add") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { SearchClause clause = new SearchClause(); SearchView.this.getModel().getObject().add(clause); target.add(searchFormContainer); } }; item.add(add); if (searchClause == null || searchClause.getType() == null) { property.setChoices(Collections.<String>emptyList()); } else { switch (searchClause.getType()) { case ATTRIBUTE: final List<String> names = new ArrayList<String>(dnames.getObject()); if (anames.getObject() != null && !anames.getObject().isEmpty()) { names.addAll(anames.getObject()); } Collections.sort(names); property.setChoices(names); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { return Arrays.asList(SearchClause.Comparator.values()); } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case IS_NULL: display = "NULL"; break; case IS_NOT_NULL: display = "NOT NULL"; break; case EQUALS: display = "=="; break; case NOT_EQUALS: display = "!="; break; case LESS_THAN: display = "<"; break; case LESS_OR_EQUALS: display = "<="; break; case GREATER_THAN: display = ">"; break; case GREATER_OR_EQUALS: display = ">="; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, int index) { return getDisplayValue(object).toString(); } }); if (!comparator.isEnabled()) { comparator.setEnabled(true); comparator.setRequired(true); } if (!value.isEnabled()) { value.setEnabled(true); } break; case MEMBERSHIP: property.setChoices(roleNames); property.setChoiceRenderer(new IChoiceRenderer<String>() { private static final long serialVersionUID = -4288397951948436434L; @Override public Object getDisplayValue(final String object) { return object; } @Override public String getIdValue(final String object, final int index) { return object; } }); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>(); comparators.add(SearchClause.Comparator.EQUALS); comparators.add(SearchClause.Comparator.NOT_EQUALS); return comparators; } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case EQUALS: display = "IN"; break; case NOT_EQUALS: display = "NOT IN"; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, final int index) { return getDisplayValue(object).toString(); } }); value.setEnabled(false); value.setModelObject(""); break; case RESOURCE: property.setChoices(resourceNames); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>(); comparators.add(SearchClause.Comparator.EQUALS); comparators.add(SearchClause.Comparator.NOT_EQUALS); return comparators; } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case EQUALS: display = "HAS"; break; case NOT_EQUALS: display = "HAS NOT"; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, final int index) { return getDisplayValue(object).toString(); } }); value.setEnabled(false); value.setModelObject(""); break; case ENTITLEMENT: property.setChoices(entitlements); comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<SearchClause.Comparator> load() { List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>(); comparators.add(SearchClause.Comparator.EQUALS); comparators.add(SearchClause.Comparator.NOT_EQUALS); return comparators; } }); comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() { private static final long serialVersionUID = -9086043750227867686L; @Override public Object getDisplayValue(final SearchClause.Comparator object) { String display; switch (object) { case EQUALS: display = "HAS"; break; case NOT_EQUALS: display = "HAS NOT"; break; default: display = StringUtils.EMPTY; } return display; } @Override public String getIdValue(final SearchClause.Comparator object, final int index) { return getDisplayValue(object).toString(); } }); value.setEnabled(false); value.setModelObject(""); break; default: property.setChoices(Collections.<String>emptyList()); } } }