List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setCssClassName
public ModalWindow setCssClassName(final String cssClassName)
From source file:org.apache.syncope.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 w w w . j ava 2s. c o m 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.getAllAllowedRoles("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.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);/*from ww w. ja v a2 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<Page>("schema", Schema.class); MetaDataRoleAuthorizationStrategy.authorize(schemaLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Schema", "list")); page.add(schemaLink); schemaLink.add(new Image("schemaIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "schema" + Constants.PNG_EXT))); BookmarkablePageLink<Page> usersLink = new BookmarkablePageLink<Page>("users", Users.class); MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Users", "list")); page.add(usersLink); usersLink.add(new Image("usersIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "users" + Constants.PNG_EXT))); BookmarkablePageLink<Page> rolesLink = new BookmarkablePageLink<Page>("roles", Roles.class); MetaDataRoleAuthorizationStrategy.authorize(rolesLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Roles", "list")); page.add(rolesLink); rolesLink.add(new Image("rolesIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "roles" + Constants.PNG_EXT))); BookmarkablePageLink<Page> resourcesLink = new BookmarkablePageLink<Page>("resources", Resources.class); MetaDataRoleAuthorizationStrategy.authorize(resourcesLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Resources", "list")); page.add(resourcesLink); resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "resources" + Constants.PNG_EXT))); BookmarkablePageLink<Page> todoLink = new BookmarkablePageLink<Page>("todo", Todo.class); MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Approval", "list")); page.add(todoLink); todoLink.add(new Image("todoIcon", new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "todo" + Constants.PNG_EXT))); BookmarkablePageLink<Page> reportLink = new BookmarkablePageLink<Page>("reports", Reports.class); MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Reports", "list")); page.add(reportLink); reportLink.add(new Image("reportsIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "reports" + Constants.PNG_EXT))); BookmarkablePageLink<Page> configurationLink = new BookmarkablePageLink<Page>("configuration", Configuration.class); MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Configuration", "list")); page.add(configurationLink); configurationLink.add(new Image("configurationIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "configuration" + Constants.PNG_EXT))); BookmarkablePageLink<Page> taskLink = new BookmarkablePageLink<Page>("tasks", Tasks.class); MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Tasks", "list")); page.add(taskLink); taskLink.add(new Image("tasksIcon", new ContextRelativeResource( IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "tasks" + Constants.PNG_EXT))); page.add(new BookmarkablePageLink<Page>("logout", Logout.class)); }
From source file:org.apache.syncope.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);//ww w. j a v a 2 s . c om final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { final UserTO userTO = SyncopeSession.get().isAuthenticated() ? userSelfRestClient.read() : 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.jaulp.wicket.data.provider.examples.refreshingview.ModalDialogWithStylePanel.java
License:Apache License
public ModalDialogWithStylePanel(String id) { super(id);/*from w w w. j a va 2s .c o m*/ final ModalWindow modal = new ModalWindow("modal"); modal.setCssClassName("w_vegas"); modal.setTitle("Trivial Modal"); AjaxLink<Void> modalLink = new AjaxLink<Void>("modalLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { target.appendJavaScript("var originalStyle = $('.wicket-modal').attr('style');" + "$('.wicket-modal').attr('style', originalStyle + 'opacity: 0.5;');"); } }; Fragment modalFragment = new Fragment(modal.getContentId(), "modalContent", this); modalFragment.add(modalLink); modal.setContent(modalFragment); add(modal); add(new AjaxLink<Void>("openModal") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { modal.show(target); } }); }
From source file:org.jaulp.wicket.dialogs.examples.HomePage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. * * @param parameters//from w w w. j a v a 2 s . co m * Page parameters */ public HomePage(final PageParameters parameters) { final WebMarkupContainer wmc = new WebMarkupContainer("comments"); wmc.setOutputMarkupId(true); final List<MessageBean> noteList = new ArrayList<MessageBean>(); final MessageBean messageBean = new MessageBean(); messageBean.setMessageContent("hello"); final ModalWindow modalWindow = new BaseModalWindow<MessageBean>("baseModalWindow", "Title", 350, 160, new CompoundPropertyModel<MessageBean>(messageBean)) { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void onCancel(final AjaxRequestTarget target) { target.add(wmc); close(target); } @Override public void onSelect(final AjaxRequestTarget target, final MessageBean object) { MessageBean clone = (MessageBean) WicketObjects.cloneObject(object); noteList.add(clone); // Clear the content from textarea in the dialog. object.setMessageContent(""); target.add(wmc); close(target); } }; modalWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); modalWindow.setResizable(false); add(modalWindow); final AjaxLink<String> linkToModalWindow = new AjaxLink<String>("linkToModalWindow") { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { modalWindow.show(target); } }; // Add the WebMarkupContainer... add(wmc); final Label linkToModalWindowLabel = new Label("linkToModalWindowLabel", "show modal dialog"); linkToModalWindow.add(linkToModalWindowLabel); // The AjaxLink to open the modal window add(linkToModalWindow); // here we must set the message content from the bean in a repeater... final ListView<MessageBean> repliesAndNotesListView = new ListView<MessageBean>("repliesAndNotesListView", noteList) { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MessageBean> item) { final MessageBean repliesandnotes = item.getModelObject(); item.add(new RepliesandnotesPanel("repliesandnotesPanel", repliesandnotes)); } }; repliesAndNotesListView.setVisible(true); wmc.add(repliesAndNotesListView); @SuppressWarnings("rawtypes") Link showUploadPage = new Link("showUploadPage") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new UploadPage(getPageParameters())); } }; add(showUploadPage); add(new ModalDialogWithStylePanel("modalDialogWithStylePanel")); }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.simplified.QuestionCategoryOpenAnswerDefinitionPanel.java
License:Open Source License
private ModalWindow createPadModalWindow(String padId) { ModalWindow newPadWindow = new ModalWindow(padId); DataType type = getOpenAnswerDefinition().getDataType(); if (type.equals(DataType.INTEGER) || type.equals(DataType.DECIMAL)) { pad = new NumericPad(newPadWindow.getContentId(), getQuestionModel(), getQuestionCategoryModel(), getOpenAnswerDefinitionModel()) { /**/*from www. ja v a 2 s. co m*/ * */ private static final long serialVersionUID = 1L; @Override public boolean isRequired() { // is never required because in a array the pad allows deselecting the category when setting a null value return false; } }; newPadWindow.setTitle(new StringResourceModel("NumericPadTitle", pad, null)); newPadWindow.setContent(pad); newPadWindow.setCssClassName("onyx"); newPadWindow.setInitialWidth(288); newPadWindow.setInitialHeight(365); newPadWindow.setResizable(false); // same as cancel newPadWindow.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = 1L; public boolean onCloseButtonClicked(AjaxRequestTarget target) { return true; } }); return newPadWindow; } throw new UnsupportedOperationException("Pad for type " + type + " not supported yet."); }
From source file:org.obiba.onyx.webapp.participant.page.InterviewPage.java
License:Open Source License
public InterviewPage() { super();/*w w w.j av a2 s. c o m*/ if (activeInterviewService.getParticipant() == null || activeInterviewService.getInterview() == null) { setResponsePage(WebApplication.get().getHomePage()); } else { addOrReplace(new EmptyPanel("header")); // // Modify menu bar. // remove("menuBar"); add(new InterviewMenuBar("menuBar")); final InterviewLogPanel interviewLogPanel; final Dialog interviewLogsDialog; interviewLogPanel = new InterviewLogPanel("content", 338, new LoadableInterviewLogModel()); interviewLogsDialog = DialogBuilder .buildDialog("interviewLogsDialog", new StringResourceModel("Log", this, null), interviewLogPanel) .setOptions(Option.CLOSE_OPTION).setFormCssClass("interview-log-dialog-form").getDialog(); interviewLogsDialog.setHeightUnit("em"); interviewLogsDialog.setWidthUnit("em"); interviewLogsDialog.setInitialHeight(34); interviewLogsDialog.setInitialWidth(59); interviewLogsDialog.setCloseButtonCallback(new CloseButtonCallback() { private static final long serialVersionUID = 1L; public boolean onCloseButtonClicked(AjaxRequestTarget target, Status status) { // Update comment count on interview page once the modal window closes. User may have added comments. updateCommentCount(target); return true; } }); interviewLogPanel.setup(interviewLogsDialog); interviewLogPanel.add(new AttributeModifier("class", true, new Model("interview-log-panel-content"))); interviewLogPanel.setMarkupId("interviewLogPanel"); interviewLogPanel.setOutputMarkupId(true); add(interviewLogsDialog); Participant participant = activeInterviewService.getParticipant(); add(new ParticipantPanel("participant", new DetachableEntityModel(queryService, participant), true)); // Create modal comments window final ModalWindow commentsWindow; add(commentsWindow = new ModalWindow("addCommentsModal")); commentsWindow.setCssClassName("onyx"); commentsWindow.setTitle(new StringResourceModel("CommentsWindow", this, null)); commentsWindow.setHeightUnit("em"); commentsWindow.setWidthUnit("em"); commentsWindow.setInitialHeight(34); commentsWindow.setInitialWidth(50); commentsWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { } }); ViewInterviewLogsLink viewCommentsIconLink = createIconLink("viewCommentsIconLink", interviewLogsDialog, interviewLogPanel, true); add(viewCommentsIconLink); ContextImage commentIcon = createContextImage("commentIcon", "icons/note.png"); viewCommentsIconLink.add(commentIcon); ViewInterviewLogsLink viewLogIconLink = createIconLink("viewLogIconLink", interviewLogsDialog, interviewLogPanel, false); add(viewLogIconLink); ContextImage logIcon = createContextImage("logIcon", "icons/loupe_button.png"); viewLogIconLink.add(logIcon); // Add view interview comments action add(viewComments = new ViewInterviewLogsLink("viewComments", interviewLogsDialog, interviewLogPanel, true) { private static final long serialVersionUID = -5561038138085317724L; @Override public void onClick(AjaxRequestTarget target) { interviewLogPanel.setCommentsOnly(true); // Disable Show All Button target.appendJavascript( "$('[name=showAll]').attr('disabled','true');$('[name=showAll]').css('color','rgba(0, 0, 0, 0.2)');$('[name=showAll]').css('border-color','rgba(0, 0, 0, 0.2)');"); super.onClick(target); } }); add(new ViewInterviewLogsLink("viewLog", interviewLogsDialog, interviewLogPanel, false) { private static final long serialVersionUID = -5561038138085317724L; @Override public void onClick(AjaxRequestTarget target) { interviewLogPanel.setCommentsOnly(false); // Disable Show All Button target.appendJavascript( "$('[name=showAll]').attr('disabled','true');$('[name=showAll]').css('color','rgba(0, 0, 0, 0.2)');$('[name=showAll]').css('border-color','rgba(0, 0, 0, 0.2)');"); super.onClick(target); } }); // Add create interview comments action add(addCommentDialog = createAddCommentDialog()); add(new AjaxLink("addComment") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { addCommentDialog.show(target); } }); // Initialize comments counter updateCommentsCount(); ActiveInterviewModel interviewModel = new ActiveInterviewModel(); kvPanel = new KeyValueDataPanel("interview"); kvPanel.addRow(new StringResourceModel("StartDate", this, null), new PropertyModel(interviewModel, "startDate")); kvPanel.addRow(new StringResourceModel("EndDate", this, null), new PropertyModel(interviewModel, "endDate")); kvPanel.addRow(new StringResourceModel("Status", this, null), new PropertyModel(interviewModel, "status")); add(kvPanel); // Interview cancellation final ActionDefinition cancelInterviewDef = actionDefinitionConfiguration .getActionDefinition(ActionType.STOP, "Interview", null, null); final ActionWindow interviewActionWindow = new ActionWindow("modal") { private static final long serialVersionUID = 1L; @Override public void onActionPerformed(AjaxRequestTarget target, Stage stage, Action action) { activeInterviewService.setStatus(InterviewStatus.CANCELLED); setResponsePage(InterviewPage.class); } }; add(interviewActionWindow); AjaxLink link = new AjaxLink("cancelInterview") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Label label = new Label("content", new StringResourceModel("ConfirmCancellationOfInterview", InterviewPage.this, null)); label.add(new AttributeModifier("class", true, new Model("confirmation-dialog-content"))); ConfirmationDialog confirmationDialog = getConfirmationDialog(); confirmationDialog.setContent(label); confirmationDialog .setTitle(new StringResourceModel("ConfirmCancellationOfInterviewTitle", this, null)); confirmationDialog.setYesButtonCallback(new OnYesCallback() { private static final long serialVersionUID = -6691702933562884991L; public void onYesButtonClicked(AjaxRequestTarget target) { interviewActionWindow.show(target, null, cancelInterviewDef); } }); confirmationDialog.show(target); } @Override public boolean isVisible() { InterviewStatus status = activeInterviewService.getInterview().getStatus(); return (status == InterviewStatus.IN_PROGRESS || status == InterviewStatus.COMPLETED); } }; MetaDataRoleAuthorizationStrategy.authorize(link, RENDER, "PARTICIPANT_MANAGER"); add(link); // Interview closing final ActionDefinition closeInterviewDef = actionDefinitionConfiguration .getActionDefinition(ActionType.STOP, "Closed.Interview", null, null); final ActionWindow closeInterviewActionWindow = new ActionWindow("closeModal") { private static final long serialVersionUID = 1L; @Override public void onActionPerformed(AjaxRequestTarget target, Stage stage, Action action) { activeInterviewService.setStatus(InterviewStatus.CLOSED); setResponsePage(InterviewPage.class); } }; add(closeInterviewActionWindow); AjaxLink closeLink = new AjaxLink("closeInterview") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Label label = new Label("content", new StringResourceModel("ConfirmClosingOfInterview", InterviewPage.this, null)); label.add(new AttributeModifier("class", true, new Model("confirmation-dialog-content"))); ConfirmationDialog confirmationDialog = getConfirmationDialog(); confirmationDialog.setContent(label); confirmationDialog .setTitle(new StringResourceModel("ConfirmClosingOfInterviewTitle", this, null)); confirmationDialog.setYesButtonCallback(new OnYesCallback() { private static final long serialVersionUID = -6691702933562884991L; public void onYesButtonClicked(AjaxRequestTarget target) { closeInterviewActionWindow.show(target, null, closeInterviewDef); } }); confirmationDialog.show(target); } @Override public boolean isVisible() { InterviewStatus status = activeInterviewService.getInterview().getStatus(); return (status == InterviewStatus.IN_PROGRESS); } }; MetaDataRoleAuthorizationStrategy.authorize(link, RENDER, "PARTICIPANT_MANAGER"); add(closeLink); // Reinstate interview link add(createReinstateInterviewLink()); // Print report link class ReportLink extends AjaxLink { private static final long serialVersionUID = 1L; public ReportLink(String id) { super(id); } @Override public void onClick(AjaxRequestTarget target) { getPrintableReportsDialog().show(target); } } ReportLink printReportLink = new ReportLink("printReport"); printReportLink.add(new Label("reportLabel", new ResourceModel("PrintReport"))); add(printReportLink); add(new StageSelectionPanel("stage-list", getFeedbackWindow()) { private static final long serialVersionUID = 1L; @Override public void onViewComments(AjaxRequestTarget target, String stage) { commentsWindow.setContent(new CommentsModalPanel("content", commentsWindow, stage) { private static final long serialVersionUID = 1L; @Override public void onAddComments(AjaxRequestTarget target) { InterviewPage.this.updateCommentsCount(); target.addComponent(InterviewPage.this.commentsCount); } }); commentsWindow.show(target); } @Override public void onViewLogs(AjaxRequestTarget target, String stage, boolean commentsOnly) { interviewLogPanel.setStageName(stage); interviewLogPanel.setCommentsOnly(commentsOnly); interviewLogPanel.setReadOnly(true); interviewLogPanel.addInterviewLogComponent(); interviewLogsDialog.show(target); } @Override public void onActionPerformed(AjaxRequestTarget target, Stage stage, Action action) { if (activeInterviewService.getStageExecution(action.getStage()).isFinal()) { setResponsePage(InterviewPage.class); } else { InterviewPage.this.updateCommentsCount(); target.addComponent(InterviewPage.this.commentsCount); } } }); AjaxLink exitLink = new AjaxLink("exitInterview") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { interviewManager.releaseInterview(); setResponsePage(HomePage.class); } }; add(exitLink); } }
From source file:org.syncope.console.pages.BasePage.java
License:Apache License
private void pageSetup() { ((SyncopeApplication) getApplication()).setupNavigationPane(this, xmlRolesReader, true, version); feedbackPanel = new FeedbackPanel("feedback"); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel);/* ww w. j ava2 s . co m*/ final String kind = getClass().getSimpleName().toLowerCase(); final BookmarkablePageLink kindLink = (BookmarkablePageLink) get(kind); if (kindLink != null) { kindLink.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("class", kind); } }); Component kindIcon = kindLink.get(0); if (kindIcon != null) { kindIcon.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("src", "../.." + SyncopeApplication.IMG_PREFIX + kind + SyncopeApplication.IMG_SUFFIX); } }); } } // 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"); add(editProfileModalWin); add(new Label("username", SyncopeSession.get().getUserId())); Fragment editProfileFrag; if ("admin".equals(SyncopeSession.get().getUserId())) { editProfileFrag = new Fragment("editProfile", "adminEmptyFrag", this); } else { final UserTO userTO = SyncopeSession.get().isAuthenticated() ? profileRestClient.readProfile() : new UserTO(); editProfileFrag = new Fragment("editProfile", "editProfileFrag", this); AjaxLink editProfileLink = new IndicatingAjaxLink("link") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() { @Override public Page createPage() { return new UserRequestModalPage(BasePage.this.getPageReference(), editProfileModalWin, userTO); } }); editProfileModalWin.show(target); } }; editProfileLink.add(new Label("linkTitle", getString("editProfile"))); Panel panel = new LinkPanel("editProfile", new ResourceModel("editProfile")); panel.add(editProfileLink); editProfileFrag.add(panel); } add(editProfileFrag); }
From source file:org.syncope.console.pages.Login.java
License:Apache License
public Login(final PageParameters parameters) { super(parameters); form = new Form("login"); userIdField = new TextField("userId", new Model()); userIdField.setMarkupId("userId"); form.add(userIdField);/* w ww . ja v a 2 s. co m*/ passwordField = new PasswordTextField("password", new Model()); passwordField.setMarkupId("password"); form.add(passwordField); languageSelect = new LocaleDropDown("language", Arrays.asList(new Locale[] { Locale.ENGLISH, Locale.ITALIAN })); form.add(languageSelect); Button submitButton = new Button("submit", new Model(getString("submit"))) { private static final long serialVersionUID = 429178684321093953L; @Override public void onSubmit() { String[] entitlements = authenticate(userIdField.getRawInput(), passwordField.getRawInput()); if (entitlements == null) { error(getString("login-error")); } else { SyncopeSession.get().setUserId(userIdField.getRawInput()); SyncopeSession.get().setEntitlements(entitlements); SyncopeSession.get().setCoreVersion(getCoreVersion()); setResponsePage(WelcomePage.class, parameters); } } }; submitButton.setDefaultFormProcessing(false); form.add(submitButton); add(form); add(new FeedbackPanel("feedback")); // 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 (isSelfRegistrationAllowed()) { selfRegFrag = new Fragment("selfRegistration", "selfRegAllowed", this); AjaxLink selfRegLink = new IndicatingAjaxLink("link") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserRequestModalPage(Login.this.getPageReference(), editProfileModalWin, new UserTO()); } }); 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.syncope.console.pages.panels.PoliciesPanel.java
License:Apache License
public PoliciesPanel(final String id, final PolicyType policyType) { super(id);//w w w . j a v a 2 s . c om 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> columns = new ArrayList<IColumn>(); columns.add(new PropertyColumn(new ResourceModel("id"), "id", "id")); columns.add(new PropertyColumn(new ResourceModel("description"), "description", "description")); columns.add(new AbstractColumn<PolicyTO>(new ResourceModel("type")) { private static final long serialVersionUID = 8263694778917279290L; @Override public void populateItem(final Item<ICellPopulator<PolicyTO>> cellItem, final String componentId, final IModel<PolicyTO> model) { cellItem.add(new Label(componentId, getString(model.getObject().getType().name()))); } }); columns.add(new AbstractColumn<PolicyTO>(new ResourceModel("actions", "")) { private static final long serialVersionUID = 2054811145491901166L; @Override public String getCssClass() { return "action"; } @Override public void populateItem(final Item<ICellPopulator<PolicyTO>> cellItem, final String componentId, final IModel<PolicyTO> model) { final PolicyTO accountPolicyTO = model.getObject(); final ActionLinksPanel panel = new ActionLinksPanel(componentId, model); 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() { final PolicyModalPage page = new PolicyModalPage(mwindow, accountPolicyTO); return page; } }); mwindow.show(target); } }, ActionLink.ActionType.EDIT, "Policies", "read"); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { policyRestClient.delete(accountPolicyTO.getId()); info(getString("operation_succeded")); } catch (SyncopeClientCompositeErrorException e) { error(getString("operation_error")); LOG.error("While deleting resource {}({})", new Object[] { accountPolicyTO.getId(), accountPolicyTO.getDescription() }, e); } target.add(container); target.add(getPage().get("feedback")); } }, ActionLink.ActionType.DELETE, "Policies", "delete"); cellItem.add(panel); } }); final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("datatable", columns, new PolicyDataProvider(), paginatorRows); container.add(table); final IndicatingAjaxLink createButton = new IndicatingAjaxLink("createLink") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { mwindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { final PolicyModalPage page = new PolicyModalPage(mwindow, getPolicyTOInstance(policyType)); return page; } }); mwindow.show(target); } }; add(createButton); MetaDataRoleAuthorizationStrategy.authorize(createButton, ENABLE, xmlRolesReader.getAllAllowedRoles("Policies", "create")); final Form paginatorForm = new Form("PaginatorForm"); final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"), prefMan.getPaginatorChoices()); rowsChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") { 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); }