List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close
public void close(final IPartialPageRequestHandler target)
From source file:org.apache.syncope.client.console.pages.BulkActionResultModalPage.java
License:Apache License
public BulkActionResultModalPage(final ModalWindow window, final Collection<T> items, final List<IColumn<T, S>> columns, final BulkActionResult results, final String idFieldName) { super();//from ww w. ja va2 s . c o m final List<IColumn<T, S>> newColumnList = new ArrayList<>(columns.subList(1, columns.size() - 1)); newColumnList.add(newColumnList.size(), new ActionResultColumn<T, S>(results, idFieldName)); final SortableDataProvider<T, S> dataProvider = new SortableDataProvider<T, S>() { private static final long serialVersionUID = 5291903859908641954L; @Override public Iterator<? extends T> iterator(final long first, final long count) { return items.iterator(); } @Override public long size() { return items.size(); } @Override public IModel<T> model(final T object) { return new CompoundPropertyModel<T>(object); } }; add(new AjaxFallbackDefaultDataTable<T, S>("selectedObjects", newColumnList, dataProvider, Integer.MAX_VALUE).setVisible(items != null && !items.isEmpty())); final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { window.close(target); } }; add(close); }
From source file:org.apache.syncope.client.console.pages.CamelRouteModalPage.java
License:Apache License
public CamelRouteModalPage(final PageReference pageRef, final ModalWindow window, final CamelRouteTO routeTO, final boolean createFlag) { Form<CamelRouteTO> routeForm = new Form<>("routeDefForm"); final TextArea<String> routeDefArea = new TextArea<>("content", new PropertyModel<String>(routeTO, "content")); routeForm.add(routeDefArea);/*from w w w. j av a2 s. c om*/ routeForm.setModel(new CompoundPropertyModel<>(routeTO)); AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<>(getString(SUBMIT)), routeForm) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { try { restClient.update(routeTO.getKey(), ((CamelRouteTO) form.getModelObject()).getContent()); info(getString(Constants.OPERATION_SUCCEEDED)); // Uncomment with something similar once SYNCOPE-156 is completed // Configuration callerPage = (Configuration) pageRef.getPage(); // callerPage.setModalResult(true); window.close(target); } catch (SyncopeClientException scee) { error(getString(Constants.ERROR) + ": " + scee.getMessage()); } target.add(feedbackPanel); } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { target.add(feedbackPanel); } }; MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, Entitlement.ROUTE_UPDATE); routeForm.add(submit); this.add(routeForm); }
From source file:org.apache.syncope.client.console.pages.ConfirmPasswordResetModalPage.java
License:Apache License
public ConfirmPasswordResetModalPage(final ModalWindow window, final String token) { super();//from w w w . ja v a 2 s.c om setOutputMarkupId(true); final StatelessForm<?> form = new StatelessForm<Object>(FORM); form.setOutputMarkupId(true); final FieldPanel<String> password = new AjaxPasswordFieldPanel("password", "password", new Model<String>()) .setRequired(true); ((PasswordTextField) password.getField()).setResetPassword(true); form.add(password); final FieldPanel<String> confirmPassword = new AjaxPasswordFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); ((PasswordTextField) confirmPassword.getField()).setResetPassword(true); form.add(confirmPassword); form.add(new EqualPasswordInputValidator(password.getField(), confirmPassword.getField())); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT, SUBMIT)) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { try { userSelfRestClient.confirmPasswordReset(token, password.getModelObject()); setResponsePage( new ResultStatusModalPage.Builder(window, new UserTO()).mode(Mode.SELF).build()); } catch (Exception e) { LOG.error("While confirming password reset for {}", token, e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; form.add(submit); form.setDefaultButton(submit); final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { } }; cancel.setDefaultFormProcessing(false); form.add(cancel); add(form); }
From source file:org.apache.syncope.client.console.pages.ConfModalPage.java
License:Apache License
public ConfModalPage(final PageReference pageRef, final ModalWindow window, final WebMarkupContainer parameters) { super();// ww w. ja v a2 s . c om MetaDataRoleAuthorizationStrategy.authorize(parameters, ENABLE, xmlRolesReader.getEntitlement("Configuration", "list")); final ConfTO conf = confRestClient.list(); final Form<ConfTO> form = new Form<>("confForm"); form.setModel(new CompoundPropertyModel<>(conf)); form.add(new PlainAttrsPanel("paramAttrs", conf, form, Mode.ADMIN)); final AjaxButton submit = new IndicatingAjaxButton(SUBMIT, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ConfTO updatedConf = (ConfTO) form.getModelObject(); try { for (AttrTO attr : updatedConf.getPlainAttrs()) { attr.getValues().removeAll(Collections.singleton(null)); if (attr.getValues().isEmpty() || attr.getValues().equals(Collections.singletonList(StringUtils.EMPTY))) { confRestClient.delete(attr.getSchema()); } else { confRestClient.set(attr); } } if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (Exception e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, xmlRolesReader.getEntitlement("Configuration", "set")); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, xmlRolesReader.getEntitlement("Configuration", "delete")); form.add(submit); form.setDefaultButton(submit); final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); form.add(cancel); add(form); }
From source file:org.apache.syncope.client.console.pages.ConnectorModalPage.java
License:Apache License
public ConnectorModalPage(final PageReference pageRef, final ModalWindow window, final ConnInstanceTO connInstanceTO) { super();// w w w . ja v a 2s . c o m this.add(new Label("new", connInstanceTO.getKey() == 0 ? new ResourceModel("new") : new Model<>(StringUtils.EMPTY))); this.add(new Label("key", connInstanceTO.getKey() == 0 ? StringUtils.EMPTY : connInstanceTO.getKey())); // general data setup selectedCapabilities = new ArrayList<>( connInstanceTO.getKey() == 0 ? EnumSet.noneOf(ConnectorCapability.class) : connInstanceTO.getCapabilities()); mapConnBundleTOs = new HashMap<>(); for (ConnBundleTO connBundleTO : restClient.getAllBundles()) { // by location if (!mapConnBundleTOs.containsKey(connBundleTO.getLocation())) { mapConnBundleTOs.put(connBundleTO.getLocation(), new HashMap<String, Map<String, ConnBundleTO>>()); } final Map<String, Map<String, ConnBundleTO>> byLocation = mapConnBundleTOs .get(connBundleTO.getLocation()); // by name if (!byLocation.containsKey(connBundleTO.getBundleName())) { byLocation.put(connBundleTO.getBundleName(), new HashMap<String, ConnBundleTO>()); } final Map<String, ConnBundleTO> byName = byLocation.get(connBundleTO.getBundleName()); // by version if (!byName.containsKey(connBundleTO.getVersion())) { byName.put(connBundleTO.getVersion(), connBundleTO); } } bundleTO = getSelectedBundleTO(connInstanceTO); properties = fillProperties(bundleTO, connInstanceTO); // form - first tab final Form<ConnInstanceTO> connectorForm = new Form<>(FORM); connectorForm.setModel(new CompoundPropertyModel<>(connInstanceTO)); connectorForm.setOutputMarkupId(true); add(connectorForm); propertiesContainer = new WebMarkupContainer("container"); propertiesContainer.setOutputMarkupId(true); connectorForm.add(propertiesContainer); final Form<ConnInstanceTO> connectorPropForm = new Form<>("connectorPropForm"); connectorPropForm.setModel(new CompoundPropertyModel<>(connInstanceTO)); connectorPropForm.setOutputMarkupId(true); propertiesContainer.add(connectorPropForm); final AjaxTextFieldPanel displayName = new AjaxTextFieldPanel("displayName", "display name", new PropertyModel<String>(connInstanceTO, "displayName")); displayName.setOutputMarkupId(true); displayName.addRequiredLabel(); connectorForm.add(displayName); final AjaxDropDownChoicePanel<String> location = new AjaxDropDownChoicePanel<>("location", "location", new Model<>(bundleTO == null ? null : bundleTO.getLocation())); ((DropDownChoice<String>) location.getField()).setNullValid(true); location.setStyleSheet("long_dynamicsize"); location.setChoices(new ArrayList<>(mapConnBundleTOs.keySet())); location.setRequired(true); location.addRequiredLabel(); location.setOutputMarkupId(true); location.setEnabled(connInstanceTO.getKey() == 0); location.getField().setOutputMarkupId(true); connectorForm.add(location); final AjaxDropDownChoicePanel<String> connectorName = new AjaxDropDownChoicePanel<>("connectorName", "connectorName", new Model<>(bundleTO == null ? null : bundleTO.getBundleName())); ((DropDownChoice<String>) connectorName.getField()).setNullValid(true); connectorName.setStyleSheet("long_dynamicsize"); connectorName.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<>(mapConnBundleTOs.get(connInstanceTO.getLocation()).keySet())); connectorName.setRequired(true); connectorName.addRequiredLabel(); connectorName.setEnabled(connInstanceTO.getLocation() != null); connectorName.setOutputMarkupId(true); connectorName.setEnabled(connInstanceTO.getKey() == 0); connectorName.getField().setOutputMarkupId(true); connectorForm.add(connectorName); final AjaxDropDownChoicePanel<String> version = new AjaxDropDownChoicePanel<>("version", "version", new Model<>(bundleTO == null ? null : bundleTO.getVersion())); version.setStyleSheet("long_dynamicsize"); version.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<>(mapConnBundleTOs.get(connInstanceTO.getLocation()) .get(connInstanceTO.getBundleName()).keySet())); version.setRequired(true); version.addRequiredLabel(); version.setEnabled(connInstanceTO.getBundleName() != null); version.setOutputMarkupId(true); version.addRequiredLabel(); version.getField().setOutputMarkupId(true); connectorForm.add(version); final SpinnerFieldPanel<Integer> connRequestTimeout = new SpinnerFieldPanel<>("connRequestTimeout", "connRequestTimeout", Integer.class, new PropertyModel<Integer>(connInstanceTO, "connRequestTimeout"), 0, null); connRequestTimeout.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(connRequestTimeout); if (connInstanceTO.getPoolConf() == null) { connInstanceTO.setPoolConf(new ConnPoolConfTO()); } final SpinnerFieldPanel<Integer> poolMaxObjects = new SpinnerFieldPanel<>("poolMaxObjects", "poolMaxObjects", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxObjects"), 0, null); poolMaxObjects.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxObjects); final SpinnerFieldPanel<Integer> poolMinIdle = new SpinnerFieldPanel<>("poolMinIdle", "poolMinIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "minIdle"), 0, null); poolMinIdle.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(poolMinIdle); final SpinnerFieldPanel<Integer> poolMaxIdle = new SpinnerFieldPanel<>("poolMaxIdle", "poolMaxIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxIdle"), 0, null); poolMaxIdle.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxIdle); final SpinnerFieldPanel<Long> poolMaxWait = new SpinnerFieldPanel<>("poolMaxWait", "poolMaxWait", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "maxWait"), 0L, null); poolMaxWait.getField().add(new RangeValidator<>(0L, Long.MAX_VALUE)); connectorForm.add(poolMaxWait); final SpinnerFieldPanel<Long> poolMinEvictableIdleTime = new SpinnerFieldPanel<>("poolMinEvictableIdleTime", "poolMinEvictableIdleTime", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "minEvictableIdleTimeMillis"), 0L, null); poolMinEvictableIdleTime.getField().add(new RangeValidator<>(0L, Long.MAX_VALUE)); connectorForm.add(poolMinEvictableIdleTime); // form - first tab - onchange() location.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) location.getField()).setNullValid(false); connInstanceTO.setLocation(location.getModelObject()); target.add(location); connectorName.setChoices(new ArrayList<>(mapConnBundleTOs.get(location.getModelObject()).keySet())); connectorName.setEnabled(true); connectorName.getField().setModelValue(null); target.add(connectorName); version.setChoices(new ArrayList<String>()); version.getField().setModelValue(null); version.setEnabled(false); target.add(version); properties.clear(); target.add(propertiesContainer); } }); connectorName.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) connectorName.getField()).setNullValid(false); connInstanceTO.setBundleName(connectorName.getModelObject()); target.add(connectorName); List<String> versions = new ArrayList<>(mapConnBundleTOs.get(location.getModelObject()) .get(connectorName.getModelObject()).keySet()); version.setChoices(versions); version.setEnabled(true); if (versions.size() == 1) { selectVersion(target, connInstanceTO, version, versions.get(0)); version.getField().setModelObject(versions.get(0)); } else { version.getField().setModelValue(null); properties.clear(); target.add(propertiesContainer); } target.add(version); } }); version.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { selectVersion(target, connInstanceTO, version, version.getModelObject()); } }); // form - second tab (properties) final ListView<ConnConfProperty> connPropView = new ConnConfPropertyListView("connectorProperties", new PropertyModel<List<ConnConfProperty>>(this, "properties"), true, connInstanceTO.getConfiguration()); connPropView.setOutputMarkupId(true); connectorPropForm.add(connPropView); final AjaxButton check = new IndicatingAjaxButton("check", new ResourceModel("check")) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ConnInstanceTO conn = (ConnInstanceTO) form.getModelObject(); // ensure that connector bundle information is in sync conn.setBundleName(bundleTO.getBundleName()); conn.setVersion(bundleTO.getVersion()); conn.setConnectorName(bundleTO.getConnectorName()); if (restClient.check(conn)) { info(getString("success_connection")); } else { error(getString("error_connection")); } feedbackPanel.refresh(target); } }; connectorPropForm.add(check); // form - third tab (capabilities) final IModel<List<ConnectorCapability>> capabilities = new LoadableDetachableModel<List<ConnectorCapability>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<ConnectorCapability> load() { return Arrays.asList(ConnectorCapability.values()); } }; CheckBoxMultipleChoice<ConnectorCapability> capabilitiesPalette = new CheckBoxMultipleChoice<>( "capabilitiesPalette", new PropertyModel<List<ConnectorCapability>>(this, "selectedCapabilities"), capabilities); capabilitiesPalette.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); connectorForm.add(capabilitiesPalette); // form - submit / cancel buttons final AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<>(getString(SUBMIT))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ConnInstanceTO conn = (ConnInstanceTO) form.getModelObject(); conn.setConnectorName(bundleTO.getConnectorName()); conn.setBundleName(bundleTO.getBundleName()); conn.setVersion(bundleTO.getVersion()); conn.getConfiguration().clear(); conn.getConfiguration().addAll(connPropView.getModelObject()); // Set the model object's capabilities to capabilitiesPalette's converted Set conn.getCapabilities().clear(); conn.getCapabilities() .addAll(selectedCapabilities.isEmpty() ? EnumSet.noneOf(ConnectorCapability.class) : EnumSet.copyOf(selectedCapabilities)); // Reset pool configuration if all fields are null if (conn.getPoolConf() != null && conn.getPoolConf().getMaxIdle() == null && conn.getPoolConf().getMaxObjects() == null && conn.getPoolConf().getMaxWait() == null && conn.getPoolConf().getMinEvictableIdleTimeMillis() == null && conn.getPoolConf().getMinIdle() == null) { conn.setPoolConf(null); } try { if (connInstanceTO.getKey() == 0) { restClient.create(conn); } else { restClient.update(conn); } ((Resources) pageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); ((Resources) pageRef.getPage()).setModalResult(false); LOG.error("While creating or updating connector {}", conn, e); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; String roles = connInstanceTO.getKey() == 0 ? xmlRolesReader.getEntitlement("Connectors", "create") : xmlRolesReader.getEntitlement("Connectors", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, roles); connectorForm.add(submit); final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); connectorForm.add(cancel); }
From source file:org.apache.syncope.client.console.pages.DerSchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, DerSchemaTO schema, final boolean createFlag) { if (schema == null) { schema = new DerSchemaTO(); }//from w ww.j ava 2s . com final Form<DerSchemaTO> schemaForm = new Form<>(FORM); schemaForm.setModel(new CompoundPropertyModel<>(schema)); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(schema, "key")); name.addRequiredLabel(); final AjaxTextFieldPanel expression = new AjaxTextFieldPanel("expression", getString("expression"), new PropertyModel<String>(schema, "expression")); expression.addRequiredLabel(); final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); schemaForm.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); name.setEnabled(createFlag); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { DerSchemaTO schemaTO = (DerSchemaTO) form.getDefaultModelObject(); try { if (createFlag) { schemaRestClient.createDerSchema(kind, schemaTO); } else { schemaRestClient.updateDerSchema(kind, schemaTO); } if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); String allowedRoles = createFlag ? xmlRolesReader.getEntitlement("Schema", "create") : xmlRolesReader.getEntitlement("Schema", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); schemaForm.add(name); schemaForm.add(expression); schemaForm.add(submit); schemaForm.add(cancel); add(schemaForm); }
From source file:org.apache.syncope.client.console.pages.DisplayAttributesModalPage.java
License:Apache License
public DisplayAttributesModalPage(final PageReference pageRef, final ModalWindow window, final List<String> schemaNames, final List<String> dSchemaNames, final List<String> vSchemaNames) { super();//from w w w . j a va 2s . c om final IModel<List<String>> fnames = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return SearchableFields.get(UserTO.class); } }; final IModel<List<String>> names = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return schemaNames; } }; final IModel<List<String>> dsnames = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return dSchemaNames; } }; final IModel<List<String>> vsnames = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return vSchemaNames; } }; final Form form = new Form(FORM); form.setModel(new CompoundPropertyModel(this)); selectedDetails = prefMan.getList(getRequest(), Constants.PREF_USERS_DETAILS_VIEW); selectedPlainSchemas = prefMan.getList(getRequest(), Constants.PREF_USERS_ATTRIBUTES_VIEW); selectedDerSchemas = prefMan.getList(getRequest(), Constants.PREF_USERS_DERIVED_ATTRIBUTES_VIEW); selectedVirSchemas = prefMan.getList(getRequest(), Constants.PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW); final CheckGroup dgroup = new CheckGroup("dCheckGroup", new PropertyModel(this, "selectedDetails")); form.add(dgroup); final ListView<String> details = new ListView<String>("details", fnames) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(final ListItem<String> item) { item.add(new Check("dcheck", item.getModel())); item.add(new Label("dname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; dgroup.add(details); if (names.getObject() == null || names.getObject().isEmpty()) { final Fragment fragment = new Fragment("plainSchemas", "emptyFragment", form); form.add(fragment); selectedPlainSchemas.clear(); } else { final Fragment fragment = new Fragment("plainSchemas", "sfragment", form); form.add(fragment); final CheckGroup sgroup = new CheckGroup("psCheckGroup", new PropertyModel(this, "selectedPlainSchemas")); fragment.add(sgroup); final ListView<String> schemas = new ListView<String>("plainSchemas", names) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(final ListItem<String> item) { item.add(new Check("scheck", item.getModel())); item.add(new Label("sname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; sgroup.add(schemas); } if (dsnames.getObject() == null || dsnames.getObject().isEmpty()) { final Fragment fragment = new Fragment("dschemas", "emptyFragment", form); form.add(fragment); selectedDerSchemas.clear(); } else { final Fragment fragment = new Fragment("dschemas", "dsfragment", form); form.add(fragment); final CheckGroup dsgroup = new CheckGroup("dsCheckGroup", new PropertyModel(this, "selectedDerSchemas")); fragment.add(dsgroup); final ListView<String> derSchemas = new ListView<String>("derSchemas", dsnames) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(ListItem<String> item) { item.add(new Check("dscheck", item.getModel())); item.add(new Label("dsname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; dsgroup.add(derSchemas); } if (vsnames.getObject() == null || vsnames.getObject().isEmpty()) { final Fragment fragment = new Fragment("vschemas", "emptyFragment", form); form.add(fragment); selectedVirSchemas.clear(); } else { final Fragment fragment = new Fragment("vschemas", "vsfragment", form); form.add(fragment); final CheckGroup vsgroup = new CheckGroup("vsCheckGroup", new PropertyModel(this, "selectedVirSchemas")); fragment.add(vsgroup); final ListView<String> virSchemas = new ListView<String>("virSchemas", vsnames) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(ListItem<String> item) { item.add(new Check("vscheck", item.getModel())); item.add(new Label("vsname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; vsgroup.add(virSchemas); } final AjaxButton submit = new IndicatingAjaxButton(SUBMIT, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { if (selectedDetails.size() + selectedPlainSchemas.size() + selectedVirSchemas.size() + selectedDerSchemas.size() > MAX_SELECTIONS) { error(getString("tooManySelections")); onError(target, form); } else { final Map<String, List<String>> prefs = new HashMap<String, List<String>>(); prefs.put(Constants.PREF_USERS_DETAILS_VIEW, selectedDetails); prefs.put(Constants.PREF_USERS_ATTRIBUTES_VIEW, selectedPlainSchemas); prefs.put(Constants.PREF_USERS_DERIVED_ATTRIBUTES_VIEW, selectedDerSchemas); prefs.put(Constants.PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW, selectedVirSchemas); prefMan.setList(getRequest(), getResponse(), prefs); ((BasePage) pageRef.getPage()).setModalResult(true); window.close(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; form.add(submit); final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); form.add(cancel); add(form); }
From source file:org.apache.syncope.client.console.pages.GroupSelectModalPage.java
License:Apache License
public GroupSelectModalPage(final PageReference pageRef, final ModalWindow window, final Class<?> payloadClass) { super();/*w w w .jav a 2s .c o m*/ final ITreeProvider<DefaultMutableTreeNode> treeProvider = new TreeGroupProvider(groupTreeBuilder, true); final DefaultMutableTreeNodeExpansionModel treeModel = new DefaultMutableTreeNodeExpansionModel(); tree = new DefaultNestedTree<DefaultMutableTreeNode>("treeTable", treeProvider, treeModel) { private static final long serialVersionUID = 7137658050662575546L; @Override protected Component newContentComponent(final String id, final IModel<DefaultMutableTreeNode> node) { final DefaultMutableTreeNode treeNode = node.getObject(); final GroupTO groupTO = (GroupTO) treeNode.getUserObject(); return new Folder<DefaultMutableTreeNode>(id, GroupSelectModalPage.this.tree, node) { private static final long serialVersionUID = 9046323319920426493L; @Override protected boolean isClickable() { return true; } @Override protected IModel<?> newLabelModel(final IModel<DefaultMutableTreeNode> model) { return new Model<>(groupTO.getDisplayName()); } @Override protected void onClick(final AjaxRequestTarget target) { super.onClick(target); try { Constructor<?> constructor = payloadClass.getConstructor(Long.class); Object payload = constructor.newInstance(groupTO.getKey()); send(pageRef.getPage(), Broadcast.BREADTH, payload); } catch (Exception e) { LOG.error("Could not send group select event", e); } window.close(target); } }; } }; tree.add(new WindowsTheme()); tree.setOutputMarkupId(true); DefaultMutableTreeNodeExpansion.get().expandAll(); this.add(tree); }
From source file:org.apache.syncope.client.console.pages.MembershipModalPage.java
License:Apache License
public MembershipModalPage(final PageReference pageRef, final ModalWindow window, final MembershipTO membershipTO, final Mode mode) { final Form<MembershipTO> form = new Form<MembershipTO>("MembershipForm"); final UserTO userTO = ((UserModalPage) pageRef.getPage()).getUserTO(); form.setModel(new CompoundPropertyModel<MembershipTO>(membershipTO)); submit = new AjaxButton(SUBMIT, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override//from w w w.j av a 2s.com protected void onSubmit(final AjaxRequestTarget target, final Form form) { userTO.getMemberships().remove(membershipTO); userTO.getMemberships().add(membershipTO); ((UserModalPage) pageRef.getPage()).setUserTO(userTO); window.close(target); } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; form.add(submit); form.setDefaultButton(submit); final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { ((UserModalPage) pageRef.getPage()).setUserTO(userTO); window.close(target); } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { } }; cancel.setDefaultFormProcessing(false); form.add(cancel); //-------------------------------- // Attributes panel //-------------------------------- form.add(new PlainAttrsPanel("plainAttrs", membershipTO, form, mode)); form.add(new AnnotatedBeanPanel("systeminformation", membershipTO)); //-------------------------------- //-------------------------------- // Derived attributes container //-------------------------------- form.add(new DerAttrsPanel("derAttrs", membershipTO)); //-------------------------------- //-------------------------------- // Virtual attributes container //-------------------------------- form.add(new VirAttrsPanel("virAttrs", membershipTO, mode == Mode.TEMPLATE)); //-------------------------------- add(form); }
From source file:org.apache.syncope.client.console.pages.NotificationModalPage.java
License:Apache License
public NotificationModalPage(final PageReference pageRef, final ModalWindow window, final NotificationTO notificationTO, final boolean createFlag) { final Form<NotificationTO> form = new Form<NotificationTO>(FORM, new CompoundPropertyModel<NotificationTO>(notificationTO)); final AjaxTextFieldPanel sender = new AjaxTextFieldPanel("sender", getString("sender"), new PropertyModel<String>(notificationTO, "sender")); sender.addRequiredLabel();/*from ww w . j a v a2s.co m*/ sender.addValidator(EmailAddressValidator.getInstance()); form.add(sender); final AjaxTextFieldPanel subject = new AjaxTextFieldPanel("subject", getString("subject"), new PropertyModel<String>(notificationTO, "subject")); subject.addRequiredLabel(); form.add(subject); final AjaxDropDownChoicePanel<String> template = new AjaxDropDownChoicePanel<String>("template", getString("template"), new PropertyModel<String>(notificationTO, "template")); template.setChoices(confRestClient.getMailTemplates()); template.addRequiredLabel(); form.add(template); final AjaxDropDownChoicePanel<TraceLevel> traceLevel = new AjaxDropDownChoicePanel<TraceLevel>("traceLevel", getString("traceLevel"), new PropertyModel<TraceLevel>(notificationTO, "traceLevel")); traceLevel.setChoices(Arrays.asList(TraceLevel.values())); traceLevel.addRequiredLabel(); form.add(traceLevel); final AjaxCheckBoxPanel isActive = new AjaxCheckBoxPanel("isActive", getString("isActive"), new PropertyModel<Boolean>(notificationTO, "active")); if (createFlag) { isActive.getField().setDefaultModelObject(Boolean.TRUE); } form.add(isActive); final WebMarkupContainer aboutContainer = new WebMarkupContainer("aboutContainer"); aboutContainer.setOutputMarkupId(true); form.add(aboutContainer); final AjaxCheckBoxPanel checkAbout = new AjaxCheckBoxPanel("checkAbout", "checkAbout", new Model<Boolean>( notificationTO.getUserAbout() == null && notificationTO.getGroupAbout() == null)); aboutContainer.add(checkAbout); final AjaxCheckBoxPanel checkUserAbout = new AjaxCheckBoxPanel("checkUserAbout", "checkUserAbout", new Model<Boolean>(notificationTO.getUserAbout() != null)); aboutContainer.add(checkUserAbout); final AjaxCheckBoxPanel checkGroupAbout = new AjaxCheckBoxPanel("checkGroupAbout", "checkGroupAbout", new Model<Boolean>(notificationTO.getGroupAbout() != null)); aboutContainer.add(checkGroupAbout); final UserSearchPanel userAbout = new UserSearchPanel.Builder("userAbout") .fiql(notificationTO.getUserAbout()).build(); aboutContainer.add(userAbout); userAbout.setEnabled(checkUserAbout.getModelObject()); final GroupSearchPanel groupAbout = new GroupSearchPanel.Builder("groupAbout") .fiql(notificationTO.getGroupAbout()).build(); aboutContainer.add(groupAbout); groupAbout.setEnabled(checkGroupAbout.getModelObject()); checkAbout.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (checkAbout.getModelObject()) { checkUserAbout.setModelObject(Boolean.FALSE); checkGroupAbout.setModelObject(Boolean.FALSE); userAbout.setEnabled(Boolean.FALSE); groupAbout.setEnabled(Boolean.FALSE); } else { checkAbout.setModelObject(Boolean.TRUE); } target.add(aboutContainer); } }); checkUserAbout.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (checkUserAbout.getModelObject()) { checkAbout.setModelObject(!checkUserAbout.getModelObject()); checkGroupAbout.setModelObject(!checkUserAbout.getModelObject()); groupAbout.setEnabled(Boolean.FALSE); } else { checkUserAbout.setModelObject(Boolean.TRUE); } userAbout.setEnabled(Boolean.TRUE); target.add(aboutContainer); } }); checkGroupAbout.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (checkGroupAbout.getModelObject()) { checkAbout.setModelObject(Boolean.FALSE); checkUserAbout.setModelObject(Boolean.FALSE); userAbout.setEnabled(Boolean.FALSE); } else { checkGroupAbout.setModelObject(Boolean.TRUE); } groupAbout.setEnabled(Boolean.TRUE); target.add(aboutContainer); } }); final AjaxDropDownChoicePanel<IntMappingType> recipientAttrType = new AjaxDropDownChoicePanel<IntMappingType>( "recipientAttrType", new ResourceModel("recipientAttrType", "recipientAttrType").getObject(), new PropertyModel<IntMappingType>(notificationTO, "recipientAttrType")); recipientAttrType .setChoices(new ArrayList<IntMappingType>(IntMappingType.getAttributeTypes(AttributableType.USER, EnumSet.of(IntMappingType.UserId, IntMappingType.Password)))); recipientAttrType.addRequiredLabel(); form.add(recipientAttrType); final AjaxDropDownChoicePanel<String> recipientAttrName = new AjaxDropDownChoicePanel<String>( "recipientAttrName", new ResourceModel("recipientAttrName", "recipientAttrName").getObject(), new PropertyModel<String>(notificationTO, "recipientAttrName")); recipientAttrName.setChoices(getSchemaNames(recipientAttrType.getModelObject())); recipientAttrName.addRequiredLabel(); form.add(recipientAttrName); recipientAttrType.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { recipientAttrName.setChoices(getSchemaNames(recipientAttrType.getModelObject())); target.add(recipientAttrName); } }); form.add(new LoggerCategoryPanel("eventSelection", loggerRestClient.listEvents(), new PropertyModel<List<String>>(notificationTO, "events"), getPageReference(), "Notification") { private static final long serialVersionUID = 6429053774964787735L; @Override protected String[] getListRoles() { return new String[] {}; } @Override protected String[] getChangeRoles() { return new String[] {}; } }); final WebMarkupContainer recipientsContainer = new WebMarkupContainer("recipientsContainer"); recipientsContainer.setOutputMarkupId(true); form.add(recipientsContainer); final AjaxCheckBoxPanel checkStaticRecipients = new AjaxCheckBoxPanel("checkStaticRecipients", "recipients", new Model<Boolean>(!notificationTO.getStaticRecipients().isEmpty())); form.add(checkStaticRecipients); if (createFlag) { checkStaticRecipients.getField().setDefaultModelObject(Boolean.FALSE); } final AjaxTextFieldPanel staticRecipientsFieldPanel = new AjaxTextFieldPanel("panel", "staticRecipients", new Model<String>(null)); staticRecipientsFieldPanel.addValidator(EmailAddressValidator.getInstance()); staticRecipientsFieldPanel.setRequired(checkStaticRecipients.getModelObject()); if (notificationTO.getStaticRecipients().isEmpty()) { notificationTO.getStaticRecipients().add(null); } final MultiFieldPanel<String> staticRecipients = new MultiFieldPanel<String>("staticRecipients", new PropertyModel<List<String>>(notificationTO, "staticRecipients"), staticRecipientsFieldPanel); staticRecipients.setEnabled(checkStaticRecipients.getModelObject()); form.add(staticRecipients); final AjaxCheckBoxPanel checkRecipients = new AjaxCheckBoxPanel("checkRecipients", "checkRecipients", new Model<Boolean>(notificationTO.getRecipients() == null ? false : true)); recipientsContainer.add(checkRecipients); if (createFlag) { checkRecipients.getField().setDefaultModelObject(Boolean.TRUE); } final UserSearchPanel recipients = new UserSearchPanel.Builder("recipients") .fiql(notificationTO.getRecipients()).build(); recipients.setEnabled(checkRecipients.getModelObject()); recipientsContainer.add(recipients); final AjaxCheckBoxPanel selfAsRecipient = new AjaxCheckBoxPanel("selfAsRecipient", getString("selfAsRecipient"), new PropertyModel<Boolean>(notificationTO, "selfAsRecipient")); form.add(selfAsRecipient); if (createFlag) { selfAsRecipient.getField().setDefaultModelObject(Boolean.FALSE); } selfAsRecipient.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (!selfAsRecipient.getModelObject() && !checkRecipients.getModelObject() && !checkStaticRecipients.getModelObject()) { checkRecipients.getField().setDefaultModelObject(Boolean.TRUE); target.add(checkRecipients); recipients.setEnabled(checkRecipients.getModelObject()); target.add(recipients); target.add(recipientsContainer); } } }); checkRecipients.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (!checkRecipients.getModelObject() && !selfAsRecipient.getModelObject() && !checkStaticRecipients.getModelObject()) { checkStaticRecipients.getField().setDefaultModelObject(Boolean.TRUE); target.add(checkStaticRecipients); staticRecipients.setEnabled(Boolean.TRUE); target.add(staticRecipients); staticRecipientsFieldPanel.setRequired(Boolean.TRUE); target.add(staticRecipientsFieldPanel); } recipients.setEnabled(checkRecipients.getModelObject()); target.add(recipients); target.add(recipientsContainer); } }); checkStaticRecipients.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (!checkStaticRecipients.getModelObject() && !selfAsRecipient.getModelObject() && !checkRecipients.getModelObject()) { checkRecipients.getField().setDefaultModelObject(Boolean.TRUE); checkRecipients.setEnabled(Boolean.TRUE); target.add(checkRecipients); } staticRecipients.setEnabled(checkStaticRecipients.getModelObject()); staticRecipientsFieldPanel.setRequired(checkStaticRecipients.getModelObject()); recipients.setEnabled(checkRecipients.getModelObject()); target.add(staticRecipientsFieldPanel); target.add(staticRecipients); target.add(recipients); target.add(recipientsContainer); } }); AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { notificationTO.setUserAbout( !checkAbout.getModelObject() && checkUserAbout.getModelObject() ? userAbout.buildFIQL() : null); notificationTO.setGroupAbout( !checkAbout.getModelObject() && checkGroupAbout.getModelObject() ? groupAbout.buildFIQL() : null); notificationTO.setRecipients(checkRecipients.getModelObject() ? recipients.buildFIQL() : null); notificationTO.getStaticRecipients().removeAll(Collections.singleton(null)); try { if (createFlag) { restClient.create(notificationTO); } else { restClient.update(notificationTO); } info(getString(Constants.OPERATION_SUCCEEDED)); Configuration callerPage = (Configuration) pageRef.getPage(); callerPage.setModalResult(true); window.close(target); } catch (SyncopeClientException scee) { error(getString(Constants.ERROR) + ": " + scee.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); String allowedRoles = createFlag ? xmlRolesReader.getEntitlement("Notification", "create") : xmlRolesReader.getEntitlement("Notification", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); form.add(submit); form.setDefaultButton(submit); form.add(cancel); add(form); }