List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow ModalWindow
public ModalWindow(final String id)
From source file:org.geoserver.wms.web.WMSAdminPage.java
License:Open Source License
@SuppressWarnings("unchecked") protected void build(IModel info, Form form) { // popups support form.add(modal = new ModalWindow("modal")); // authority URLs and Identifiers for the root layer LayerAuthoritiesAndIdentifiersPanel authAndIds; authAndIds = new LayerAuthoritiesAndIdentifiersPanel("authoritiesAndIds", true, info); form.add(authAndIds);/*w ww. j a v a 2 s. co m*/ // limited srs list TextArea srsList = new SRSListTextArea("srs", LiveCollectionModel.list(new PropertyModel(info, "sRS"))); form.add(srsList); form.add(new CheckBox("bBOXForEachCRS")); form.add(new AjaxLink("bBOXForEachCRSHelp") { @Override public void onClick(AjaxRequestTarget target) { dialog.showInfo(target, new StringResourceModel("bboxForEachCRSHelp.title", WMSAdminPage.this, null), new StringResourceModel("bboxForEachCRSHelp.message", WMSAdminPage.this, null)); } }); // advanced projection handling PropertyModel metadataModel = new PropertyModel(info, "metadata"); MapModel aphEnabled = defaultedModel(metadataModel, WMS.ADVANCED_PROJECTION_KEY, WMS.ENABLE_ADVANCED_PROJECTION); CheckBox aphEnabledField = new CheckBox("aph.enabled", aphEnabled); form.add(aphEnabledField); MapModel aphWrap = defaultedModel(metadataModel, WMS.MAP_WRAPPING_KEY, WMS.ENABLE_MAP_WRAPPING); CheckBox aphWrapField = new CheckBox("aph.wrap", aphWrap); form.add(aphWrapField); // general form.add(new DropDownChoice("interpolation", Arrays.asList(WMSInfo.WMSInterpolation.values()), new InterpolationRenderer())); // resource limits TextField<Integer> maxMemory = new TextField<Integer>("maxRequestMemory"); maxMemory.add(new MinimumValidator<Integer>(0)); form.add(maxMemory); TextField<Integer> maxTime = new TextField<Integer>("maxRenderingTime"); maxTime.add(new MinimumValidator<Integer>(0)); form.add(maxTime); TextField<Integer> maxErrors = new TextField<Integer>("maxRenderingErrors"); maxErrors.add(new MinimumValidator<Integer>(0)); form.add(maxErrors); // watermark form.add(new CheckBox("watermark.enabled")); TextField watermarkUrlField = new TextField("watermark.uRL", new FileModel(new PropertyModel<String>(form.getModel(), "watermark.URL"))); watermarkUrlField.add(new FileExistsValidator(true)); watermarkUrlField.setOutputMarkupId(true); form.add(watermarkUrlField); form.add(chooserButton("chooser", new ParamResourceModel("chooseWatermark", this).getString(), watermarkUrlField)); TextField<Integer> transparency = new TextField<Integer>("watermark.transparency"); transparency.add(new RangeValidator<Integer>(0, 100)); form.add(transparency); form.add(new DropDownChoice("watermark.position", Arrays.asList(Position.values()), new WatermarkPositionRenderer())); // svg form.add(new CheckBox("svg.antialias", new MapModel(metadataModel, "svgAntiAlias"))); form.add(new DropDownChoice("svg.producer", new MapModel(metadataModel, "svgRenderer"), SVG_RENDERERS, new SVGMethodRenderer())); // png compression levels MapModel pngCompression = defaultedModel(metadataModel, WMS.PNG_COMPRESSION, WMS.PNG_COMPRESSION_DEFAULT); TextField<Integer> pngCompressionField = new TextField<Integer>("png.compression", pngCompression, Integer.class); pngCompressionField.add(new RangeValidator<Integer>(0, 100)); form.add(pngCompressionField); // jpeg compression levels MapModel jpegCompression = defaultedModel(metadataModel, WMS.JPEG_COMPRESSION, WMS.JPEG_COMPRESSION_DEFAULT); TextField<Integer> jpegCompressionField = new TextField<Integer>("jpeg.compression", jpegCompression, Integer.class); jpegCompressionField.add(new RangeValidator<Integer>(0, 100)); form.add(jpegCompressionField); // GIF animated // MAX_ALLOWED_FRAMES MapModel maxAllowedFrames = defaultedModel(metadataModel, WMS.MAX_ALLOWED_FRAMES, WMS.MAX_ALLOWED_FRAMES_DEFAULT); TextField<Integer> maxAllowedFramesField = new TextField<Integer>("anim.maxallowedframes", maxAllowedFrames, Integer.class); maxAllowedFramesField.add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); form.add(maxAllowedFramesField); // MAX_RENDERING_TIME MapModel maxRenderingTime = defaultedModel(metadataModel, WMS.MAX_RENDERING_TIME, null); TextField<Integer> maxRenderingTimeField = new TextField<Integer>("anim.maxrenderingtime", maxRenderingTime, Integer.class); form.add(maxRenderingTimeField); // MAX_RENDERING_SIZE MapModel maxRenderingSize = defaultedModel(metadataModel, WMS.MAX_RENDERING_SIZE, null); TextField<Integer> maxRenderingSizeField = new TextField<Integer>("anim.maxrenderingsize", maxRenderingSize, Integer.class); form.add(maxRenderingSizeField); // FRAMES_DELAY MapModel framesDelay = defaultedModel(metadataModel, WMS.FRAMES_DELAY, WMS.FRAMES_DELAY_DEFAULT); TextField<Integer> framesDelayField = new TextField<Integer>("anim.framesdelay", framesDelay, Integer.class); framesDelayField.add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); form.add(framesDelayField); // LOOP_CONTINUOUSLY MapModel loopContinuously = defaultedModel(metadataModel, WMS.LOOP_CONTINUOUSLY, WMS.LOOP_CONTINUOUSLY_DEFAULT); CheckBox loopContinuouslyField = new CheckBox("anim.loopcontinuously", loopContinuously); form.add(loopContinuouslyField); // kml handling MapModel kmlReflectorMode = defaultedModel(metadataModel, WMS.KML_REFLECTOR_MODE, WMS.KML_REFLECTOR_MODE_DEFAULT); form.add(new DropDownChoice("kml.defaultReflectorMode", kmlReflectorMode, KML_REFLECTOR_MODES)); MapModel kmlSuperoverlayMode = defaultedModel(metadataModel, WMS.KML_SUPEROVERLAY_MODE, WMS.KML_SUPEROVERLAY_MODE_DEFAULT); form.add(new DropDownChoice("kml.superoverlayMode", kmlSuperoverlayMode, KML_SUPEROVERLAY_MODES)); form.add(new CheckBox("kml.kmattr", defaultedModel(metadataModel, WMS.KML_KMLATTR, WMS.KML_KMLATTR_DEFAULT))); form.add(new CheckBox("kml.kmlplacemark", defaultedModel(metadataModel, WMS.KML_KMLPLACEMARK, WMS.KML_KMLPLACEMARK_DEFAULT))); MapModel kmScore = defaultedModel(metadataModel, WMS.KML_KMSCORE, WMS.KML_KMSCORE_DEFAULT); TextField<Integer> kmScoreField = new TextField<Integer>("kml.kmscore", kmScore, Integer.class); kmScoreField.add(new RangeValidator<Integer>(0, 100)); form.add(kmScoreField); //scalehint form.add(new CheckBox("scalehint.mapunitsPixel", defaultedModel(metadataModel, WMS.SCALEHINT_MAPUNITS_PIXEL, WMS.SCALEHINT_MAPUNITS_PIXEL_DEFAULT))); // mime types for GetMap getMapAvailable = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (GetMapOutputFormat format : GeoServerExtensions.extensions(GetMapOutputFormat.class)) { getMapAvailable.add(format.getMimeType()); } List<String> getMapSelected = new ArrayList<String>(); getMapSelected.addAll(new PropertyModel<Set<String>>(info, "getMapMimeTypes").getObject()); List<String> getMapChoices = new ArrayList<String>(); getMapChoices.addAll(getMapAvailable); form.add(getMapMimeTypesComponent = new MimeTypesFormComponent("getMapMimeTypes", new ListModel<String>(getMapSelected), new CollectionModel<String>(getMapChoices), new PropertyModel<Boolean>(info, "getMapMimeTypeCheckingEnabled").getObject())); // mime types for GetFeatueInfo getFeatureInfoAvailable = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (GetFeatureInfoOutputFormat format : GeoServerExtensions.extensions(GetFeatureInfoOutputFormat.class)) { getFeatureInfoAvailable.add(format.getContentType()); } List<String> getFeatureInfoSelected = new ArrayList<String>(); getFeatureInfoSelected.addAll(new PropertyModel<Set<String>>(info, "getFeatureInfoMimeTypes").getObject()); List<String> getFeatureInfoChoices = new ArrayList<String>(); getFeatureInfoChoices.addAll(getFeatureInfoAvailable); form.add(getFeatureInfoMimeTypesComponent = new MimeTypesFormComponent("getFeatureInfoMimeTypes", new ListModel<String>(getFeatureInfoSelected), new CollectionModel<String>(getFeatureInfoChoices), new PropertyModel<Boolean>(info, "getFeatureInfoMimeTypeCheckingEnabled").getObject())); }
From source file:org.geoserver.wps.web.ComplexInputPanel.java
License:Open Source License
public ComplexInputPanel(String id, InputParameterValues pv, int valueIndex) { super(id);/* w ww . ja v a2 s .co m*/ setOutputMarkupId(true); setDefaultModel(new PropertyModel(pv, "values[" + valueIndex + "]")); valueModel = new PropertyModel(getDefaultModel(), "value"); mimeTypes = pv.getSupportedMime(); List<ParameterType> ptypes = pv.getSupportedTypes(); ptypes.remove(ParameterType.LITERAL); typeChoice = new DropDownChoice("type", new PropertyModel(getDefaultModelObject(), "type"), ptypes); add(typeChoice); subprocesswindow = new ModalWindow("subprocessPopupWindow"); subprocesswindow.setInitialWidth(700); subprocesswindow.setInitialHeight(500); add(subprocesswindow); subprocesswindow.setPageCreator(new ModalWindow.PageCreator() { public Page createPage() { return new SubProcessBuilder((ExecuteRequest) subprocesswindow.getDefaultModelObject(), subprocesswindow); } }); updateEditor(); typeChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { updateEditor(); target.addComponent(ComplexInputPanel.this); } }); }
From source file:org.geoserver.wps.web.WPSRequestBuilder.java
License:Open Source License
public WPSRequestBuilder(String procName) { // the form/*from ww w.ja va2s .co m*/ Form form = new Form("form"); add(form); // the actual request builder component ExecuteRequest execRequest = new ExecuteRequest(); if (procName != null) execRequest.processName = procName; builder = new WPSRequestBuilderPanel("requestBuilder", execRequest); form.add(builder); // the xml popup window final ModalWindow xmlWindow = new ModalWindow("xmlWindow"); add(xmlWindow); xmlWindow.setPageCreator(new ModalWindow.PageCreator() { public Page createPage() { return new PlainCodePage(xmlWindow, responseWindow, getRequestXML()); } }); // the output response window responseWindow = new ModalWindow("responseWindow"); add(responseWindow); responseWindow.setPageMapName("demoResponse"); responseWindow.setCookieName("demoResponse"); responseWindow.setPageCreator(new ModalWindow.PageCreator() { @SuppressWarnings("unchecked") public Page createPage() { DemoRequest request = new DemoRequest(null); HttpServletRequest http = ((WebRequest) WPSRequestBuilder.this.getRequest()) .getHttpServletRequest(); String url = ResponseUtils.buildURL(ResponseUtils.baseURL(http), "ows", Collections.singletonMap("strict", "true"), URLType.SERVICE); request.setRequestUrl(url); request.setRequestBody((String) responseWindow.getDefaultModelObject()); request.setUserName(builder.username); request.setPassword(builder.password); return new DemoRequestResponse(new Model(request)); } }); form.add(new AjaxSubmitLink("execute") { @SuppressWarnings("unchecked") @Override protected void onSubmit(AjaxRequestTarget target, Form form) { responseWindow.setDefaultModel(new Model(getRequestXML())); responseWindow.show(target); } @Override protected void onError(AjaxRequestTarget target, Form form) { super.onError(target, form); target.addComponent(builder.getFeedbackPanel()); } }); form.add(new AjaxSubmitLink("executeXML") { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { try { getRequestXML(); xmlWindow.show(target); } catch (Exception e) { error(e.getMessage()); target.addComponent(getFeedbackPanel()); } } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(getFeedbackPanel()); } }); }
From source file:org.geoserver.wps.web.WPSRequestBuilderPanel.java
License:Open Source License
/** * Creates a panel to display a process and its parameters. * Invoked with one of://from w w w . j av a 2 s.c o m * <ul> * <li>an empty executeRequest, which displays only the process dropdown * <li<an executeRequest with the processName set, which displays the process and parameters * </ul> * * @param id id of the panel * @param executeRequest execute request, possibly with processName set */ @SuppressWarnings({ "rawtypes", "unchecked" }) public WPSRequestBuilderPanel(String id, ExecuteRequest executeRequest) { super(id); setOutputMarkupId(true); this.execute = executeRequest; final DropDownChoice<String> processChoice = new DropDownChoice<String>("process", new PropertyModel<String>(execute, "processName"), buildProcessList()); add(processChoice); descriptionContainer = new WebMarkupContainer("descriptionContainer"); descriptionContainer.setVisible(false); add(descriptionContainer); // the process description final Label descriptionLabel = new Label("processDescription", new PropertyModel(this, "description")); descriptionContainer.add(descriptionLabel); // description value is set later in initProcessView() inputContainer = new WebMarkupContainer("inputContainer"); inputContainer.setVisible(false); add(inputContainer); inputView = new ListView<InputParameterValues>("inputs", new PropertyModel(execute, "inputs")) { @Override protected void populateItem(ListItem item) { InputParameterValues pv = (InputParameterValues) item.getModelObject(); Parameter p = pv.getParameter(); item.add(new Label("param", buildParamSpec(p))); item.add(new Label("paramDescription", p.description.toString(Locale.ENGLISH))); // TODO: roll out an extension point for these editors final PropertyModel property = new PropertyModel(pv, "values[0].value"); if (pv.isBoundingBox()) { EnvelopePanel envelope = new EnvelopePanel("paramValue", property); envelope.setCRSFieldVisible(true); item.add(envelope); } else if (pv.isCoordinateReferenceSystem()) { CRSPanel crs = new CRSPanel("paramValue", property); item.add(crs); } else if (pv.isEnum()) { EnumPanel panel = new EnumPanel("paramValue", ((Class<Enum>) pv.getParameter().type), property); item.add(panel); } else if (pv.isComplex()) { ComplexInputPanel input = new ComplexInputPanel("paramValue", pv, 0); item.add(input); } else { Fragment f = new Fragment("paramValue", "literal", WPSRequestBuilderPanel.this); FormComponent literal = new TextField("literalValue", property); literal.setRequired(p.minOccurs > 0); literal.setLabel(new Model<String>(p.key)); f.add(literal); item.add(f); } } }; inputView.setReuseItems(true); inputContainer.add(inputView); outputContainer = new WebMarkupContainer("outputContainer"); outputContainer.setVisible(false); add(outputContainer); outputView = new ListView("outputs", new PropertyModel(execute, "outputs")) { @Override protected void populateItem(ListItem item) { OutputParameter pv = (OutputParameter) item.getModelObject(); Parameter p = pv.getParameter(); item.add(new CheckBox("include", new PropertyModel<Boolean>(pv, "include"))); item.add(new Label("param", buildParamSpec(p))); item.add(new Label("paramDescription", p.description.toString(Locale.ENGLISH))); if (pv.isComplex()) { DropDownChoice mime = new DropDownChoice("mime", new PropertyModel(pv, "mimeType"), pv.getSupportedMime()); item.add(mime); } else { item.add(new Label("mime", "").setVisible(false)); // placeholder } } }; outputView.setReuseItems(true); outputContainer.add(outputView); // the output response window responseWindow = new ModalWindow("responseWindow"); add(responseWindow); responseWindow.setPageMapName("demoResponse"); responseWindow.setCookieName("demoResponse"); responseWindow.setPageCreator(new ModalWindow.PageCreator() { public Page createPage() { DemoRequest request = new DemoRequest(null); HttpServletRequest http = ((WebRequest) WPSRequestBuilderPanel.this.getRequest()) .getHttpServletRequest(); String url = ResponseUtils.buildURL(ResponseUtils.baseURL(http), "ows", Collections.singletonMap("strict", "true"), URLType.SERVICE); request.setRequestUrl(url); request.setRequestBody((String) responseWindow.getDefaultModelObject()); return new DemoRequestResponse(new Model<DemoRequest>(request)); } }); // the describe process link final GeoServerAjaxFormLink describeLink = new GeoServerAjaxFormLink("describeProcess") { @Override protected void onClick(AjaxRequestTarget target, Form form) { processChoice.processInput(); if (execute.processName != null) { responseWindow.setDefaultModel(new Model<String>(getDescribeXML(execute.processName))); responseWindow.show(target); } } }; descriptionContainer.add(describeLink); // the feedback panel, for validation errors feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true); add(feedback); // the process choice dropdown ajax behavior processChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { initProcessView(); target.addComponent(WPSRequestBuilderPanel.this); // ensure the parent page feedback panel gets refreshed to clear any existing err msg // check for GeoServerBasePage, because parent page can also be a SubProcessBuilder WebPage page = getWebPage(); if (page instanceof GeoServerBasePage) { target.addComponent(((GeoServerBasePage) page).getFeedbackPanel()); } } }); // handle process name submitted as request param if (execute.processName != null) initProcessView(); // username and password for authenticated requests final WebMarkupContainer authenticationContainer = new WebMarkupContainer("authenticationContainer"); authenticationContainer.setOutputMarkupId(true); add(authenticationContainer); final WebMarkupContainer userpwdContainer = new WebMarkupContainer("userpwdContainer"); userpwdContainer.setOutputMarkupId(true); userpwdContainer.setVisible(false); authenticationContainer.add(userpwdContainer); final TextField username = new TextField("username", new PropertyModel(this, "username")); userpwdContainer.add(username); final PasswordTextField password = new PasswordTextField("password", new PropertyModel(this, "password")); password.setRequired(false); userpwdContainer.add(password); CheckBox checkbox = new CheckBox("authenticate", new PropertyModel(this, "authenticate")); checkbox.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { userpwdContainer.setVisible(authenticate); target.addComponent(authenticationContainer); } }); authenticationContainer.add(checkbox); }
From source file:org.jaulp.wicket.data.provider.examples.refreshingview.ModalDialogWithStylePanel.java
License:Apache License
public ModalDialogWithStylePanel(String id) { super(id);// w w w. jav a2s . co 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.UploadPage.java
License:Apache License
public UploadPage(PageParameters parameters) { super(parameters); final ModalWindow uploadFileDialog = new ModalWindow("uploadFileDialog"); add(uploadFileDialog);//from ww w . jav a 2 s. c om final UploadFilePanel uploadFilePanel = new UploadFilePanel("content"); uploadFileDialog.setContent(uploadFilePanel); add(new AjaxLink<Void>("showUpdoadFileDialog") { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { uploadFileDialog.show(target); } }); }
From source file:org.jnotary.service.web.CRLPanel.java
License:Open Source License
private ModalWindow createModalWindow(final String windowName, final Long crlUrlId) { final ModalWindow modalWindow = new ModalWindow(windowName); modalWindow.setCookieName(windowName); modalWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new AddEditCrlUrlPage(crlUrlId, modalWindow); }//from w ww. j a va2 s. c o m }); modalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { wmc.setOutputMarkupId(true); initListData(); target.add(wmc); } }); modalWindow.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = 1L; public boolean onCloseButtonClicked(AjaxRequestTarget target) { return true; } }); return modalWindow; }
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()) { /**//ww w . j a v a 2 s . c o 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.quartz.core.wicket.layout.impl.simplified.SimplifiedOpenAnswerDefinitionPanel.java
License:Open Source License
/** * @param id/*from w ww . j a va2s . c om*/ * @param questionModel * @param questionCategoryModel * @param openAnswerDefinitionModel */ @SuppressWarnings("serial") public SimplifiedOpenAnswerDefinitionPanel(String id, IModel questionModel, IModel questionCategoryModel, IModel openAnswerDefinitionModel) { super(id, questionModel, questionCategoryModel, openAnswerDefinitionModel); setOutputMarkupId(true); updateState(); // make a clickable label with the current value. Label value = new Label("value", new PropertyModel(this, "openValue")); value.setOutputMarkupId(true).add(new QuestionCategorySelectionBehavior()); value.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget target) { padWindow.show(target); } }); add(value); add(new Label("label", getCategoryLabelResourceModel())); QuestionnaireStringResourceModel unitLabelModel = new QuestionnaireStringResourceModel( getOpenAnswerDefinitionModel(), "unitLabel"); add(new Label("unit", unitLabelModel).setVisible(StringUtils.hasLength(unitLabelModel.getString()))); AjaxImageLink link = new AjaxImageLink("link", new QuestionnaireStringResourceModel( activeQuestionnaireAdministrationService.getQuestionnaire(), "clickHere")) { @Override public void onClick(AjaxRequestTarget target) { padWindow.show(target); } }; link.getLink().add(new QuestionCategorySelectionBehavior()); link.getLink().add(new NoDragBehavior()); add(link); // Create modal window add(padWindow = new ModalWindow("padModal")); padWindow.setCssClassName("onyx"); padWindow.setInitialWidth(288); padWindow.setInitialHeight(365); padWindow.setResizable(false); final AbstractOpenAnswerDefinitionPanel pad = createPad(padWindow); padWindow.setContent(pad); // same as cancel padWindow.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { public boolean onCloseButtonClicked(AjaxRequestTarget target) { return true; } }); padWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { public void onClose(AjaxRequestTarget target) { // fire event to other selectors in case of exclusive choice IQuestionCategorySelectionListener listener = SimplifiedOpenAnswerDefinitionPanel.this .findParent(IQuestionCategorySelectionListener.class); if (listener != null) { listener.onQuestionCategorySelection(target, getQuestionModel(), getQuestionCategoryModel(), !isQuestionCategorySelected()); } target.addComponent(SimplifiedOpenAnswerDefinitionPanel.this); } }); }
From source file:org.obiba.onyx.quartz.editor.category.CategoryListPanel.java
License:Open Source License
public CategoryListPanel(String id, IModel<EditedQuestion> model, final IModel<Questionnaire> questionnaireModel, final IModel<LocaleProperties> localePropertiesModel, FeedbackPanel feedbackPanel, FeedbackWindow feedbackWindow, Panel parentPanel) { super(id, model); this.questionnaireModel = questionnaireModel; this.localePropertiesModel = localePropertiesModel; this.feedbackPanel = feedbackPanel; this.feedbackWindow = feedbackWindow; this.parentPanel = parentPanel; add(CSSPackageResource.getHeaderContribution(CategoryListPanel.class, "CategoryListPanel.css")); final Question question = model.getObject().getElement(); QuestionnaireFinder questionnaireFinder = QuestionnaireFinder.getInstance(questionnaireModel.getObject()); questionnaireModel.getObject().setQuestionnaireCache(null); questionsByCategory = questionnaireFinder.findQuestionsByCategory(); questionnaireCategories = new ArrayList<Category>(questionsByCategory.keySet()); Collections.sort(questionnaireCategories, new CategoryByQuestionsComparator(questionsByCategory)); categoryWindow = new ModalWindow("categoryWindow"); categoryWindow.setCssClassName("onyx"); categoryWindow.setInitialWidth(950); categoryWindow.setInitialHeight(550); categoryWindow.setResizable(true);/*from w ww.ja v a 2 s . c o m*/ categoryWindow.setTitle(new ResourceModel("Category")); add(categoryWindow); List<ITab> tabs = new ArrayList<ITab>(); tabs.add(new AbstractTab(new ResourceModel("Add.simple")) { @Override public Panel getPanel(String panelId) { return new SimpleAddPanel(panelId); } }); tabs.add(new AbstractTab(new ResourceModel("Add.bulk")) { @Override public Panel getPanel(String panelId) { return new BulkAddPanel(panelId); } }); tabs.add(new AbstractTab(new ResourceModel("Add.existing")) { @Override public Panel getPanel(String panelId) { return new AddExistingPanel(panelId); } }); add(new AjaxTabbedPanel("addTabs", tabs)); categoryList = new SortableList<QuestionCategory>("categories", question.getQuestionCategories()) { @Override public void onItemPopulation(QuestionCategory questionCategory) { } @Override public Component getItemTitle(@SuppressWarnings("hiding") String id, QuestionCategory questionCategory) { Category category = questionCategory.getCategory(); if (QuestionnaireSharedCategory.isSharedIfLink(questionCategory, questionnaireModel.getObject())) { StringBuilder sb = new StringBuilder(); for (Question q : questionsByCategory.get(category)) { if (q.getName().equals(question.getName())) continue; if (sb.length() > 0) sb.append(", "); sb.append(q.getName()); } String shared = " <span class=\"shared\">" + new StringResourceModel("sharedWith", CategoryListPanel.this, null, new Object[] { abbreviate(sb.toString(), 50) }).getString() + "</span>"; return new Label(id, category.getName() + shared).setEscapeModelStrings(false); } return new Label(id, category.getName()); } @Override public void editItem(final QuestionCategory questionCategory, AjaxRequestTarget target) { final ElementClone<QuestionCategory> original = QuestionnaireElementCloner.clone(questionCategory, new CloneSettings(true), localePropertiesModel.getObject()); categoryWindow .setContent(new CategoryWindow("content", new Model<QuestionCategory>(questionCategory), questionnaireModel, localePropertiesModel, categoryWindow) { @Override public void onSave(@SuppressWarnings("hiding") AjaxRequestTarget target, @SuppressWarnings("hiding") QuestionCategory questionCategory) { Collection<QuestionCategory> others = findOtherQuestionCategories( questionCategory.getCategory(), questionCategory); if (!others.isEmpty()) { LocaleProperties localeProperties = localePropertiesModel.getObject(); ListMultimap<Locale, KeyValue> elementLabelsQC = localeProperties .getElementLabels(questionCategory); for (QuestionCategory other : others) { localePropertiesUtils.load(localeProperties, questionnaireModel.getObject(), other); ListMultimap<Locale, KeyValue> elementLabelsOtherQC = localeProperties .getElementLabels(other); copyLabels(elementLabelsQC, elementLabelsOtherQC); } } } @Override public void onCancel(@SuppressWarnings("hiding") AjaxRequestTarget target, QuestionCategory questionCategory) { rollback(questionCategory, original); } }); categoryWindow.setCloseButtonCallback(new CloseButtonCallback() { @Override public boolean onCloseButtonClicked(@SuppressWarnings("hiding") AjaxRequestTarget target) { rollback(questionCategory, original); return true; } }); categoryWindow.setWindowClosedCallback(new WindowClosedCallback() { @Override public void onClose(@SuppressWarnings("hiding") AjaxRequestTarget target) { refreshList(target); refreshListAndNoAnswerPanel(categoryList, target); } }); categoryWindow.show(target); } @Override @SuppressWarnings("unchecked") public void deleteItem(QuestionCategory questionCategory, AjaxRequestTarget target) { ((IModel<EditedQuestion>) CategoryListPanel.this.getDefaultModel()).getObject().getElement() .getQuestionCategories().remove(questionCategory); localePropertiesModel.getObject().remove(questionnaireModel.getObject(), questionCategory); refreshListAndNoAnswerPanel(categoryList, target); } @Override public Button[] getButtons() { return null; } }; add(categoryList); }