List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setInitialWidth
public ModalWindow setInitialWidth(final int initialWidth)
From source file:org.apache.directory.fortress.web.panel.UserListPanel.java
License:Apache License
private void addPermSearchModal(Radio permRb) { final ModalWindow permsModalWindow; userformsearchfields.add(permsModalWindow = new ModalWindow("permsearchmodal")); final PermSearchModalPanel permSearchModalPanel = new PermSearchModalPanel(permsModalWindow.getContentId(), permsModalWindow, false);//from w ww . j a v a 2 s.c o m permsModalWindow.setContent(permSearchModalPanel); permsModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { /** Default serialVersionUID */ private static final long serialVersionUID = 1L; @Override public void onClose(AjaxRequestTarget target) { Permission permSelection = permSearchModalPanel.getSelection(); if (permSelection != null) { searchData.setField1(permSelection.getObjName()); searchData.setField2(permSelection.getOpName()); } selectedRadioButton = PERMS; enablePermSearch(); target.add(searchFields); target.add(radioGroup); } }); permRb.add(new SecureIndicatingAjaxLink("permLinkLbl", GlobalIds.REVIEW_MGR, GlobalIds.FIND_PERMISSIONS) { /** Default serialVersionUID */ private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { String msg = "clicked on perms search"; msg += "permSelection: " + permission; String objectSearchVal = ""; if (StringUtils.isNotEmpty(searchData.getField1())) { objectSearchVal = searchData.getField1(); } permSearchModalPanel.setSearchVal(objectSearchVal); LOG.debug(msg); target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE); permsModalWindow.show(target); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AjaxCallListener ajaxCallListener = new AjaxCallListener() { /** Default serialVersionUID */ private static final long serialVersionUID = 1L; @Override public CharSequence getFailureHandler(Component component) { return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML; } }; attributes.getAjaxCallListeners().add(ajaxCallListener); } }); permsModalWindow.setTitle("Permission Search Modal"); permsModalWindow.setInitialWidth(650); permsModalWindow.setInitialHeight(450); permsModalWindow.setCookieName("perm-search-modal"); }
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 w w w . j a v a 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.ReportModalPage.java
License:Apache License
private void setupProfile() { final WebMarkupContainer profile = new WebMarkupContainer("profile"); profile.setOutputMarkupId(true);/*from www . j a va2 s.co m*/ form.add(profile); final ModalWindow reportletConfWin = new ModalWindow("reportletConfWin"); reportletConfWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); reportletConfWin.setCookieName("reportlet-conf-win-modal"); reportletConfWin.setInitialHeight(REPORTLET_CONF_WIN_HEIGHT); reportletConfWin.setInitialWidth(REPORTLET_CONF_WIN_WIDTH); reportletConfWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487139L; @Override public void onClose(final AjaxRequestTarget target) { int foundIdx = -1; if (modalReportletConfOldName != null) { for (int i = 0; i < reportTO.getReportletConfs().size() && foundIdx == -1; i++) { if (reportTO.getReportletConfs().get(i).getName().equals(modalReportletConfOldName)) { foundIdx = i; } } } if (modalReportletConf != null) { if (foundIdx == -1) { reportTO.getReportletConfs().add(modalReportletConf); } else { reportTO.getReportletConfs().set(foundIdx, modalReportletConf); } } target.add(reportlets); } }); add(reportletConfWin); final Label idLabel = new Label("idLabel", new ResourceModel("key")); profile.add(idLabel); final AjaxTextFieldPanel key = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(reportTO, "key")); key.setEnabled(false); profile.add(key); final Label nameLabel = new Label("nameLabel", new ResourceModel("name")); profile.add(nameLabel); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(reportTO, "name")); profile.add(name); final AjaxTextFieldPanel lastExec = new AjaxTextFieldPanel("lastExec", getString("lastExec"), new DateFormatROModel(new PropertyModel<String>(reportTO, "lastExec"))); lastExec.setEnabled(false); profile.add(lastExec); final AjaxTextFieldPanel nextExec = new AjaxTextFieldPanel("nextExec", getString("nextExec"), new DateFormatROModel(new PropertyModel<String>(reportTO, "nextExec"))); nextExec.setEnabled(false); profile.add(nextExec); reportlets = new ListChoice<AbstractReportletConf>("reportletConfs", new Model<AbstractReportletConf>(), reportTO.getReportletConfs(), new IChoiceRenderer<ReportletConf>() { private static final long serialVersionUID = 1048000918946220007L; @Override public Object getDisplayValue(final ReportletConf object) { return object.getName(); } @Override public String getIdValue(final ReportletConf object, final int index) { return object.getName(); } }) { private static final long serialVersionUID = 4022366881854379834L; @Override protected CharSequence getDefaultChoice(final String selectedValue) { return null; } }; reportlets.setNullValid(true); profile.add(reportlets); reportlets.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.add(reportlets); } }); profile.add(new AjaxLink<Void>(ADD_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { reportletConfWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { modalReportletConfOldName = null; modalReportletConf = null; return new ReportletConfModalPage(null, reportletConfWin, ReportModalPage.this.getPageReference()); } }); reportletConfWin.show(target); } }); profile.add(new AjaxLink<Void>(EDIT_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { reportletConfWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { modalReportletConfOldName = reportlets.getModelObject().getName(); modalReportletConf = null; return new ReportletConfModalPage(reportlets.getModelObject(), reportletConfWin, ReportModalPage.this.getPageReference()); } }); reportletConfWin.show(target); } } }); profile.add(new AjaxLink<Void>(REMOVE_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { reportTO.getReportletConfs().remove(reportlets.getModelObject()); reportlets.setModelObject(null); target.add(reportlets); } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { if (reportlets.getModelObject() != null) { super.updateAjaxAttributes(attributes); final AjaxCallListener ajaxCallListener = new AjaxCallListener() { private static final long serialVersionUID = 7160235486520935153L; @Override public CharSequence getPrecondition(final Component component) { return "if (!confirm('" + getString("confirmDelete") + "')) {return false;}"; } }; attributes.getAjaxCallListeners().add(ajaxCallListener); } } }); profile.add(new AjaxLink<Void>(UP_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { moveUp(reportlets.getModelObject()); target.add(reportlets); } } }); profile.add(new AjaxLink<Void>(DOWN_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { moveDown(reportlets.getModelObject()); target.add(reportlets); } } }); }
From source file:org.apache.syncope.client.console.pages.ReportModalPage.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" }) private void setupExecutions() { final WebMarkupContainer executions = new WebMarkupContainer("executionContainer"); executions.setOutputMarkupId(true);/*from www.ja v a2 s. co m*/ form.add(executions); final ModalWindow reportExecMessageWin = new ModalWindow("reportExecMessageWin"); reportExecMessageWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); reportExecMessageWin.setCookieName("report-exec-message-win-modal"); add(reportExecMessageWin); final ModalWindow reportExecExportWin = new ModalWindow("reportExecExportWin"); reportExecExportWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); reportExecExportWin.setCookieName("report-exec-export-win-modal"); reportExecExportWin.setInitialHeight(EXEC_EXPORT_WIN_HEIGHT); reportExecExportWin.setInitialWidth(EXEC_EXPORT_WIN_WIDTH); reportExecExportWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487139L; @Override public void onClose(final AjaxRequestTarget target) { AjaxExportDownloadBehavior behavior = new AjaxExportDownloadBehavior( ReportModalPage.this.exportFormat, ReportModalPage.this.exportExecId); executions.add(behavior); behavior.initiate(target); } }); add(reportExecExportWin); final List<IColumn> columns = new ArrayList<IColumn>(); columns.add(new PropertyColumn(new ResourceModel("key"), "key", "key")); columns.add(new DatePropertyColumn(new ResourceModel("startDate"), "startDate", "startDate")); columns.add(new DatePropertyColumn(new ResourceModel("endDate"), "endDate", "endDate")); columns.add(new PropertyColumn(new ResourceModel("status"), "status", "status")); columns.add(new ActionColumn<ReportExecTO, String>(new ResourceModel("actions", "")) { private static final long serialVersionUID = 2054811145491901166L; @Override public ActionLinksPanel getActions(final String componentId, final IModel<ReportExecTO> model) { final ReportExecTO taskExecutionTO = 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) { reportExecMessageWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ExecMessageModalPage(model.getObject().getMessage()); } }); reportExecMessageWin.show(target); } }, ActionLink.ActionType.EDIT, "Reports", StringUtils.hasText(model.getObject().getMessage())); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { reportExecExportWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { ReportModalPage.this.exportExecId = model.getObject().getKey(); return new ReportExecResultDownloadModalPage(reportExecExportWin, ReportModalPage.this.getPageReference()); } }); reportExecExportWin.show(target); } }, ActionLink.ActionType.EXPORT, "Reports", ReportExecStatus.SUCCESS.name().equals(model.getObject().getStatus())); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { reportRestClient.deleteExecution(taskExecutionTO.getKey()); reportTO.getExecutions().remove(taskExecutionTO); info(getString(Constants.OPERATION_SUCCEEDED)); } catch (SyncopeClientException scce) { error(scce.getMessage()); } feedbackPanel.refresh(target); target.add(executions); } }, ActionLink.ActionType.DELETE, "Reports"); return panel; } @Override public Component getHeader(final String componentId) { final ActionLinksPanel panel = new ActionLinksPanel(componentId, new Model(), getPageReference()); panel.add(new ActionLink() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (target != null) { final ReportTO currentReportTO = reportTO.getKey() == 0 ? reportTO : reportRestClient.read(reportTO.getKey()); reportTO.getExecutions().clear(); reportTO.getExecutions().addAll(currentReportTO.getExecutions()); final AjaxFallbackDefaultDataTable currentTable = new AjaxFallbackDefaultDataTable( "executionsTable", columns, new ReportExecutionsProvider(reportTO), 10); currentTable.setOutputMarkupId(true); target.add(currentTable); executions.addOrReplace(currentTable); } } }, ActionLink.ActionType.RELOAD, TASKS, "list"); return panel; } }); final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("executionsTable", columns, new ReportExecutionsProvider(reportTO), 10); executions.add(table); }
From source file:org.apache.syncope.client.console.pages.Users.java
License:Apache License
public Users(final PageParameters parameters) { super(parameters); // Modal window for editing user attributes final ModalWindow editModalWin = new ModalWindow("editModal"); editModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editModalWin.setInitialHeight(EDIT_MODAL_WIN_HEIGHT); editModalWin.setInitialWidth(EDIT_MODAL_WIN_WIDTH); editModalWin.setCookieName("edit-modal"); add(editModalWin);//from ww w. ja v a 2 s .c om final AbstractSearchResultPanel searchResult = new UserSearchResultPanel("searchResult", true, null, getPageReference(), restClient); add(searchResult); final AbstractSearchResultPanel listResult = new UserSearchResultPanel("listResult", false, null, getPageReference(), restClient); add(listResult); // create new user final AjaxLink<Void> createLink = new ClearIndicatingAjaxLink<Void>("createLink", getPageReference()) { private static final long serialVersionUID = -7978723352517770644L; @Override protected void onClickInternal(final AjaxRequestTarget target) { editModalWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new EditUserModalPage(Users.this.getPageReference(), editModalWin, new UserTO()); } }); editModalWin.show(target); } }; MetaDataRoleAuthorizationStrategy.authorize(createLink, ENABLE, xmlRolesReader.getEntitlement("Users", "create")); add(createLink); setWindowClosedReloadCallback(editModalWin); final Form<?> searchForm = new Form<>("searchForm"); add(searchForm); final UserSearchPanel searchPanel = new UserSearchPanel.Builder("searchPanel").build(); searchForm.add(searchPanel); final ClearIndicatingAjaxButton searchButton = new ClearIndicatingAjaxButton("search", new ResourceModel("search"), getPageReference()) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { final String fiql = searchPanel.buildFIQL(); LOG.debug("FIQL: " + fiql); doSearch(target, fiql, searchResult); Session.get().getFeedbackMessages().clear(); searchPanel.getSearchFeedback().refresh(target); } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { searchPanel.getSearchFeedback().refresh(target); } }; searchForm.add(searchButton); searchForm.setDefaultButton(searchButton); }
From source file:org.apache.syncope.client.console.panels.PoliciesPanel.java
License:Apache License
public PoliciesPanel(final String id, final PageReference pageRef, final PolicyType policyType) { super(id);/*from w w w . j av a2s. c o m*/ this.pageRef = pageRef; this.policyType = policyType; // Modal window for editing user attributes final ModalWindow mwindow = new ModalWindow("editModalWin"); mwindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); mwindow.setInitialHeight(MODAL_WIN_HEIGHT); mwindow.setInitialWidth(MODAL_WIN_WIDTH); mwindow.setCookieName("policy-modal"); add(mwindow); // Container for user list final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); setWindowClosedCallback(mwindow, container); final List<IColumn<AbstractPolicyTO, String>> columns = new ArrayList<>(); columns.add(new PropertyColumn<AbstractPolicyTO, String>(new ResourceModel("key"), "key", "key")); columns.add(new PropertyColumn<AbstractPolicyTO, String>(new ResourceModel("description"), "description", "description")); columns.add(new AbstractColumn<AbstractPolicyTO, String>(new ResourceModel("type")) { private static final long serialVersionUID = 8263694778917279290L; @Override public void populateItem(final Item<ICellPopulator<AbstractPolicyTO>> cellItem, final String componentId, final IModel<AbstractPolicyTO> model) { cellItem.add(new Label(componentId, getString(model.getObject().getType().name()))); } }); columns.add(new AbstractColumn<AbstractPolicyTO, String>(new ResourceModel("actions", "")) { private static final long serialVersionUID = 2054811145491901166L; @Override public String getCssClass() { return "action"; } @Override public void populateItem(final Item<ICellPopulator<AbstractPolicyTO>> cellItem, final String componentId, final IModel<AbstractPolicyTO> model) { final AbstractPolicyTO policyTO = model.getObject(); final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, pageRef); 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; @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Page createPage() { return new PolicyModalPage(pageRef, mwindow, policyTO); } }); mwindow.show(target); } }, ActionLink.ActionType.EDIT, "Policies"); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { policyRestClient.delete(policyTO.getKey(), policyTO.getClass()); info(getString(Constants.OPERATION_SUCCEEDED)); } catch (SyncopeClientException e) { error(getString(Constants.OPERATION_ERROR)); LOG.error("While deleting policy {}({})", policyTO.getKey(), policyTO.getDescription(), e); } target.add(container); ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target); } }, ActionLink.ActionType.DELETE, "Policies"); cellItem.add(panel); } }); @SuppressWarnings({ "unchecked", "rawtypes" }) final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("datatable", columns, new PolicyDataProvider(), paginatorRows); container.add(table); final AjaxLink<Void> createButton = new ClearIndicatingAjaxLink<Void>("createLink", pageRef) { private static final long serialVersionUID = -7978723352517770644L; @Override protected void onClickInternal(final AjaxRequestTarget target) { mwindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Page createPage() { return new PolicyModalPage(pageRef, mwindow, getPolicyTOInstance(policyType)); } }); mwindow.show(target); } }; add(createButton); MetaDataRoleAuthorizationStrategy.authorize(createButton, ENABLE, xmlRolesReader.getEntitlement("Policies", "create")); @SuppressWarnings("rawtypes") final Form paginatorForm = new Form("PaginatorForm"); @SuppressWarnings({ "unchecked", "rawtypes" }) final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"), prefMan.getPaginatorChoices()); rowsChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { prefMan.set(getWebRequest(), (WebResponse) getResponse(), Constants.PREF_POLICY_PAGINATOR_ROWS, String.valueOf(paginatorRows)); table.setItemsPerPage(paginatorRows); target.add(container); } }); paginatorForm.add(rowsChooser); add(paginatorForm); }
From source file:org.apache.syncope.client.console.SyncopeApplication.java
License:Apache License
public void setupNavigationPanel(final WebPage page, final XMLRolesReader xmlRolesReader, final boolean notsel) { final ModalWindow infoModal = new ModalWindow("infoModal"); page.add(infoModal);/*w ww. ja v a 2 s . c o m*/ infoModal.setInitialWidth(350); infoModal.setInitialHeight(300); infoModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY); infoModal.setCookieName("infoModal"); infoModal.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new InfoModalPage(); } }); final AjaxLink<Page> infoLink = new AjaxLink<Page>("infoLink") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { infoModal.show(target); } }; page.add(infoLink); BookmarkablePageLink<Page> schemaLink = new BookmarkablePageLink<>("schema", Schema.class); MetaDataRoleAuthorizationStrategy.authorize(schemaLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Schema", "list")); page.add(schemaLink); schemaLink.add(new Image("schemaIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "schema" + Constants.PNG_EXT))); BookmarkablePageLink<Page> usersLink = new BookmarkablePageLink<>("users", Users.class); MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Users", "list")); page.add(usersLink); usersLink.add(new Image("usersIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "users" + Constants.PNG_EXT))); BookmarkablePageLink<Page> groupsLink = new BookmarkablePageLink<>("groups", Groups.class); MetaDataRoleAuthorizationStrategy.authorize(groupsLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Groups", "list")); page.add(groupsLink); groupsLink.add(new Image("groupsIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "groups" + Constants.PNG_EXT))); BookmarkablePageLink<Page> resourcesLink = new BookmarkablePageLink<>("resources", Resources.class); MetaDataRoleAuthorizationStrategy.authorize(resourcesLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Resources", "list")); page.add(resourcesLink); resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "resources" + Constants.PNG_EXT))); BookmarkablePageLink<Page> todoLink = new BookmarkablePageLink<>("todo", Todo.class); MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Approval", "list")); page.add(todoLink); todoLink.add(new Image("todoIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "todo" + Constants.PNG_EXT))); BookmarkablePageLink<Page> reportLink = new BookmarkablePageLink<>("reports", Reports.class); MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Reports", "list")); page.add(reportLink); reportLink.add(new Image("reportsIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "reports" + Constants.PNG_EXT))); BookmarkablePageLink<Page> configurationLink = new BookmarkablePageLink<>("configuration", Configuration.class); MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Configuration", "list")); page.add(configurationLink); configurationLink.add(new Image("configurationIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "configuration" + Constants.PNG_EXT))); BookmarkablePageLink<Page> taskLink = new BookmarkablePageLink<>("tasks", Tasks.class); MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Tasks", "list")); page.add(taskLink); taskLink.add(new Image("tasksIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "tasks" + Constants.PNG_EXT))); page.add(new BookmarkablePageLink<Page>("logout", Logout.class)); }
From source file:org.apache.syncope.client.console.SyncopeApplication.java
License:Apache License
public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) { // Modal window for editing user profile final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal"); editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT); editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH); editProfileModalWin.setCookieName("edit-profile-modal"); page.add(editProfileModalWin);//from ww w . j a v a2s.c o m final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { final UserTO userTO; if (SyncopeSession.get().isAuthenticated()) { try { userTO = userSelfRestClient.read(); } catch (Exception e) { throw new WicketRuntimeException(e); } } else { userTO = new UserTO(); } editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO); } }); editProfileModalWin.show(target); } }; editProfileLink.add(new Label("username", SyncopeSession.get().getUsername())); if ("admin".equals(SyncopeSession.get().getUsername())) { editProfileLink.setEnabled(false); } page.add(editProfileLink); }
From source file:org.apache.syncope.console.pages.Login.java
License:Apache License
public Login(final PageParameters parameters) { super(parameters); feedbackPanel = new NotificationPanel(Constants.FEEDBACK); add(feedbackPanel);/*from w w w.ja v a2s . com*/ form = new Form<Void>("login"); userIdField = new TextField<String>("userId", new Model<String>()); userIdField.setMarkupId("userId"); form.add(userIdField); passwordField = new PasswordTextField("password", new Model<String>()); passwordField.setMarkupId("password"); form.add(passwordField); languageSelect = new LocaleDropDown("language"); form.add(languageSelect); AjaxButton submitButton = new AjaxButton("submit", new Model<String>(getString("submit"))) { private static final long serialVersionUID = 429178684321093953L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { try { if (anonymousUser.equals(userIdField.getRawInput())) { throw new AccessControlException("Illegal username"); } authenticate(userIdField.getRawInput(), passwordField.getRawInput()); setResponsePage(WelcomePage.class, parameters); } catch (AccessControlException e) { error(getString("login-error")); feedbackPanel.refresh(target); SyncopeSession.get().resetClients(); } } }; submitButton.setDefaultFormProcessing(false); form.add(submitButton); add(form); // Modal window for self registration final ModalWindow editProfileModalWin = new ModalWindow("selfRegModal"); editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editProfileModalWin.setInitialHeight(SELF_REG_WIN_HEIGHT); editProfileModalWin.setInitialWidth(SELF_REG_WIN_WIDTH); editProfileModalWin.setCookieName("self-reg-modal"); add(editProfileModalWin); Fragment selfRegFrag; if (userSelfRestClient.isSelfRegistrationAllowed()) { selfRegFrag = new Fragment("selfRegistration", "selfRegAllowed", this); final AjaxLink<Void> selfRegLink = new ClearIndicatingAjaxLink<Void>("link", getPageReference()) { private static final long serialVersionUID = -7978723352517770644L; @Override protected void onClickInternal(final AjaxRequestTarget target) { editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { // anonymous authentication needed for self-registration authenticate(anonymousUser, anonymousKey); return new UserSelfModalPage(Login.this.getPageReference(), editProfileModalWin, new UserTO()); } }); editProfileModalWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 251794406325329768L; @Override public void onClose(final AjaxRequestTarget target) { SyncopeSession.get().invalidate(); } }); editProfileModalWin.show(target); } }; selfRegLink.add(new Label("linkTitle", getString("selfRegistration"))); Panel panel = new LinkPanel("selfRegistration", new ResourceModel("selfRegistration")); panel.add(selfRegLink); selfRegFrag.add(panel); } else { selfRegFrag = new Fragment("selfRegistration", "selfRegNotAllowed", this); } add(selfRegFrag); }
From source file:org.apache.syncope.console.pages.panels.AjaxDataTablePanel.java
License:Apache License
public AjaxDataTablePanel(final String id, final List<IColumn<T, S>> columns, final ISortableDataProvider<T, S> dataProvider, final int rowsPerPage, final Collection<ActionLink.ActionType> actions, final BaseRestClient bulkActionExecutor, final String itemIdField, final String pageId, final PageReference pageRef) { super(id);//from w ww .ja v a 2s. c om final ModalWindow bulkModalWin = new ModalWindow("bulkModal"); bulkModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); bulkModalWin.setInitialHeight(600); bulkModalWin.setInitialWidth(900); bulkModalWin.setCookieName("bulk-modal"); add(bulkModalWin); bulkModalWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487149L; @Override public void onClose(final AjaxRequestTarget target) { final EventDataWrapper data = new EventDataWrapper(); data.setTarget(target); data.setRows(rowsPerPage); send(pageRef.getPage(), Broadcast.BREADTH, data); final AbstractBasePage page = (AbstractBasePage) pageRef.getPage(); if (page.isModalResult()) { // reset modal result page.setModalResult(false); // set operation succeeded getSession().info(getString(Constants.OPERATION_SUCCEEDED)); // refresh feedback panel target.add(page.getFeedbackPanel()); } } }); Fragment fragment = new Fragment("tablePanel", "bulkAvailable", this); add(fragment); Form<T> bulkActionForm = new Form<T>("groupForm"); fragment.add(bulkActionForm); group = new CheckGroup<T>("checkgroup", model); group.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = -151291731388673682L; @Override protected void onUpdate(final AjaxRequestTarget target) { // triggers AJAX form submit } }); bulkActionForm.add(group); columns.add(0, new CheckGroupColumn<T, S>(group)); dataTable = new AjaxFallbackDefaultDataTable<T, S>("dataTable", columns, dataProvider, rowsPerPage); group.add(dataTable); fragment.add(new ClearIndicatingAjaxButton("bulkActionLink", bulkActionForm, pageRef) { private static final long serialVersionUID = 382302811235019988L; @Override protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { bulkModalWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690941L; @Override public Page createPage() { return new BulkActionModalPage<T, S>(bulkModalWin, group.getModelObject(), columns, actions, bulkActionExecutor, itemIdField, pageId); } }); bulkModalWin.show(target); } }); }