List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow show
public void show(final IPartialPageRequestHandler target)
From source file:org.devgateway.eudevfin.projects.module.components.panels.TransactionTableListPanel.java
@Override protected void populateTable() { final ModalWindow modal = AddModalWindow(null); // refreshItems(); this.itemsListView = new ListView<FinancialTransaction>("projectTransactionsList", items) { private static final long serialVersionUID = -8758662617501215830L; @Override/*from w w w . ja va 2 s .c o m*/ protected void populateItem(ListItem<FinancialTransaction> listItem) { final FinancialTransaction transaction = listItem.getModelObject(); AjaxLink linkToEdit = new AjaxLink("linkToEditTransaction") { @Override public void onClick(AjaxRequestTarget target) { PageParameters parameters = new PageParameters() .add(TransactionsTableModal.PARAM_TRANSACTION_ID, transaction.getId()); setParameters(parameters); AddModalWindow(parameters); modal.show(target); } }; linkToEdit.setBody(Model.of(transaction.getShortDescription())); String CRSId = transaction.getCrsIdentificationNumber() == null ? "" : transaction.getCrsIdentificationNumber(); Label CRSIdLabel = new Label("CRSId", CRSId); String geographicName = transaction.getRecipient() == null ? "" : transaction.getRecipient().getName(); Label geographicFocusLabel = new Label("geographicFocus", geographicName); String agencyName = transaction.getExtendingAgency() == null ? "" : transaction.getExtendingAgency().getName(); Label financingInstitutionLabel = new Label("financingInstitution", agencyName); Label reportingYearLabel = new Label("reportingYear", transaction.getReportingYear().getYear()); final CustomFinancialTransaction ctx = (CustomFinancialTransaction) transaction; Label amountUSD = new Label("amountUSD", RateUtil.moneyToString(rateUtil.exchange(transaction.getAmountsExtended(), CurrencyUnit.USD, ctx.getFixedRate(), RateUtil.getStartOfMonth(ctx.getCommitmentDate())))); Label amountRON = new Label("amountRON", transaction.getAmountsExtended().getAmount().toString()); Label amountEUR = new Label("amountEUR", RateUtil.moneyToString(rateUtil.exchange(transaction.getAmountsExtended(), CurrencyUnit.EUR, ctx.getFixedRate(), RateUtil.getStartOfMonth(ctx.getCommitmentDate())))); BootstrapDeleteButton delete = new BootstrapDeleteButton("delete", new StringResourceModel("delete", this, null)) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { NewProjectPage.project.removeTransaction(transaction); TransactionTableListPanel newComp = new TransactionTableListPanel(WICKETID_LIST_PANEL, new ProjectTransactionsListGenerator( NewProjectPage.project.getProjectTransactions())); newComp.add(new AttributeAppender("class", "budget-table")); TransactionTableListPanel.this.replaceWith(newComp); target.add(newComp); } }; delete.add(AttributeModifier.remove("class")); delete.add(AttributeModifier.prepend("class", "round_delete")); listItem.add(linkToEdit); listItem.add(CRSIdLabel); listItem.add(geographicFocusLabel); listItem.add(financingInstitutionLabel); listItem.add(reportingYearLabel); listItem.add(amountUSD); listItem.add(amountRON); listItem.add(amountEUR); listItem.add(delete); } }; itemsListView.setOutputMarkupId(true); this.add(modal); this.add(itemsListView); }
From source file:org.devgateway.eudevfin.projects.module.components.tabs.ReportingTab.java
public ReportingTab(String id, PageParameters parameters) { super(id);/*w w w.ja va 2s . c om*/ Label tabDescription = new Label("reportsDescription", new StringResourceModel("reportsDescription", this, null, null)); add(tabDescription); reportTableListPanel = new ReportsTableListPanel(WICKETID_LIST_PANEL, new ProjectReportsListGenerator(NewProjectPage.project.getProjectReports())); add(reportTableListPanel); final ModalWindow modal = AddModalWindow(parameters); add(modal); BootstrapSubmitButton submitButton = new BootstrapSubmitButton("addReport", new StringResourceModel("button.addReport", this, null)) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { modal.show(target); } }; submitButton.setDefaultFormProcessing(false); add(submitButton); }
From source file:org.devgateway.eudevfin.projects.module.components.tabs.ResultsTab.java
public ResultsTab(String id, PageParameters parameters) { super(id);/*from w w w . j a va 2 s . c om*/ Label tabDescription = new Label("resultsDescription", new StringResourceModel("resultsDescription", this, null, null)); add(tabDescription); resultTableListPanel = new ResultsTableListPanel(WICKETID_LIST_PANEL, new ProjectResultsListGenerator(NewProjectPage.project.getProjectResults())); add(resultTableListPanel); final ModalWindow modal = AddModalWindow(parameters); add(modal); BootstrapSubmitButton submitButton = new BootstrapSubmitButton("addResult", new StringResourceModel("button.addResult", this, null)) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { modal.show(target); } }; MetaDataRoleAuthorizationStrategy.authorize(submitButton, Component.ENABLE, AuthConstants.Roles.ROLE_PROJECTS_MFA); MetaDataRoleAuthorizationStrategy.authorize(submitButton, Component.ENABLE, AuthConstants.Roles.ROLE_SUPERVISOR); submitButton.setDefaultFormProcessing(false); add(submitButton); }
From source file:org.devgateway.eudevfin.projects.module.components.tabs.TransactionsTab.java
public TransactionsTab(String id, PageParameters parameters) { super(id);/*from w w w . ja va2s . c o m*/ Label tabDescription = new Label("budgetDescription", new StringResourceModel("budgetDescription", this, null, null)); add(tabDescription); transactionTableListPanel = new TransactionTableListPanel(WICKETID_LIST_PANEL, new ProjectTransactionsListGenerator(NewProjectPage.project.getProjectTransactions())); transactionTableListPanel.add(new AttributeAppender("class", "budget-table")); add(transactionTableListPanel); final ModalWindow modal = AddModalWindow(parameters); add(modal); BootstrapSubmitButton submitButton = new BootstrapSubmitButton("addTransaction", new StringResourceModel("button.addTransaction", this, null)) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { modal.show(target); } }; submitButton.setDefaultFormProcessing(false); add(submitButton); //todo: cast to transaction file wrapper MultiProjectFileUploadField transactionDocumentation = new MultiProjectFileUploadField( "transactionDocumentation", new RWComponentPropertyModel<Collection<ProjectFileWrapper>>("projectFiles")); transactionDocumentation.setProjectFileType(ProjectFileType.TRANSACTION); transactionDocumentation.maxFiles(10); transactionDocumentation.add(new AttributeAppender("class", "remove-left-margin")); add(transactionDocumentation); }
From source file:org.efaps.ui.wicket.components.bpm.process.ActionPanel.java
License:Apache License
/** * @param _wicketID component id/*ww w . j a va2 s . c o m*/ * @param _model model for contact * @param _pageReference reference to the calling page */ public ActionPanel(final String _wicketID, final IModel<UIProcessInstanceLog> _model, final PageReference _pageReference) { super(_wicketID, _model); final ModalWindow modal = new AbstractModalWindow("modal", _model) { private static final long serialVersionUID = 1L; }.setInitialWidth(200).setInitialHeight(100); this.add(modal); final AjaxLink<UIProcessInstanceLog> select = new AjaxLink<UIProcessInstanceLog>("select", _model) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget _target) { final UIProcessInstanceLog processinstance = (UIProcessInstanceLog) getDefaultModelObject(); if (processinstance != null) { getPage().visitChildren(AjaxFallbackDefaultDataTable.class, new IVisitor<AjaxFallbackDefaultDataTable<?, ?>, Void>() { @Override public void component(final AjaxFallbackDefaultDataTable<?, ?> _table, final IVisit<Void> _visit) { final IDataProvider<?> provider = _table.getDataProvider(); if (provider instanceof NodeInstanceProvider) { ((NodeInstanceProvider) provider) .setProcessInstanceId(processinstance.getProcessInstanceId()); ((NodeInstanceProvider) provider).requery(); _target.add(_table); } else if (provider instanceof VariableInstanceProvider) { ((VariableInstanceProvider) provider) .setProcessInstanceId(processinstance.getProcessInstanceId()); ((VariableInstanceProvider) provider).requery(); _target.add(_table); } } }); } } }; add(select); final AjaxLink<UIProcessInstanceLog> abort = new AjaxLink<UIProcessInstanceLog>("abort", _model) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget _target) { modal.setContent(new AjaxButton<UIProcessInstanceLog>(modal.getContentId(), _model, Button.ICON.ACCEPT.getReference(), "OK") { private static final long serialVersionUID = 1L; @Override public void onSubmit(final AjaxRequestTarget _target) { final UIProcessInstanceLog processinstance = (UIProcessInstanceLog) getDefaultModelObject(); BPM.abortProcessInstance(processinstance.getProcessInstanceId()); modal.close(_target); } }); modal.show(_target); } }; add(abort); }
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);//from w ww . ja va 2s .c o m 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);/* www . j av a2 s . 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);/*from w w w .j a va2 s . c o m*/ 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 . java 2 s.c om * @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.wcs.web.demo.WCSRequestBuilder.java
License:Open Source License
public WCSRequestBuilder() { // the form//ww w. j a v a 2s. c o m Form form = new Form("form"); add(form); // the actual request builder component builder = new WCSRequestBuilderPanel("requestBuilder", new GetCoverageRequest()); 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() { public Page createPage() { DemoRequest request = new DemoRequest(null); HttpServletRequest http = ((WebRequest) WCSRequestBuilder.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(request)); } }); form.add(new AjaxSubmitLink("execute") { @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()); } }); }