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.PlainSchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, final PlainSchemaTO schemaTO, final boolean createFlag) { final PlainSchemaTO schema = schemaTO == null ? new PlainSchemaTO() : schemaTO; final Form<PlainSchemaTO> schemaForm = new Form<>(FORM); schemaForm.setModel(new CompoundPropertyModel<>(schema)); schemaForm.setOutputMarkupId(true);//from w ww. j a v a 2s. c om final AjaxTextFieldPanel name = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(schema, "key")); name.addRequiredLabel(); name.setEnabled(createFlag); schemaForm.add(name); final AjaxDropDownChoicePanel<AttrSchemaType> type = new AjaxDropDownChoicePanel<>("type", getString("type"), new PropertyModel<AttrSchemaType>(schema, "type")); type.setChoices(Arrays.asList(AttrSchemaType.values())); type.addRequiredLabel(); schemaForm.add(type); // -- long, double, date final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern", getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern")); schemaForm.add(conversionPattern); final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams"); conversionParams.setOutputMarkupPlaceholderTag(true); conversionParams.add(conversionPattern); schemaForm.add(conversionParams); final WebMarkupContainer typeParams = new WebMarkupContainer("typeParams"); typeParams.setOutputMarkupPlaceholderTag(true); // -- enum final AjaxTextFieldPanel enumerationValuesPanel = new AjaxTextFieldPanel("panel", "enumerationValues", new Model<String>(null)); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationValues = new MultiFieldPanel<>("enumerationValues", new Model(), enumerationValuesPanel); enumerationValues.setModelObject(getEnumValuesAsList(schema.getEnumerationValues())); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationKeys = new MultiFieldPanel<>("enumerationKeys", new Model(), new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>(null))); enumerationKeys.setModelObject(getEnumValuesAsList(schema.getEnumerationKeys())); final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams"); enumParams.setOutputMarkupPlaceholderTag(true); enumParams.add(enumerationValues); enumParams.add(enumerationKeys); typeParams.add(enumParams); // -- encrypted final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey", getString("secretKey"), new PropertyModel<String>(schema, "secretKey")); final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<>( "cipherAlgorithm", getString("cipherAlgorithm"), new PropertyModel<CipherAlgorithm>(schema, "cipherAlgorithm")); cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values())); final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams"); encryptedParams.setOutputMarkupPlaceholderTag(true); encryptedParams.add(secretKey); encryptedParams.add(cipherAlgorithm); typeParams.add(encryptedParams); // -- binary final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType", getString("mimeType"), new PropertyModel<String>(schema, "mimeType")); mimeType.setChoices(mimeTypesInitializer.getMimeTypes()); final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams"); binaryParams.setOutputMarkupPlaceholderTag(true); binaryParams.add(mimeType); typeParams.add(binaryParams); schemaForm.add(typeParams); // -- show or hide showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { PlainSchemaModalPage.this.showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); target.add(typeParams); } }); final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return schemaRestClient.getAllValidatorClasses(); } }; final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<>("validatorClass", getString("validatorClass"), new PropertyModel<String>(schema, "validatorClass")); ((DropDownChoice) validatorClass.getField()).setNullValid(true); validatorClass.setChoices(validatorsList.getObject()); schemaForm.add(validatorClass); final AutoCompleteTextField<String> mandatoryCondition = new AutoCompleteTextField<String>( "mandatoryCondition") { private static final long serialVersionUID = -2428903969518079100L; @Override protected Iterator<String> getChoices(final String input) { List<String> choices = new ArrayList<String>(); if (Strings.isEmpty(input)) { choices = Collections.emptyList(); } else if ("true".startsWith(input.toLowerCase())) { choices.add("true"); } else if ("false".startsWith(input.toLowerCase())) { choices.add("false"); } return choices.iterator(); } }; mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); schemaForm.add(mandatoryCondition); final WebMarkupContainer pwdJexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> pwdQuestionMarkJexlHelp = JexlHelpUtils.getAjaxLink(pwdJexlHelp, "questionMarkJexlHelp"); schemaForm.add(pwdQuestionMarkJexlHelp); pwdQuestionMarkJexlHelp.add(pwdJexlHelp); final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"), new PropertyModel<Boolean>(schema, "multivalue")); schemaForm.add(multivalue); final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"), new PropertyModel<Boolean>(schema, "readonly")); schemaForm.add(readonly); final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint", getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint")); schemaForm.add(uniqueConstraint); 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) { final PlainSchemaTO schemaTO = (PlainSchemaTO) form.getDefaultModelObject(); schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject())); schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject())); if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) { error(getString("multivalueAndUniqueConstr.validation")); feedbackPanel.refresh(target); return; } try { if (createFlag) { schemaRestClient.createPlainSchema(kind, schemaTO); } else { schemaRestClient.updatePlainSchema(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); } }; schemaForm.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); schemaForm.add(cancel); String allowedRoles = createFlag ? xmlRolesReader.getEntitlement("Schema", "create") : xmlRolesReader.getEntitlement("Schema", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); add(schemaForm); }
From source file:org.apache.syncope.client.console.pages.PolicyModalPage.java
License:Apache License
public PolicyModalPage(final PageReference pageRef, final ModalWindow window, final T policyTO) { super();/*from ww w.j ava 2 s. c o m*/ final Form<?> form = new Form<>(FORM); form.setOutputMarkupId(true); add(form); final AjaxTextFieldPanel policyid = new AjaxTextFieldPanel("key", "key", new PropertyModel<String>(policyTO, "key")); policyid.setEnabled(false); policyid.setStyleSheet("ui-widget-content ui-corner-all short_fixedsize"); form.add(policyid); final AjaxTextFieldPanel description = new AjaxTextFieldPanel("description", "description", new PropertyModel<String>(policyTO, "description")); description.addRequiredLabel(); description.setStyleSheet("ui-widget-content ui-corner-all medium_dynamicsize"); form.add(description); final AjaxDropDownChoicePanel<PolicyType> type = new AjaxDropDownChoicePanel<>("type", "type", new PropertyModel<PolicyType>(policyTO, "type")); switch (policyTO.getType()) { case GLOBAL_ACCOUNT: case ACCOUNT: type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_ACCOUNT, PolicyType.ACCOUNT })); break; case GLOBAL_PASSWORD: case PASSWORD: type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_PASSWORD, PolicyType.PASSWORD })); break; case GLOBAL_SYNC: case SYNC: type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_SYNC, PolicyType.SYNC })); default: } type.setChoiceRenderer(new PolicyTypeRenderer()); type.addRequiredLabel(); form.add(type); // Authentication resources - only for AccountPolicyTO Fragment fragment; if (policyTO instanceof AccountPolicyTO) { fragment = new Fragment("forAccountOnly", "authResourcesFragment", form); final List<String> resourceNames = new ArrayList<>(); for (ResourceTO resource : resourceRestClient.getAll()) { resourceNames.add(resource.getKey()); } fragment.add(new AjaxPalettePanel<>("authResources", new PropertyModel<List<String>>(policyTO, "resources"), new ListModel<>(resourceNames))); } else { fragment = new Fragment("forAccountOnly", "emptyFragment", form); } form.add(fragment); // final PolicySpec policy = getPolicySpecification(policyTO); form.add(new PolicyBeanPanel("panel", policy)); final ModalWindow mwindow = new ModalWindow("metaEditModalWin"); mwindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); mwindow.setInitialHeight(WIN_HEIGHT); mwindow.setInitialWidth(WIN_WIDTH); mwindow.setCookieName("meta-edit-modal"); add(mwindow); List<IColumn<String, String>> resColumns = new ArrayList<>(); resColumns.add(new AbstractColumn<String, String>(new StringResourceModel("name", this, null, "")) { private static final long serialVersionUID = 2054811145491901166L; @Override public void populateItem(final Item<ICellPopulator<String>> cellItem, final String componentId, final IModel<String> rowModel) { cellItem.add(new Label(componentId, rowModel.getObject())); } }); resColumns.add(new AbstractColumn<String, String>(new StringResourceModel("actions", this, null, "")) { private static final long serialVersionUID = 2054811145491901166L; @Override public String getCssClass() { return "action"; } @Override public void populateItem(final Item<ICellPopulator<String>> cellItem, final String componentId, final IModel<String> model) { final String resource = model.getObject(); final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference()); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { mwindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ResourceModalPage(PolicyModalPage.this.getPageReference(), mwindow, resourceRestClient.read(resource), false); } }); mwindow.show(target); } }, ActionLink.ActionType.EDIT, "Resources"); cellItem.add(panel); } }); ISortableDataProvider<String, String> resDataProvider = new SortableDataProvider<String, String>() { private static final long serialVersionUID = 8263758912838836438L; @Override public Iterator<? extends String> iterator(final long first, final long count) { return policyTO.getKey() == 0 ? Collections.<String>emptyList().iterator() : policyRestClient.getPolicy(policyTO.getKey()).getUsedByResources() .subList((int) first, (int) first + (int) count).iterator(); } @Override public long size() { return policyTO.getKey() == 0 ? 0 : policyRestClient.getPolicy(policyTO.getKey()).getUsedByResources().size(); } @Override public IModel<String> model(final String object) { return new Model<>(object); } }; final AjaxFallbackDefaultDataTable<String, String> resources = new AjaxFallbackDefaultDataTable<>( "resources", resColumns, resDataProvider, 10); form.add(resources); List<IColumn<GroupTO, String>> groupColumns = new ArrayList<>(); groupColumns.add(new PropertyColumn<GroupTO, String>(new ResourceModel("key", "key"), "key", "key")); groupColumns.add(new PropertyColumn<GroupTO, String>(new ResourceModel("name", "name"), "name", "name")); groupColumns.add(new AbstractColumn<GroupTO, String>(new StringResourceModel("actions", this, null, "")) { private static final long serialVersionUID = 2054811145491901166L; @Override public String getCssClass() { return "action"; } @Override public void populateItem(final Item<ICellPopulator<GroupTO>> cellItem, final String componentId, final IModel<GroupTO> model) { final GroupTO group = model.getObject(); final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference()); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { mwindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new GroupModalPage(PolicyModalPage.this.getPageReference(), mwindow, group); } }); mwindow.show(target); } }, ActionLink.ActionType.EDIT, "Groups"); cellItem.add(panel); } }); ISortableDataProvider<GroupTO, String> groupDataProvider = new SortableDataProvider<GroupTO, String>() { private static final long serialVersionUID = 8263758912838836438L; @Override public Iterator<? extends GroupTO> iterator(final long first, final long count) { List<GroupTO> groups = new ArrayList<>(); if (policyTO.getKey() > 0) { for (Long groupId : policyRestClient.getPolicy(policyTO.getKey()).getUsedByGroups() .subList((int) first, (int) first + (int) count)) { groups.add(groupRestClient.read(groupId)); } } return groups.iterator(); } @Override public long size() { return policyTO.getKey() == 0 ? 0 : policyRestClient.getPolicy(policyTO.getKey()).getUsedByGroups().size(); } @Override public IModel<GroupTO> model(final GroupTO object) { return new Model<>(object); } }; final AjaxFallbackDefaultDataTable<GroupTO, String> groups = new AjaxFallbackDefaultDataTable<>("groups", groupColumns, groupDataProvider, 10); form.add(groups); mwindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487139L; @Override public void onClose(final AjaxRequestTarget target) { target.add(resources); target.add(groups); if (isModalResult()) { info(getString(Constants.OPERATION_SUCCEEDED)); feedbackPanel.refresh(target); setModalResult(false); } } }); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(APPLY)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { setPolicySpecification(policyTO, policy); try { if (policyTO.getKey() > 0) { policyRestClient.updatePolicy(policyTO); } else { policyRestClient.createPolicy(policyTO); } ((BasePage) pageRef.getPage()).setModalResult(true); window.close(target); } catch (Exception e) { LOG.error("While creating policy", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target); } }; form.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); } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { } }; cancel.setDefaultFormProcessing(false); form.add(cancel); }
From source file:org.apache.syncope.client.console.pages.ReportExecResultDownloadModalPage.java
License:Apache License
public ReportExecResultDownloadModalPage(final ModalWindow window, final PageReference callerPageRef) { final AjaxDropDownChoicePanel<ReportExecExportFormat> format = new AjaxDropDownChoicePanel<>("format", "format", new Model<ReportExecExportFormat>()); format.setChoices(Arrays.asList(ReportExecExportFormat.values())); format.setChoiceRenderer(new IChoiceRenderer<ReportExecExportFormat>() { private static final long serialVersionUID = -3941271550163141339L; @Override/*from w w w. java2 s . com*/ public Object getDisplayValue(final ReportExecExportFormat object) { return object.name(); } @Override public String getIdValue(final ReportExecExportFormat object, final int index) { return object.name(); } }); format.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { format.getField(); ((ReportModalPage) callerPageRef.getPage()).setExportFormat(format.getField().getModelObject()); window.close(target); } }); add(format); }
From source file:org.apache.syncope.client.console.pages.ReportletConfModalPage.java
License:Apache License
public ReportletConfModalPage(final AbstractReportletConf reportletConf, final ModalWindow window, final PageReference pageRef) { this.reportletConf = reportletConf; final Form form = new Form(FORM); add(form);/*from ww w .java 2 s.c o m*/ propertiesContainer = new WebMarkupContainer("container"); propertiesContainer.setOutputMarkupId(true); form.add(propertiesContainer); name = new AjaxTextFieldPanel("name", "name", this.reportletConf == null ? new Model<String>() : new PropertyModel<String>(this.reportletConf, "name")); name.setOutputMarkupId(true); name.addRequiredLabel(); form.add(name); final AjaxDropDownChoicePanel<String> reportletClass = new AjaxDropDownChoicePanel<String>("reportletClass", "reportletClass", new IModel<String>() { private static final long serialVersionUID = -2316468110411802130L; @Override public String getObject() { return ReportletConfModalPage.this.reportletConf == null ? null : ReportletConfModalPage.this.reportletConf.getClass().getName(); } @Override public void setObject(final String object) { try { Class<?> reportletClass = Class.forName(object); ReportletConfModalPage.this.reportletConf = (AbstractReportletConf) reportletClass .newInstance(); propertiesContainer.replace(buildPropView()); } catch (Exception e) { LOG.error("Cannot find or initialize {}", object, e); } } @Override public void detach() { } }); reportletClass.setStyleSheet("long_dynamicsize"); reportletClass.setChoices(reportRestClient.getReportletConfClasses()); ((DropDownChoice) reportletClass.getField()).setNullValid(true); reportletClass.addRequiredLabel(); reportletClass.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = 5538299138211283825L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice) reportletClass.getField()).setNullValid(false); target.add(reportletClass.getField()); target.add(propertiesContainer); } }); form.add(reportletClass); propertiesContainer.add(buildPropView()); final AjaxButton submit = new AjaxButton(APPLY, new ResourceModel(APPLY)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final BeanWrapper wrapper = PropertyAccessorFactory .forBeanPropertyAccess(ReportletConfModalPage.this.reportletConf); wrapper.setPropertyValue("name", name.getField().getInput()); // Iterate over properties in order to find UserSearchPanel instances and manually update // this.reportletConf with select search criteria - this is needed because UserSearchPanel // does not comply with usual Wicket model paradigm. ReportletConfModalPage.this.propView.visitChildren(new IVisitor<Component, Void>() { @Override public void component(final Component component, final IVisit<Void> ivisit) { if (component instanceof UserSearchPanel) { // using component.getDefaultModelObjectAsString() to fetch field name (set above) wrapper.setPropertyValue(component.getDefaultModelObjectAsString(), ((UserSearchPanel) component).buildFIQL()); } } }); ((ReportModalPage) pageRef.getPage()) .setModalReportletConf(ReportletConfModalPage.this.reportletConf); window.close(target); } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; form.add(submit); final AjaxButton cancel = new ClearIndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL), pageRef) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); form.add(cancel); }
From source file:org.apache.syncope.client.console.pages.ReportModalPage.java
License:Apache License
public ReportModalPage(final ModalWindow window, final ReportTO reportTO, final PageReference callerPageRef) { super();/* w w w . ja va2s. c o m*/ this.reportTO = reportTO; form = new Form<ReportTO>(FORM); form.setModel(new CompoundPropertyModel<ReportTO>(reportTO)); add(form); setupProfile(); setupExecutions(); final CrontabContainer crontab = new CrontabContainer("crontab", new PropertyModel<String>(reportTO, "cronExpression"), reportTO.getCronExpression()); form.add(crontab); final AjaxButton submit = new ClearIndicatingAjaxButton(APPLY, new ResourceModel(APPLY), getPageReference()) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { ReportTO toSubmit = (ReportTO) form.getModelObject(); toSubmit.setCronExpression( StringUtils.hasText(toSubmit.getCronExpression()) ? crontab.getCronExpression() : null); try { if (toSubmit.getKey() > 0) { reportRestClient.update(toSubmit); } else { reportRestClient.create(toSubmit); } ((BasePage) callerPageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { LOG.error("While creating or updating report", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; if (reportTO.getKey() > 0) { MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getEntitlement("Reports", "update")); } else { MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getEntitlement("Reports", "create")); } form.add(submit); final AjaxButton cancel = new ClearIndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL), getPageReference()) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); form.add(cancel); }
From source file:org.apache.syncope.client.console.pages.RequestPasswordResetModalPage.java
License:Apache License
public RequestPasswordResetModalPage(final ModalWindow window) { super();/*w w w . java 2 s . c om*/ setOutputMarkupId(true); final boolean handleSecurityQuestion = userSelfRestClient.isPwdResetRequiringSecurityQuestions(); final StatelessForm<?> form = new StatelessForm<Object>(FORM); form.setOutputMarkupId(true); final Label securityQuestionLabel = new Label("securityQuestionLabel", getString("securityQuestion")); securityQuestionLabel.setOutputMarkupPlaceholderTag(true); securityQuestionLabel.setVisible(handleSecurityQuestion); form.add(securityQuestionLabel); final AjaxTextFieldPanel securityQuestion = new AjaxTextFieldPanel("securityQuestion", "securityQuestion", new Model<String>()); securityQuestion.setReadOnly(true); securityQuestion.setRequired(true); securityQuestion.getField().setOutputMarkupId(true); securityQuestion.setOutputMarkupPlaceholderTag(true); securityQuestion.setVisible(handleSecurityQuestion); form.add(securityQuestion); final AjaxTextFieldPanel username = new AjaxTextFieldPanel("username", "username", new Model<String>()); username.setRequired(true); username.getField().setOutputMarkupId(true); if (handleSecurityQuestion) { username.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_BLUR) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { getFeedbackMessages().clear(); target.add(feedbackPanel); try { SecurityQuestionTO read = securityQuestionRestClient.readByUser(username.getModelObject()); securityQuestion.setModelObject(read.getContent()); } catch (Exception e) { LOG.error("While fetching security question for {}", username.getModelObject(), e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); securityQuestion.setModelObject(null); } finally { target.add(securityQuestion); } } }); } form.add(username); final Label securityAnswerLabel = new Label("securityAnswerLabel", getString("securityAnswer")); securityAnswerLabel.setOutputMarkupPlaceholderTag(true); securityAnswerLabel.setVisible(handleSecurityQuestion); form.add(securityAnswerLabel); final AjaxTextFieldPanel securityAnswer = new AjaxTextFieldPanel("securityAnswer", "securityAnswer", new Model<String>()); securityAnswer.setRequired(handleSecurityQuestion); securityAnswer.setOutputMarkupPlaceholderTag(true); securityAnswer.setVisible(handleSecurityQuestion); form.add(securityAnswer); 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.requestPasswordReset(username.getModelObject(), securityAnswer.getModelObject()); setResponsePage( new ResultStatusModalPage.Builder(window, new UserTO()).mode(Mode.SELF).build()); } catch (Exception e) { LOG.error("While requesting password reset for {}", username.getModelObject(), 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) { // do nothing } }; cancel.setDefaultFormProcessing(false); form.add(cancel); add(form); }
From source file:org.apache.syncope.client.console.pages.ResourceModalPage.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" }) public ResourceModalPage(final PageReference pageRef, final ModalWindow window, final ResourceTO resourceTO, final boolean createFlag) { super();//from ww w. j ava 2s. c o m this.add(new Label("new", StringUtils.isBlank(resourceTO.getKey()) ? new ResourceModel("new") : new Model(StringUtils.EMPTY))); this.add(new Label("name", StringUtils.isBlank(resourceTO.getKey()) ? StringUtils.EMPTY : resourceTO.getKey())); final Form<ResourceTO> form = new Form<>(FORM); form.setModel(new CompoundPropertyModel<>(resourceTO)); //-------------------------------- // Resource details panel //-------------------------------- form.add(new ResourceDetailsPanel("details", resourceTO, resourceRestClient.getPropagationActionsClasses(), createFlag)); form.add(new AnnotatedBeanPanel("systeminformation", resourceTO)); //-------------------------------- //-------------------------------- // Resource mapping panels //-------------------------------- form.add(new ResourceMappingPanel("umapping", resourceTO, AttributableType.USER)); form.add(new ResourceMappingPanel("gmapping", resourceTO, AttributableType.GROUP)); //-------------------------------- //-------------------------------- // Resource connector configuration panel //-------------------------------- ResourceConnConfPanel resourceConnConfPanel = new ResourceConnConfPanel("connconf", resourceTO, createFlag); MetaDataRoleAuthorizationStrategy.authorize(resourceConnConfPanel, ENABLE, xmlRolesReader.getEntitlement("Connectors", "read")); form.add(resourceConnConfPanel); //-------------------------------- //-------------------------------- // Resource security panel //-------------------------------- form.add(new ResourceSecurityPanel("security", resourceTO)); //-------------------------------- final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT, SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ResourceTO resourceTO = (ResourceTO) form.getDefaultModelObject(); boolean accountIdError = false; if (resourceTO.getUmapping() == null || resourceTO.getUmapping().getItems().isEmpty()) { resourceTO.setUmapping(null); } else { int uAccountIdCount = 0; for (MappingItemTO item : resourceTO.getUmapping().getItems()) { if (item.isAccountid()) { uAccountIdCount++; } } accountIdError = uAccountIdCount != 1; } if (resourceTO.getGmapping() == null || resourceTO.getGmapping().getItems().isEmpty()) { resourceTO.setGmapping(null); } else { int rAccountIdCount = 0; for (MappingItemTO item : resourceTO.getGmapping().getItems()) { if (item.isAccountid()) { rAccountIdCount++; } } accountIdError |= rAccountIdCount != 1; } if (accountIdError) { error(getString("accountIdValidation")); feedbackPanel.refresh(target); } else { try { if (createFlag) { resourceRestClient.create(resourceTO); } else { resourceRestClient.update(resourceTO); } if (pageRef != null && pageRef.getPage() instanceof AbstractBasePage) { ((AbstractBasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (Exception e) { LOG.error("Failure managing resource {}", resourceTO, 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); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, xmlRolesReader.getEntitlement("Resources", createFlag ? "create" : "update")); }
From source file:org.apache.syncope.client.console.pages.RoleSelectModalPage.java
License:Apache License
public RoleSelectModalPage(final PageReference pageRef, final ModalWindow window, final Class<?> payloadClass) { super();//w ww .j a v a 2 s . co m final ITreeProvider<DefaultMutableTreeNode> treeProvider = new TreeRoleProvider(roleTreeBuilder, 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 RoleTO roleTO = (RoleTO) treeNode.getUserObject(); return new Folder<DefaultMutableTreeNode>(id, RoleSelectModalPage.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<>(roleTO.getDisplayName()); } @Override protected void onClick(final AjaxRequestTarget target) { super.onClick(target); try { Constructor<?> constructor = payloadClass.getConstructor(Long.class); Object payload = constructor.newInstance(roleTO.getKey()); send(pageRef.getPage(), Broadcast.BREADTH, payload); } catch (Exception e) { LOG.error("Could not send role 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.SecurityQuestionModalPage.java
License:Apache License
public SecurityQuestionModalPage(final PageReference pageRef, final ModalWindow window, final SecurityQuestionTO securityQuestionTO, final boolean createFlag) { final Form<SecurityQuestionTO> form = new Form<SecurityQuestionTO>(FORM, new CompoundPropertyModel<SecurityQuestionTO>(securityQuestionTO)); final AjaxTextFieldPanel contentFieldPanel = new AjaxTextFieldPanel("content", "content", new PropertyModel<String>(securityQuestionTO, "content")); contentFieldPanel.setRequired(true); form.add(contentFieldPanel);//from w ww.j a v a 2s. com 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) { try { if (createFlag) { restClient.create(securityQuestionTO); } else { restClient.update(securityQuestionTO); } 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("SecurityQuestion", "create") : xmlRolesReader.getEntitlement("SecurityQuestion", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); form.add(submit); form.setDefaultButton(submit); form.add(cancel); add(form); }
From source file:org.apache.syncope.client.console.pages.StatusModalPage.java
License:Apache License
public StatusModalPage(final PageReference pageRef, final ModalWindow window, final AbstractSubjectTO subjectTO, final boolean statusOnly) { super();//from w w w . ja v a 2 s. c om this.pageRef = pageRef; this.window = window; this.statusOnly = statusOnly; this.subjectTO = subjectTO; statusUtils = new StatusUtils(subjectTO instanceof UserTO ? userRestClient : groupRestClient); add(new Label("displayName", subjectTO.getKey() + " " + (subjectTO instanceof UserTO ? ((UserTO) subjectTO).getUsername() : ((GroupTO) subjectTO).getName()))); columns = new ArrayList<>(); columns.add(new AbstractColumn<StatusBean, String>( new StringResourceModel("resourceName", this, null, "Resource name"), "resourceName") { private static final long serialVersionUID = 2054811145491901166L; @Override public void populateItem(final Item<ICellPopulator<StatusBean>> cellItem, final String componentId, final IModel<StatusBean> model) { cellItem.add(new Label(componentId, model.getObject().getResourceName()) { private static final long serialVersionUID = 8432079838783825801L; @Override protected void onComponentTag(final ComponentTag tag) { if (model.getObject().isLinked()) { super.onComponentTag(tag); } else { tag.put("style", "color: #DDDDDD"); } } }); } }); columns.add(new PropertyColumn<StatusBean, String>( new StringResourceModel("accountLink", this, null, "Account link"), "accountLink", "accountLink")); columns.add(new AbstractColumn<StatusBean, String>(new StringResourceModel("status", this, null, "")) { private static final long serialVersionUID = -3503023501954863131L; @Override public String getCssClass() { return "action"; } @Override public void populateItem(final Item<ICellPopulator<StatusBean>> cellItem, final String componentId, final IModel<StatusBean> model) { if (model.getObject().isLinked()) { cellItem.add(statusUtils.getStatusImagePanel(componentId, model.getObject().getStatus())); } else { cellItem.add(new Label(componentId, "")); } } }); table = new ActionDataTablePanel<StatusBean, String>("resourceDatatable", columns, (ISortableDataProvider<StatusBean, String>) new AttributableStatusProvider(), rowsPerPage, pageRef) { private static final long serialVersionUID = 6510391461033818316L; @Override public boolean isElementEnabled(final StatusBean element) { return !statusOnly || element.getStatus() != Status.OBJECT_NOT_FOUND; } }; table.setOutputMarkupId(true); final String pageId = subjectTO instanceof GroupTO ? "Groups" : "Users"; final Fragment pwdMgtFragment = new Fragment("pwdMgtFields", "pwdMgtFragment", this); addOrReplace(pwdMgtFragment); pwdMgt = new WebMarkupContainer("pwdMgt"); pwdMgtFragment.add(pwdMgt.setOutputMarkupId(true)); pwdMgtForm = new Form("pwdMgtForm"); pwdMgtForm.setVisible(false).setEnabled(false); pwdMgt.add(pwdMgtForm); password = new PasswordTextField("password", new Model<String>()); pwdMgtForm.add(password.setRequired(false).setEnabled(false)); confirm = new PasswordTextField("confirm", new Model<String>()); pwdMgtForm.add(confirm.setRequired(false).setEnabled(false)); changepwd = new AjaxCheckBoxPanel("changepwd", "changepwd", new Model<Boolean>(false)); pwdMgtForm.add(changepwd.setModelObject(false)); pwdMgtForm.add(new Label("changePwdLabel", new ResourceModel("changePwdLabel", "Password propagation"))); changepwd.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { password.setEnabled(changepwd.getModelObject()); confirm.setEnabled(changepwd.getModelObject()); target.add(pwdMgt); } }); cancel = new ClearIndicatingAjaxButton("cancel", new ResourceModel("cancel"), pageRef) { private static final long serialVersionUID = -2341391430136818026L; @Override protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { // ignore window.close(target); } }.feedbackPanelAutomaticReload(false); pwdMgtForm.add(cancel); final ClearIndicatingAjaxButton goon = new ClearIndicatingAjaxButton("continue", new ResourceModel("continue"), pageRef) { private static final long serialVersionUID = -2341391430136818027L; @Override protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { // none } }; pwdMgtForm.add(goon); if (statusOnly) { table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { userRestClient.reactivate(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); ((BasePage) pageRef.getPage()).setModalResult(true); window.close(target); } catch (Exception e) { LOG.error("Error enabling resources", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } }, ActionLink.ActionType.REACTIVATE, pageId); table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { userRestClient.suspend(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (Exception e) { LOG.error("Error disabling resources", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } }, ActionLink.ActionType.SUSPEND, pageId); } else { table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { if (subjectTO instanceof UserTO) { userRestClient.unlink(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } else { groupRestClient.unlink(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } ((BasePage) pageRef.getPage()).setModalResult(true); window.close(target); } catch (Exception e) { LOG.error("Error unlinking resources", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } }, ActionLink.ActionType.UNLINK, pageId); table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { if (subjectTO instanceof UserTO) { userRestClient.link(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } else { groupRestClient.link(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } ((BasePage) pageRef.getPage()).setModalResult(true); window.close(target); } catch (Exception e) { LOG.error("Error linking resources", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } }, ActionLink.ActionType.LINK, pageId); table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { BulkActionResult bulkActionResult; if (subjectTO instanceof UserTO) { bulkActionResult = userRestClient.deprovision(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } else { bulkActionResult = groupRestClient.deprovision(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } ((BasePage) pageRef.getPage()).setModalResult(true); loadBulkActionResultPage(table.getModelObject(), bulkActionResult); } catch (Exception e) { LOG.error("Error de-provisioning user", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } }, ActionLink.ActionType.DEPROVISION, pageId); table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { if (subjectTO instanceof UserTO) { StatusModalPage.this.passwordManagement(target, ResourceAssociationActionType.PROVISION, table.getModelObject()); } else { try { final BulkActionResult bulkActionResult = groupRestClient.provision( subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); ((BasePage) pageRef.getPage()).setModalResult(true); loadBulkActionResultPage(table.getModelObject(), bulkActionResult); } catch (Exception e) { LOG.error("Error provisioning user", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } } }.feedbackPanelAutomaticReload(!(subjectTO instanceof UserTO)), ActionLink.ActionType.PROVISION, pageId); table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { final BulkActionResult bulkActionResult; if (subjectTO instanceof UserTO) { bulkActionResult = userRestClient.unassign(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } else { bulkActionResult = groupRestClient.unassign(subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); } ((BasePage) pageRef.getPage()).setModalResult(true); loadBulkActionResultPage(table.getModelObject(), bulkActionResult); } catch (Exception e) { LOG.error("Error unassigning resources", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } }, ActionLink.ActionType.UNASSIGN, pageId); table.addAction(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { if (subjectTO instanceof UserTO) { StatusModalPage.this.passwordManagement(target, ResourceAssociationActionType.ASSIGN, table.getModelObject()); } else { try { final BulkActionResult bulkActionResult = groupRestClient.assign( subjectTO.getETagValue(), subjectTO.getKey(), new ArrayList<>(table.getModelObject())); ((BasePage) pageRef.getPage()).setModalResult(true); loadBulkActionResultPage(table.getModelObject(), bulkActionResult); } catch (Exception e) { LOG.error("Error assigning resources", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } } }.feedbackPanelAutomaticReload(!(subjectTO instanceof UserTO)), ActionLink.ActionType.ASSIGN, pageId); } table.addCancelButton(window); add(table); }