List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setTitle
public ModalWindow setTitle(IModel<String> title)
From source file:org.dcm4chee.web.war.folder.StudyListPage.java
License:LGPL
private Link<Object> getStudyPermissionLink(final ModalWindow modalWindow, final AbstractEditableDicomModel model, TooltipBehaviour tooltip) { int[] winSize = WebCfgDelegate.getInstance().getWindowSize("studyPerm"); ModalWindowLink studyPermissionLink = new ModalWindowLink("studyPermissions", modalWindow, winSize[0], winSize[1]) {//from ww w . j a v a2s .c om private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (checkExists(model, target)) { modalWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; @Override public Page createPage() { return new StudyPermissionsPage(model); } }); modalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; @Override public void onClose(AjaxRequestTarget target) { updateStudyPermissions(); query(target); modalWindow.getPage().setOutputMarkupId(true); target.addComponent(modalWindow.getPage()); target.addComponent(header); } }); modalWindow.add(new ModalWindowLink.DisableDefaultConfirmBehavior()); modalWindow.setTitle(""); modalWindow.setCloseButtonCallback(null); modalWindow.show(target); } } @Override public boolean isVisible() { return studyPermissionHelper.isManageStudyPermissions() && model.getDataset() != null && !(model instanceof PatientModel && !((PatientModel) model).isExpandable()); } }; Image image = new Image("studyPermissionsImg", ImageManager.IMAGE_FOLDER_STUDY_PERMISSIONS); image.add(new ImageSizeBehaviour("vertical-align: middle;")); if (tooltip != null) image.add(tooltip); studyPermissionLink.add(image); return studyPermissionLink; }
From source file:org.dcm4chee.web.war.folder.webviewer.Webviewer.java
License:LGPL
private static AbstractLink getWebviewerSelectionPageLink(final AbstractDicomModel model, final WebviewerLinkProvider[] providers, final ModalWindow modalWindow, final WebviewerLinkClickedCallback callback) { log.debug("Use SelectionLINK for model:{}", model); if (modalWindow == null) { Link<Object> link = new Link<Object>(WEBVIEW_ID) { private static final long serialVersionUID = 1L; @Override//www . jav a 2 s . c om public void onClick() { setResponsePage(new WebviewerSelectionPage(model, providers, null, callback)); } }; link.setPopupSettings(new PopupSettings(PageMap.forName("webviewPage"), PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS)); return link; } else { int[] winSize = WebCfgDelegate.getInstance().getWindowSize("webviewer"); return new ModalWindowLink(WEBVIEW_ID, modalWindow, winSize[0], winSize[1]) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { modalWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; @Override public Page createPage() { return new WebviewerSelectionPage(model, providers, modalWindow, callback); } }); modalWindow.setTitle(""); modalWindow.show(target); } }; } }
From source file:org.dcm4chee.web.war.tc.TCResultPanel.java
License:LGPL
@SuppressWarnings("serial") public TCResultPanel(final String id, final TCListModel model, final IModel<Boolean> trainingModeModel) { super(id, model != null ? model : new TCListModel()); setOutputMarkupId(true);//from w ww .j a va2 s . com stPermHelper = StudyPermissionHelper.get(); initWebviewerLinkProvider(); add(msgWin); final ModalWindow modalWindow = new ModalWindow("modal-window"); add(modalWindow); final ModalWindow forumWindow = new ModalWindow("forum-window"); add(forumWindow); final TCStudyListPage studyPage = new TCStudyListPage(); final ModalWindow studyWindow = new ModalWindow("study-window"); studyWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return studyPage; } }); add(studyWindow); tclistProvider = new SortableTCListProvider((TCListModel) getDefaultModel()); final TCAttributeVisibilityStrategy attrVisibilityStrategy = new TCAttributeVisibilityStrategy( trainingModeModel); final DataView<TCModel> dataView = new DataView<TCModel>("row", tclistProvider) { private final StudyListLocal dao = (StudyListLocal) JNDIUtils.lookup(StudyListLocal.JNDI_NAME); private final Map<String, List<String>> studyActions = new HashMap<String, List<String>>(); @Override protected void populateItem(final Item<TCModel> item) { final TCModel tc = item.getModelObject(); final StringBuilder jsStopEventPropagationInline = new StringBuilder( "var event=arguments[0] || window.event; if (event.stopPropagation) {event.stopPropagation();} else {event.cancelBubble=True;};"); item.setOutputMarkupId(true); item.add(new TCMultiLineLabel("title", new AbstractReadOnlyModel<String>() { public String getObject() { if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.Title)) { return TCUtilities.getLocalizedString("tc.case.text") + " " + tc.getId(); } return tc.getTitle(); } }, new AutoClampSettings(40))); item.add(new TCMultiLineLabel("abstract", new AbstractReadOnlyModel<String>() { public String getObject() { if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.Abstract)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return tc.getAbstract(); } }, new AutoClampSettings(40))); item.add(new TCMultiLineLabel("author", new AbstractReadOnlyModel<String>() { public String getObject() { if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.AuthorName)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return tc.getAuthor(); } }, new AutoClampSettings(40))); item.add(new Label("date", new Model<Date>(tc.getCreationDate())) { private static final long serialVersionUID = 1L; @Override public IConverter getConverter(Class<?> type) { return new DateConverter() { private static final long serialVersionUID = 1L; @Override public DateFormat getDateFormat(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } return DateFormat.getDateInstance(DateFormat.MEDIUM, locale); } }; } }); final String stuid = tc.getStudyInstanceUID(); if (dao != null && !studyActions.containsKey(stuid)) { studyActions.put(stuid, dao.findStudyPermissionActions(stuid, stPermHelper.getDicomRoles())); } item.add(Webviewer.getLink(tc, webviewerLinkProviders, stPermHelper, new TooltipBehaviour("tc.result.table.", "webviewer"), modalWindow, new WebviewerLinkClickedCallback() { public void linkClicked(AjaxRequestTarget target) { TCAuditLog.logTFImagesViewed(tc); } }).add(new SecurityBehavior(TCPanel.getModuleName() + ":webviewerInstanceLink"))); final Component viewLink = new IndicatingAjaxLink<String>("tc-view") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { selectTC(item, tc, target); openTC(tc, false, target); } protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcViewImg", ImageManager.IMAGE_COMMON_DICOM_DETAILS) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "view")).setOutputMarkupId(true); final Component editLink = new IndicatingAjaxLink<String>("tc-edit") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { selectTC(item, tc, target); openTC(tc, true, target); } protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcEditImg", ImageManager.IMAGE_COMMON_DICOM_EDIT) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "edit")) .add(new SecurityBehavior(TCPanel.getModuleName() + ":editTC")).setOutputMarkupId(true); final Component studyLink = new IndicatingAjaxLink<String>("tc-study") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { selectTC(item, tc, target); try { TCObject tcObject = TCObject.create(tc); List<TCReferencedStudy> refStudies = tcObject.getReferencedStudies(); if (refStudies != null && !refStudies.isEmpty()) { if (refStudies.size() == 1) { studyPage.setStudyInstanceUID(refStudies.get(0).getStudyUID()); } else { studyPage.setPatientIdAndIssuer(tc.getPatientId(), tc.getIssuerOfPatientId()); } } if (studyPage.getStudyInstanceUID() != null || studyPage.getPatientId() != null) { studyPage.getStudyViewPort().clear(); studyWindow .setTitle(new StringResourceModel("tc.result.studywindow.title", this, null, new Object[] { maskNull(cutAtISOControl(tc.getTitle(), 40), "?"), maskNull(cutAtISOControl(tc.getAbstract(), 25), "?"), maskNull(cutAtISOControl(tc.getAuthor(), 20), "?"), maskNull(tc.getCreationDate(), tc.getCreatedTime()) })); studyWindow.setInitialWidth(1200); studyWindow.setInitialHeight(600); studyWindow.setMinimalWidth(800); studyWindow.setMinimalHeight(400); if (studyWindow.isShown()) { log.warn("###### StudyView is already shown ???!!!"); try { Field showField = ModalWindow.class.getDeclaredField("shown"); showField.setAccessible(true); showField.set(studyWindow, false); } catch (Exception e) { log.error("Failed to reset shown Field from ModalWindow!"); } log.info("###### studyWindow.isShown():" + studyWindow.isShown()); } studyWindow.show(target); } else { log.warn("Showing TC referenced studies discarded: No referened study found!"); msgWin.setInfoMessage(getString("tc.result.studywindow.noStudies")); msgWin.show(target); } } catch (Exception e) { msgWin.setErrorMessage(getString("tc.result.studywindow.failed")); msgWin.show(target); log.error("Unable to show TC referenced studies!", e); } } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcStudyImg", ImageManager.IMAGE_COMMON_SEARCH) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "showStudy")) .add(new SecurityBehavior(TCPanel.getModuleName() + ":showTCStudy")) .setOutputMarkupId(true); final Component forumLink = new IndicatingAjaxLink<String>("tc-forum") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { TCForumPostsPanel content = new TCForumPostsPanel(forumWindow.getContentId(), new Model<String>(TCForumIntegration .get(WebCfgDelegate.getInstance().getTCForumIntegrationType()) .getPostsPageURL(tc))); forumWindow.setInitialHeight(820); forumWindow.setInitialWidth(1024); forumWindow.setContent(content); forumWindow.show(target); } catch (Exception e) { log.error("Unable to open case forum page!", e); } } @Override public boolean isVisible() { return TCForumIntegration .get(WebCfgDelegate.getInstance().getTCForumIntegrationType()) != null; } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcForumImg", ImageManager.IMAGE_TC_FORUM) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "showForum")).setOutputMarkupId(true); item.add(viewLink); item.add(editLink); item.add(studyLink); item.add(forumLink); item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (selected != null && selected.equals(tc)) { return "mouse-out-selected"; } else { return item.getIndex() % 2 == 1 ? "even-mouse-out" : "odd-mouse-out"; } } })); item.add(new AttributeModifier("selected", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (selected != null && selected.equals(tc)) { return "selected"; } else { return null; } } })); item.add(new AttributeModifier("onmouseover", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { StringBuffer sbuf = new StringBuffer(); sbuf.append("if ($(this).attr('selected')==null) {"); sbuf.append(" $(this).removeClass();"); sbuf.append(" if (").append(item.getIndex()) .append("%2==1) $(this).addClass('even-mouse-over');"); sbuf.append(" else $(this).addClass('odd-mouse-over');"); sbuf.append("}"); return sbuf.toString(); } })); item.add(new AttributeModifier("onmouseout", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { StringBuffer sbuf = new StringBuffer(); sbuf.append("if ($(this).attr('selected')==null) {"); sbuf.append(" $(this).removeClass();"); sbuf.append(" if (").append(item.getIndex()) .append("%2==1) $(this).addClass('even-mouse-out');"); sbuf.append(" else $(this).addClass('odd-mouse-out');"); sbuf.append("}"); return sbuf.toString(); } })); item.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { selectTC(item, tc, target); } }); item.add(new AjaxEventBehavior("ondblclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { boolean edit = WebCfgDelegate.getInstance().getTCEditOnDoubleClick(); if (edit) { edit = SecureComponentHelper.isActionAuthorized(editLink, "render"); } openTC(selected, edit, target); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return new IAjaxCallDecorator() { private static final long serialVersionUID = 1L; public final CharSequence decorateScript(CharSequence script) { return "if(typeof showMask == 'function') { showMask(); $('body').css('cursor','wait'); };" + script; } public final CharSequence decorateOnSuccessScript(CharSequence script) { return "hideMask();$('body').css('cursor','');" + script; } public final CharSequence decorateOnFailureScript(CharSequence script) { return "hideMask();$('body').css('cursor','');" + script; } }; } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }); } }; dataView.setItemReuseStrategy(new ReuseIfModelsEqualStrategy()); dataView.setItemsPerPage(WebCfgDelegate.getInstance().getDefaultFolderPagesize()); dataView.setOutputMarkupId(true); SortLinkGroup sortGroup = new SortLinkGroup(dataView); add(new SortLink("sortTitle", sortGroup, TCModel.Sorter.Title)); add(new SortLink("sortAbstract", sortGroup, TCModel.Sorter.Abstract)); add(new SortLink("sortDate", sortGroup, TCModel.Sorter.Date)); add(new SortLink("sortAuthor", sortGroup, TCModel.Sorter.Author)); add(dataView); add(new Label("numberOfMatchingInstances", new StringResourceModel("tc.list.numberOfMatchingInstances", this, null, new Object[] { new Model<Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getObject() { return ((TCListModel) TCResultPanel.this.getDefaultModel()).getObject().size(); } } }))); add(new PagingNavigator("navigator", dataView)); }
From source file:org.geoserver.community.css.web.CssDemoPage.java
License:Open Source License
private void doMainLayout() { final Fragment mainContent = new Fragment("main-content", "normal", this); final ModalWindow popup = new ModalWindow("popup"); mainContent.add(popup);/* w w w.ja va2s. c om*/ final StyleNameModel styleNameModel = new StyleNameModel(style); final PropertyModel layerNameModel = new PropertyModel(layer, "prefixedName"); mainContent.add(new AjaxLink("create.style", new ParamResourceModel("CssDemoPage.createStyle", this)) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(200); popup.setInitialWidth(300); popup.setTitle(new Model("Choose name for new style")); popup.setContent(new StyleNameInput(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); mainContent.add(new SimpleAjaxLink("change.style", styleNameModel) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(400); popup.setInitialWidth(600); popup.setTitle(new Model("Choose style to edit")); popup.setContent(new StyleChooser(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); mainContent.add(new SimpleAjaxLink("change.layer", layerNameModel) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(400); popup.setInitialWidth(600); popup.setTitle(new Model("Choose layer to edit")); popup.setContent(new LayerChooser(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); mainContent .add(new AjaxLink("associate.styles", new ParamResourceModel("CssDemoPage.associateStyles", this)) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(400); popup.setInitialWidth(600); popup.setTitle(new Model("Choose layers to associate")); popup.setContent(new MultipleLayerChooser(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); ParamResourceModel associateToLayer = new ParamResourceModel("CssDemoPage.associateDefaultStyle", this, styleNameModel, layerNameModel); final SimpleAjaxLink associateDefaultStyle = new SimpleAjaxLink("associate.default.style", new Model(), associateToLayer) { public void onClick(final AjaxRequestTarget linkTarget) { final Component theComponent = this; dialog.setResizable(false); dialog.setHeightUnit("em"); dialog.setWidthUnit("em"); dialog.setInitialHeight(7); dialog.setInitialWidth(50); dialog.showOkCancel(linkTarget, new DialogDelegate() { boolean success = false; @Override protected boolean onSubmit(AjaxRequestTarget target, Component contents) { layer.setDefaultStyle(style); getCatalog().save(layer); theComponent.setEnabled(false); success = true; return true; } @Override public void onClose(AjaxRequestTarget target) { super.onClose(target); target.addComponent(theComponent); if (success) { CssDemoPage.this.info(new ParamResourceModel("CssDemoPage.styleAssociated", CssDemoPage.this, styleNameModel, layerNameModel).getString()); target.addComponent(getFeedbackPanel()); } } @Override protected Component getContents(String id) { ParamResourceModel confirm = new ParamResourceModel("CssDemoPage.confirmAssocation", CssDemoPage.this, styleNameModel.getObject(), layerNameModel.getObject(), layer.getDefaultStyle().getName()); return new Label(id, confirm); } }); } }; associateDefaultStyle.setOutputMarkupId(true); if (layer.getDefaultStyle().equals(style)) { associateDefaultStyle.setEnabled(false); } mainContent.add(associateDefaultStyle); final IModel<String> sldModel = new AbstractReadOnlyModel<String>() { public String getObject() { try { // if file already in css format transform to sld, otherwise load the SLD file if (CssHandler.FORMAT.equals(style.getFormat())) { StyledLayerDescriptor sld = Styles.sld(style.getStyle()); return Styles.string(sld, new SLDHandler(), SLDHandler.VERSION_10, true); } else { File file = findStyleFile(style); if (file != null && file.isFile()) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); StringBuilder builder = new StringBuilder(); char[] line = new char[4096]; int len = 0; while ((len = reader.read(line, 0, 4096)) >= 0) builder.append(line, 0, len); return builder.toString(); } finally { if (reader != null) reader.close(); } } else { return "No SLD file found for this style. One will be generated automatically if you save the CSS."; } } } catch (IOException e) { throw new WicketRuntimeException(e); } } }; final CompoundPropertyModel model = new CompoundPropertyModel<CssDemoPage>(CssDemoPage.this); List<ITab> tabs = new ArrayList<ITab>(); tabs.add(new PanelCachingTab(new AbstractTab(new Model("Generated SLD")) { public Panel getPanel(String id) { SLDPreviewPanel panel = new SLDPreviewPanel(id, sldModel); sldPreview = panel.getLabel(); return panel; } })); tabs.add(new PanelCachingTab(new AbstractTab(new Model("Map")) { public Panel getPanel(String id) { return map = new OpenLayersMapPanel(id, layer, style); } })); if (layer.getResource() instanceof FeatureTypeInfo) { tabs.add(new PanelCachingTab(new AbstractTab(new Model("Data")) { public Panel getPanel(String id) { try { return new DataPanel(id, model, (FeatureTypeInfo) layer.getResource()); } catch (IOException e) { throw new WicketRuntimeException(e); } }; })); } else if (layer.getResource() instanceof CoverageInfo) { tabs.add(new PanelCachingTab(new AbstractTab(new Model("Data")) { public Panel getPanel(String id) { return new BandsPanel(id, (CoverageInfo) layer.getResource()); }; })); } tabs.add(new AbstractTab(new Model("CSS Reference")) { public Panel getPanel(String id) { return new DocsPanel(id); } }); File sldFile = findStyleFile(style); File cssFile = new File(sldFile.getParentFile(), style.getName() + ".css"); mainContent.add(new StylePanel("style.editing", model, CssDemoPage.this, cssFile)); mainContent.add(new AjaxTabbedPanel("context", tabs)); add(mainContent); add(dialog = new GeoServerDialog("dialog")); }
From source file:org.geoserver.qos.web.LayersListModalBuilder.java
License:Open Source License
@Override public WebMarkupContainer build(WebMarkupContainer mainDiv, ModalWindow modalWindow, IModel<LimitedAreaRequestConstraints> model) { WebMarkupContainer layersDiv = new WebMarkupContainer("layersDiv"); layersDiv.setOutputMarkupId(true);// w w w . ja v a 2s .com mainDiv.add(layersDiv); final ListView<String> layersListView = new ListView<String>("layersList", new PropertyModel<>(model, "layerNames")) { @Override protected void populateItem(ListItem<String> item) { TextField<String> layerField = new TextField<>("layerName", item.getModel()); layerField.setEnabled(false); item.add(layerField); AjaxSubmitLink deleteLayerLink = new AjaxSubmitLink("deleteLayer") { @Override protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) { super.onAfterSubmit(target, form); model.getObject().getLayerNames().remove(item.getModel().getObject()); target.add(mainDiv); } }; item.add(deleteLayerLink); } }; layersDiv.add(layersListView); final AjaxLink addLayerLink = new AjaxLink("addLayer") { @Override public void onClick(AjaxRequestTarget target) { modalWindow.setInitialHeight(375); modalWindow.setInitialWidth(525); modalWindow.setTitle("Choose layer"); WorkspaceInfo wsi = mainDiv.findParent(QosWmsAdminPanel.class).getMainModel().getObject() .getWorkspace(); modalWindow.setContent(new LayerListPanel(modalWindow.getContentId(), wsi) { @Override protected void handleLayer(org.geoserver.catalog.LayerInfo layer, AjaxRequestTarget target) { if (!model.getObject().getLayerNames().contains(model.getObject().getLayerNames())) { model.getObject().getLayerNames().add(layer.prefixedName()); } modalWindow.close(target); target.add(mainDiv); }; }); modalWindow.show(target); } }; layersDiv.add(addLayerLink); return layersDiv; }
From source file:org.geoserver.qos.web.TypesListBuilder.java
License:Open Source License
@Override public WebMarkupContainer build(WebMarkupContainer mainDiv, ModalWindow modalWindow, IModel<WfsAdHocQueryConstraints> model) { WebMarkupContainer layersDiv = new WebMarkupContainer("layersDiv"); layersDiv.setOutputMarkupId(true);// w w w . j a v a 2s . c om mainDiv.add(layersDiv); final ListView<String> layersListView = new ListView<String>("layersList", new PropertyModel<>(model, "typeNames")) { @Override protected void populateItem(ListItem<String> item) { TextField<String> layerField = new TextField<>("layerName", item.getModel()); layerField.setEnabled(false); item.add(layerField); AjaxSubmitLink deleteLayerLink = new AjaxSubmitLink("deleteLayer") { @Override protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) { super.onAfterSubmit(target, form); model.getObject().getTypeNames().remove(item.getModel().getObject()); target.add(mainDiv); } }; item.add(deleteLayerLink); } }; layersDiv.add(layersListView); // Autocomplete add to list: // final AutoCompleteTextField<String> addTypeNameField = // new AutoCompleteTextField<String>("addTypeNameField", new // PropertyModel<>(typeToAdd, "value")) { // @Override // protected Iterator<String> getChoices(String arg0) { // return null; // } // }; final AjaxLink addLayerLink = new AjaxLink("addLayer") { @Override public void onClick(AjaxRequestTarget target) { WorkspaceInfo wsi = mainDiv.findParent(QosWfsAdminPanel.class).getMainModel().getObject() .getWorkspace(); modalWindow.setInitialHeight(375); modalWindow.setInitialWidth(525); modalWindow.setTitle("Choose layer"); modalWindow.setContent(new LayerListPanel(modalWindow.getContentId(), wsi) { @Override protected void handleLayer(org.geoserver.catalog.LayerInfo layer, AjaxRequestTarget target) { if (model.getObject().getTypeNames() == null) { model.getObject().setTypeNames(new ArrayList<>()); } if (!model.getObject().getTypeNames().contains(layer.prefixedName())) { model.getObject().getTypeNames().add(layer.prefixedName()); } modalWindow.close(target); target.add(mainDiv); }; }); modalWindow.show(target); } }; layersDiv.add(addLayerLink); return layersDiv; }
From source file:org.geoserver.solr.SolrConfigurationPanel.java
License:Open Source License
/** * Adds SOLR configuration panel link, configure modal dialog and implements modal callback * /*from w w w .jav a 2 s . c o m*/ * @see {@link SolrConfigurationPage#done} */ public SolrConfigurationPanel(final String panelId, final IModel model) { super(panelId, model); final FeatureTypeInfo fti = (FeatureTypeInfo) model.getObject(); final ModalWindow modal = new ModalWindow("modal"); modal.setInitialWidth(800); modal.setTitle(new ParamResourceModel("modalTitle", SolrConfigurationPanel.this)); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { @Override public void onClose(AjaxRequestTarget target) { if (_layerInfo != null) { GeoServerApplication app = (GeoServerApplication) getApplication(); FeatureTypeInfo ft = (FeatureTypeInfo) getResourceInfo(); //Override _isNew state, based on resource informations into catalog if (ft.getId() != null && app.getCatalog().getResource(ft.getId(), ResourceInfo.class) != null) { _isNew = false; } else { _isNew = true; } app.getCatalog().getResourcePool().clear(ft); app.getCatalog().getResourcePool().clear(ft.getStore()); setResponsePage(new ResourceConfigurationPage(_layerInfo, _isNew)); } } }); if (fti.getId() == null) { modal.add(new OpenWindowOnLoadBehavior()); } modal.setContent(new SolrConfigurationPage(panelId, model) { @Override void done(AjaxRequestTarget target, ResourceInfo resource) { ResourceConfigurationPage page = (ResourceConfigurationPage) SolrConfigurationPanel.this.getPage(); page.updateResource(resource, target); modal.close(target); } }); add(modal); AjaxLink findLink = new AjaxLink("edit") { @Override public void onClick(AjaxRequestTarget target) { modal.show(target); } }; final Fragment attributePanel = new Fragment("solrPanel", "solrPanelFragment", this); attributePanel.setOutputMarkupId(true); add(attributePanel); attributePanel.add(findLink); }
From source file:org.geoserver.web.data.layergroup.RootLayerEntryPanel.java
License:Open Source License
@SuppressWarnings({ "rawtypes" }) public RootLayerEntryPanel(String id, final Form form, WorkspaceInfo workspace) { super(id);/*w w w .j a v a 2 s . com*/ setOutputMarkupId(true); final TextField<LayerInfo> rootLayerField = new TextField<LayerInfo>("rootLayer") { @Override public IConverter getConverter(Class<?> type) { return form.getConverter(type); } }; rootLayerField.setOutputMarkupId(true); rootLayerField.setRequired(true); add(rootLayerField); // global styles List<StyleInfo> globalStyles = new ArrayList<StyleInfo>(); List<StyleInfo> allStyles = GeoServerApplication.get().getCatalog().getStyles(); for (StyleInfo s : allStyles) { if (s.getWorkspace() == null) { globalStyles.add(s); } } // available styles List<StyleInfo> styles = new ArrayList<StyleInfo>(); styles.addAll(globalStyles); if (workspace != null) { styles.addAll(GeoServerApplication.get().getCatalog().getStylesByWorkspace(workspace)); } DropDownChoice<StyleInfo> styleField = new DropDownChoice<StyleInfo>("rootLayerStyle", styles) { @Override public IConverter getConverter(Class<?> type) { return form.getConverter(type); } }; styleField.setNullValid(true); add(styleField); final ModalWindow popupWindow = new ModalWindow("popup"); add(popupWindow); add(new AjaxLink("add") { @Override public void onClick(AjaxRequestTarget target) { popupWindow.setInitialHeight(375); popupWindow.setInitialWidth(525); popupWindow.setTitle(new ParamResourceModel("chooseLayer", this)); popupWindow.setContent(new LayerListPanel(popupWindow.getContentId()) { @Override protected void handleLayer(LayerInfo layer, AjaxRequestTarget target) { popupWindow.close(target); ((LayerGroupInfo) form.getModelObject()).setRootLayer(layer); target.addComponent(rootLayerField); } }); popupWindow.show(target); } }); }
From source file:org.geoserver.wms.web.data.LayerAttributePanel.java
License:Open Source License
public LayerAttributePanel(String id, AbstractStylePage parent) throws IOException { super(id, parent); //Change layer link PropertyModel<String> layerNameModel = new PropertyModel<String>(parent.getLayerModel(), "prefixedName"); add(new SimpleAjaxLink<String>("changeLayer", layerNameModel) { private static final long serialVersionUID = 7341058018479354596L; public void onClick(AjaxRequestTarget target) { ModalWindow popup = parent.getPopup(); popup.setInitialHeight(400); popup.setInitialWidth(600);// w w w . ja v a2s . co m popup.setTitle(new Model<String>("Choose layer to edit")); popup.setContent(new LayerChooser(popup.getContentId(), parent)); popup.show(target); } }); this.setDefaultModel(parent.getLayerModel()); updateAttributePanel(); }
From source file:org.geoserver.wms.web.data.OpenLayersPreviewPanel.java
License:Open Source License
public OpenLayersPreviewPanel(String id, AbstractStylePage parent) { super(id, parent); this.olPreview = new WebMarkupContainer("olPreview").setOutputMarkupId(true); // Change layer link PropertyModel<String> layerNameModel = new PropertyModel<String>(parent.getLayerModel(), "prefixedName"); add(new SimpleAjaxLink<String>("change.layer", layerNameModel) { private static final long serialVersionUID = 7341058018479354596L; public void onClick(AjaxRequestTarget target) { ModalWindow popup = parent.getPopup(); popup.setInitialHeight(400); popup.setInitialWidth(600);//from w ww. j av a 2s .co m popup.setTitle(new Model<String>("Choose layer to edit")); popup.setContent(new LayerChooser(popup.getContentId(), parent)); popup.show(target); } }); add(olPreview); setOutputMarkupId(true); try { ensureLegendDecoration(); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to put legend layout file in the data directory, the legend decoration will not appear", e); } }