List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setPageCreator
public ModalWindow setPageCreator(final PageCreator creator)
PageCreator
instance. From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel.java
License:Apache License
public CacheListPanel(final String id, final Behavior updater, final Component[] updateList) { super(id);//ww w .ja v a 2s.c o m final ModalWindow modal1; add(modal1 = new ModalWindow("modal1")); modal1.setInitialWidth(1000); // modal1.setCookieName("modal-1"); modal1.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new CacheDetailsPage(hostname); } }); this.updateList = updateList; final WebMarkupContainer container = new WebMarkupContainer("listpanel"); container.setOutputMarkupId(true); add(container); servers = createServerListView(updater, modal1); servers.setOutputMarkupId(true); container.setOutputMarkupId(true); container.add(servers); add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { private static final long serialVersionUID = 1L; int serverCount = 0; @Override protected final void onTimer(final AjaxRequestTarget target) { // target.add(getComponent()); final int size = CacheState.getCacheStates().size(); if (serverCount != size) { serverCount = size; servers.setList(getServerList()); target.add(container); if (updateList != null) { for (Component c : updateList) { target.add(c); } } // target.add(graph); } } }); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsListPanel.java
License:Apache License
public DsListPanel(final String id, final Behavior updater, final Component[] updateList) { super(id);/*from www.j a va 2 s.co m*/ final ModalWindow modal1; add(modal1 = new ModalWindow("modal2")); modal1.setInitialWidth(1000); // modal1.setCookieName("modal-1"); modal1.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new DsDetailsPage(dsId); } }); this.updateList = updateList; final WebMarkupContainer container = new WebMarkupContainer("listpanel"); container.setOutputMarkupId(true); add(container); servers = createDsListView(updater, modal1); servers.setOutputMarkupId(true); container.setOutputMarkupId(true); container.add(servers); add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { private static final long serialVersionUID = 1L; int serverCount = 0; @Override protected final void onTimer(final AjaxRequestTarget target) { final int size = DsState.getDsStates().size(); if (serverCount != size) { serverCount = size; servers.setList(getDsList()); target.add(container); if (updateList != null) { for (Component c : updateList) { target.add(c); } } } } }); }
From source file:com.doculibre.constellio.wicket.panels.admin.indexing.AdminIndexingPanel.java
License:Open Source License
private void configurePopUp(ModalWindow modal, final String textPopUp, String titlePopUp) { modal.add(new OpenWindowOnLoadBehavior()); modal.setContent(new SimpleContentPanel(modal.getContentId(), textPopUp)); modal.setTitle(titlePopUp);//from ww w . j ava 2 s .c o m modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY); modal.setMaskType(ModalWindow.MaskType.TRANSPARENT); modal.setInitialWidth(200); modal.setWidthUnit("px"); modal.setResizable(false); modal.setUseInitialHeight(false); modal.setCookieName("wicket-tips/styledModal"); modal.setPageCreator(new ModalWindow.PageCreator() { @Override public Page createPage() { // TODO Auto-generated method stub return new PopUpPage(textPopUp); } }); }
From source file:com.doculibre.constellio.wicket.panels.results.MailSearchResultPanel.java
License:Open Source License
public MailSearchResultPanel(String id, final SolrDocument doc, final SearchResultsDataProvider dataProvider) { super(id);// w w w.j av a 2s . c om RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices(); final Long recordId = new Long(doc.getFieldValue(IndexField.RECORD_ID_FIELD).toString()); final String collectionName = dataProvider.getSimpleSearch().getCollectionName(); RecordCollection collection = collectionServices.get(collectionName); Record record = recordServices.get(recordId, collection); final IModel subjectModel = new LoadableDetachableModel() { @Override protected Object load() { RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); Record record = recordServices.get(doc); String subject = record.getDisplayTitle(); if (StringUtils.isBlank(subject)) { subject = getLocalizer().getString("noSubject", MailSearchResultPanel.this); } if (subject.length() > 60) { subject = subject.substring(0, 60) + " ..."; } return subject; } }; // List<byte[]> attachmentContents = new ArrayList<byte[]>(); // String messageContent = null; // for (RawContent raw : rawContents) { // byte[] bytes = raw.getContent(); // if (messageContent == null) { // messageContent = new String(bytes); // } else { // attachmentContents.add(bytes); // } // System.out.println("partial content :" + new String(bytes)); // } // System.out.println("content 1 :" + messageContent); // Description du document dans extrait: QueryResponse response = dataProvider.getQueryResponse(); Map<String, Map<String, List<String>>> highlighting = response.getHighlighting(); final String recordURL = record.getUrl(); Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL); ConnectorInstance connectorInstance = record.getConnectorInstance(); IndexField defaultSearchField = collection.getDefaultSearchIndexField(); String excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting); final ModalWindow detailsMailModal = new ModalWindow("detailsMailModal"); detailsMailModal.setPageCreator(new PageCreator() { @Override public Page createPage() { return new BaseConstellioPage(); } }); add(detailsMailModal); detailsMailModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY); detailsMailModal.setCookieName("detailsMailModal"); IModel modalTitleModel = subjectModel; detailsMailModal.setTitle(modalTitleModel); final String displayURL = (String) doc.getFieldValue(collection.getUrlIndexField().getName()); emailModel = new LoadableDetachableModel() { @Override protected Object load() { RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); Record record = recordServices.get(doc); List<String> attachmentNames = record.getMetaContents(MailConnectorConstants.META_ATTACHMENTNAME); List<String> attachmentTypes = record.getMetaContents(MailConnectorConstants.META_ATTACHMENTTYPE); List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS); List<String> flags = record.getMetaContents(MailConnectorConstants.META_FLAGS); List<String> froms = record.getMetaContents(MailConnectorConstants.META_SENDER); // FIXME Hardcoded List<String> contentEncoding = record.getMetaContents("Content-Encoding"); List<String> receivedDateList = record.getMetaContents(MailConnectorConstants.META_RECEIVEDDATE); // FIXME voir avec Vincent : exemple qui ne marche pas jobboom car mail contient que du html RawContentServices rawContentServices = ConstellioSpringUtils.getRawContentServices(); List<RawContent> rawContents = rawContentServices.getRawContents(record); ParsedContent parsedContents = record.getParsedContent(); Email email; if (rawContents.size() != 0) { byte[] content = rawContents.get(0).getContent(); String tmpFilePath = ClasspathUtils.getCollectionsRootDir() + File.separator + "tmp.eml"; try { email = MailMessageUtils.toEmail(content, tmpFilePath); } catch (Exception e) { System.out.println("Error in reading content of mail"); // le contenu n'a pas bien t lu correctement email = new Email(); email.setMessageContentText(parsedContents.getContent()); } } else { // le contenu n'a pas bien t lu correctement email = new Email(); email.setMessageContentText(parsedContents.getContent()); } email.setFlags(flags); // email.setMessageContentHtml(messageContentHtml); if (!receivedDateList.isEmpty()) { email.setReceivedDate(receivedDateList.get(0)); } email.setRecipients(recipients); email.setSubject((String) subjectModel.getObject()); email.setFroms(froms); // email.setLanguage(language); if (!contentEncoding.isEmpty()) { email.setContentEncoding(contentEncoding.get(0)); } return email; } }; final RecordModel recordModel = new RecordModel(record); AjaxLink detailsMailLink = new AjaxLink("detailsMailLink") { @Override public void onClick(AjaxRequestTarget target) { Email email = (Email) emailModel.getObject(); detailsMailModal.setContent(new MailDetailsPanel(detailsMailModal.getContentId(), email)); detailsMailModal.show(target); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxCallDecorator() { @Override public CharSequence decorateScript(CharSequence script) { Record record = recordModel.getObject(); SimpleSearch simpleSearch = dataProvider.getSimpleSearch(); WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest(); HttpServletRequest httpRequest = webRequest.getHttpServletRequest(); return script + ";" + ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch, record); } }; } }; add(detailsMailLink); IModel recipientsLabelModel = new LoadableDetachableModel() { @Override protected Object load() { RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); Record record = recordServices.get(doc); List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS); return getLocalizer().getString("to", MailSearchResultPanel.this) + " : " + recipients; } }; IModel receivedDateLabelModel = new LoadableDetachableModel() { @Override protected Object load() { RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); Record record = recordServices.get(doc); List<String> receivedDateList = record.getMetaContents(MailConnectorConstants.META_RECEIVEDDATE); String receivedDate; if (!receivedDateList.isEmpty()) { receivedDate = receivedDateList.get(0); } else { receivedDate = ""; } return getLocalizer().getString("date", MailSearchResultPanel.this) + " : " + receivedDate; } }; Label subjectLabel = new Label("subject", subjectModel); detailsMailLink.add(subjectLabel.setEscapeModelStrings(false)); Label excerptLbl = new Label("messageContent", excerpt); add(excerptLbl.setEscapeModelStrings(false)); add(new Label("recipient", recipientsLabelModel) { @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { RecordCollectionServices collectionServices = ConstellioSpringUtils .getRecordCollectionServices(); RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); RecordCollection collection = collectionServices.get(collectionName); Record record = recordServices.get(recordId, collection); List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS); visible = !recipients.isEmpty(); } return visible; } }); // add(new Label("from", getLocalizer().getString("from", this) + " : " + froms)); add(new Label("date", receivedDateLabelModel)); add(new WebMarkupContainer("hasAttachmentsImg") { @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); Record record = recordServices.get(doc); List<String> attachmentNames = record .getMetaContents(MailConnectorConstants.META_ATTACHMENTNAME); visible = !attachmentNames.isEmpty(); } return visible; } }); final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>( collection); add(new ListView("searchResultFields", new LoadableDetachableModel() { @Override protected Object load() { RecordCollection collection = collectionModel.getObject(); return collection.getSearchResultFields(); } /** * Detaches from the current request. Implement this method with custom behavior, such as * setting the model object to null. */ protected void onDetach() { recordModel.detach(); collectionModel.detach(); } }) { @Override protected void populateItem(ListItem item) { SearchResultField searchResultField = (SearchResultField) item.getModelObject(); IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices(); Record record = recordModel.getObject(); IndexField indexField = searchResultField.getIndexField(); Locale locale = getLocale(); String indexFieldTitle = indexField.getTitle(locale); if (StringUtils.isBlank(indexFieldTitle)) { indexFieldTitle = indexField.getName(); } StringBuffer fieldValueSb = new StringBuffer(); List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField); Map<String, String> defaultLabelledValues = indexFieldServices.getDefaultLabelledValues(indexField, locale); for (Object fieldValue : fieldValues) { if (fieldValueSb.length() > 0) { fieldValueSb.append("\n"); } String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale); if (fieldValueLabel == null) { fieldValueLabel = defaultLabelledValues.get("" + fieldValue); } if (fieldValueLabel == null) { fieldValueLabel = "" + fieldValue; } fieldValueSb.append(fieldValueLabel); } item.add(new Label("indexField", indexFieldTitle)); item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString())); item.setVisible(fieldValueSb.length() > 0); } @SuppressWarnings("unchecked") @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject(); visible = !searchResultFields.isEmpty(); } return visible; } }); add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch())); }
From source file:com.evolveum.midpoint.web.page.admin.configuration.component.ObjectSelectionPage.java
License:Apache License
public static <T extends ObjectType> void prepareDialog(ModalWindow dialog, ObjectSelectionPanel.Context context, final Component callingComponent, String titleResourceKey, final String idToRefresh) { dialog.setPageCreator(new ObjectSelectionPage.PageCreator(dialog, context)); dialog.setInitialWidth(800);/*from w ww . j av a 2 s.co m*/ dialog.setInitialHeight(500); dialog.setTitle(PageBase.createStringResourceStatic(callingComponent, titleResourceKey)); dialog.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { // We are not able to refresh targets residing in the parent page // from inside the modal window -> so we have to do it in this // context, when the modal window is being closed. public void onClose(AjaxRequestTarget target) { target.add(callingComponent.get(idToRefresh)); } }); dialog.showUnloadConfirmation(false); dialog.setCssClassName(ModalWindow.CSS_CLASS_GRAY); dialog.setCookieName(ObjectSelectionPanel.class.getSimpleName() + ((int) (Math.random() * 100))); dialog.setWidthUnit("px"); }
From source file:com.userweave.pages.configuration.project.projectbrowser.MyProjectListViewPanel.java
License:Open Source License
/** * Create a dialog to create a new project. * //ww w .ja v a 2 s. c o m * @return * A CustomModalWindow */ private ModalWindow createNewProjectModalWindow(final Project parentProject, final EventHandler callback) { final ModalWindow projectModalWindow = new CustomModalWindow("createNewProjectModalWindow"); projectModalWindow.setTitle(new StringResourceModel("newProject", MyProjectListViewPanel.this, null)); projectModalWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; @Override public Page createPage() { return new EditProjectPage(projectModalWindow) { private static final long serialVersionUID = 1L; @Override protected void onFinish(AjaxRequestTarget target, String projectName) { Project project = projectService.createPreConfiguredProject(projectName); /** * @see #933. User can add subproject, so there must be * getUser(project) called */ projectDao.finalizeProject(project, UserWeaveSession.get().getUser()); UserWeaveSession.get().setCreatedEntityId(project.getId()); } }; } }); projectModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; @Override public void onClose(AjaxRequestTarget target) { Integer projectId = UserWeaveSession.get().getCreatedEntityId(); if (projectId != null) { EntityEvent.Selected(target, projectDao.findById(projectId)).fire(callback); projectId = null; } } }); return projectModalWindow; }
From source file:com.userweave.pages.test.DisplaySurveyUI.java
License:Open Source License
private void addModalWindow(SurveyExecution surveyExecution) { String ID = "modalWindow"; if (surveyExecution == null || evaluateError(surveyExecution) != ErrorType.NONE || studyService.isAtLeastOneAdminRegistered(surveyExecution.getStudy().getParentProject())) { add(new WebMarkupContainer(ID)); } else {//from w ww .j a v a 2s . c o m final ModalWindow modalWindow = new CustomModalWindow(ID); modalWindow.setInitialHeight(379); add(modalWindow); modalWindow.add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { private static final long serialVersionUID = 1L; @Override protected void onTimer(AjaxRequestTarget target) { this.stop(); modalWindow.show(target); } }); modalWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; @Override public Page createPage() { return new InformAboutIncompleteRegistrationPage(modalWindow); } }); } }
From source file:com.userweave.pages.user.verification.UserVerificationPanel.java
License:Open Source License
/** * @return/*from w w w . ja v a 2 s .c o m*/ */ protected ModalWindow createAgbModal() { final ModalWindow agbModalWindow = new CustomModalWindow("agbModalWindow"); agbModalWindow.setInitialHeight(550); agbModalWindow.setInitialWidth(600); agbModalWindow.setPageCreator(new ModalWindow.PageCreator() { public Page createPage() { return new TermsOfUsePage(agbModalWindow); } }); return agbModalWindow; }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentEnvironmentForm.java
License:Apache License
private void addModalWindowAndButton(MarkupContainer container, final String cookieName, final String buttonName, final String targetClass, final ModalWindow window) { AjaxButton ajaxButton = new AjaxButton(buttonName) { private static final long serialVersionUID = 1L; @Override/*ww w . ja va2 s .c o m*/ protected void onSubmit(AjaxRequestTarget target, Form<?> form) { window.setCookieName(cookieName); window.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; @Override public Page createPage() { try { Constructor<?> cons = null; cons = Class.forName(targetClass).getConstructor(PageReference.class, ModalWindow.class); return (Page) cons.newInstance(getPage().getPageReference(), window); } catch (NoSuchMethodException e) { log.error(e.getMessage(), e); } catch (IllegalAccessException e) { log.error(e.getMessage(), e); } catch (InstantiationException e) { log.error(e.getMessage(), e); } catch (InvocationTargetException e) { log.error(e.getMessage(), e); } catch (ClassNotFoundException e) { log.error(e.getMessage(), e); } return null; } }); window.show(target); } }; ajaxButton.setDefaultFormProcessing(false); container.add(ajaxButton); }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentScenarioForm.java
License:Apache License
private void addModalWindowAndButton(MarkupContainer container, final String cookieName, final String buttonName, final String targetClass, final ModalWindow window) { window.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; @Override/* w w w. j ava 2 s. c om*/ public void onClose(AjaxRequestTarget target) { ChoiceRenderer<Person> renderer = new ChoiceRenderer<Person>("fullName", "personId"); List<Person> choices = personFacade.getAllRecords(); Collections.sort(choices); coexperimenters.setChoiceRenderer(renderer); coexperimenters.setChoices(choices); ChoiceRenderer<ResearchGroup> groupRenderer = new ChoiceRenderer<ResearchGroup>("title", "researchGroupId"); List<ResearchGroup> groupChoices = researchGroupFacade .getResearchGroupsWhereAbleToWriteInto(EEGDataBaseSession.get().getLoggedUser()); researchGroupChoice.setChoiceRenderer(groupRenderer); researchGroupChoice.setChoices(groupChoices); licenses.clear(); licenses.addAll(model.getObject().getExperimentLicences()); licenses.addAll(EEGDataBaseSession.get().getCreateExperimentLicenseMap().values()); target.add(AddExperimentScenarioForm.this); } }); AjaxButton ajaxButton = new AjaxButton(buttonName) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { window.setCookieName(cookieName); window.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("serial") public Page createPage() { try { Constructor<?> cons = null; if (targetClass.equals(AddLicensePage.class.getName())) { p = new AddLicensePage(getPage().getPageReference(), window, model) { @Override protected void onSubmitAction(IModel<ExperimentLicence> experimentLicenseModel, Integer licenseId, AjaxRequestTarget target, Form<?> form) { ExperimentLicence experimentLicense = experimentLicenseModel.getObject(); EEGDataBaseSession.get().addLicenseToCreateLicenseMap(licenseId, experimentLicense); ModalWindow.closeCurrent(target); } }; return (Page) p; } else { cons = Class.forName(targetClass).getConstructor(PageReference.class, ModalWindow.class); return (Page) cons.newInstance(getPage().getPageReference(), window); } } catch (NoSuchMethodException e) { log.error(e.getMessage(), e); } catch (IllegalAccessException e) { log.error(e.getMessage(), e); } catch (InstantiationException e) { log.error(e.getMessage(), e); } catch (InvocationTargetException e) { log.error(e.getMessage(), e); } catch (ClassNotFoundException e) { log.error(e.getMessage(), e); } return null; } }); window.show(target); } }; ajaxButton.setDefaultFormProcessing(false); container.add(ajaxButton); }