Mercurial > dive4elements > river
changeset 6547:455876ac5914
Merged
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 08 Jul 2013 14:50:59 +0200 |
parents | 7106f9b75004 (diff) a4f60641e445 (current diff) |
children | 9987c5a8154a |
files | |
diffstat | 5 files changed, 48 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java Mon Jul 08 14:06:44 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java Mon Jul 08 14:50:59 2013 +0200 @@ -21,6 +21,7 @@ import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.layout.HLayout; import org.dive4elements.river.client.client.Config; @@ -137,7 +138,13 @@ public void onClick(ClickEvent event) { GWT.log("Clicked 'info' button."); String wikiLink = Config.getInstance().getWikiUrl() + "/Info"; - Window.open(wikiLink, "_blank", null); + + // Create a dynamic form which contains the SAML session + // for the user which is currently logged in + DynamicForm df = WikiLinks.dynamicForm(getFlys(), wikiLink); + info.addChild(df); // add the form somewhere + df.submitForm(); // submit the form to go to the wiki + info.removeChild(df); // and remove the dynamic form } }); init();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Mon Jul 08 14:06:44 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Mon Jul 08 14:50:59 2013 +0200 @@ -99,7 +99,7 @@ MSG.gauge_river_url() + number : MSG.gauge_river_url(); String wikiBaseUrl = Config.getInstance().getWikiUrl(); - DynamicForm infoLink = WikiLinks.linkHTML(this.flys, wikiBaseUrl + url, + DynamicForm infoLink = WikiLinks.linkDynamicForm(this.flys, wikiBaseUrl + url, MSG.gauge_river_info_link()); infoLink.setTop(5); LinkItem item = (LinkItem)infoLink.getField("saml");
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java Mon Jul 08 14:06:44 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java Mon Jul 08 14:50:59 2013 +0200 @@ -24,7 +24,7 @@ @Override protected void update() { - setContents(WikiLinks.imageLinkHTML(instance, href, imgUrl)); + setContents(WikiLinks.imageLinkForm(instance, href, imgUrl)); setWidth(width); setHeight(height); setOverflow(Overflow.VISIBLE);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Mon Jul 08 14:06:44 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Mon Jul 08 14:50:59 2013 +0200 @@ -8,18 +8,21 @@ package org.dive4elements.river.client.client.ui; +import com.google.gwt.core.client.GWT; +import com.google.gwt.safehtml.shared.SafeHtmlUtils; import com.smartgwt.client.types.FormMethod; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.HiddenItem; import com.smartgwt.client.widgets.form.fields.LinkItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; -import com.google.gwt.safehtml.shared.SafeHtmlUtils; import org.dive4elements.river.client.client.FLYS; +import org.dive4elements.river.client.shared.model.User; public class WikiLinks { - public static String imageLinkHTML(FLYS instance, String url, String imageUrl) { + public static String imageLinkForm(FLYS instance, String url, String imageUrl) { String saml = null; if (instance != null && instance.getCurrentUser() != null) { saml = instance.getCurrentUser().getSamlXMLBase64(); @@ -40,11 +43,13 @@ } } - public static DynamicForm linkHTML(FLYS flys, String url, String text) { - String saml = flys.getCurrentUser().getSamlXMLBase64(); + public static DynamicForm linkDynamicForm(FLYS flys, String url, String text) { + User currentUser = flys.getCurrentUser(); String quotedUrl = SafeHtmlUtils.htmlEscape(url); String quotedText = SafeHtmlUtils.htmlEscape(text); - if (saml != null) { + + if (currentUser != null) { + String saml = currentUser.getSamlXMLBase64(); final DynamicForm form = new DynamicForm(); form.setMethod(FormMethod.POST); form.setTarget("_blank"); @@ -71,4 +76,31 @@ return form; } } + + public static DynamicForm dynamicForm(FLYS flys, String url) { + User currentUser = flys.getCurrentUser(); + String quotedUrl = SafeHtmlUtils.htmlEscape(url); + + if (currentUser != null) { + String saml = currentUser.getSamlXMLBase64(); + saml = SafeHtmlUtils.htmlEscape(saml); + GWT.log("saml=" + saml); + DynamicForm form = new DynamicForm(); + form.setMethod(FormMethod.POST); + form.setTarget("_blank"); + form.setAction(quotedUrl); + form.setCanSubmit(true); + HiddenItem item = new HiddenItem("saml"); + item.setDefaultValue(saml); + form.setFields(item); + form.setValue("saml", saml); + return form; + } + else { + DynamicForm form = new DynamicForm(); + form.setTarget("_blank"); + form.setAction(quotedUrl); + return form; + } + } }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java Mon Jul 08 14:06:44 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java Mon Jul 08 14:50:59 2013 +0200 @@ -46,7 +46,7 @@ ) { String name = this.getFieldName(colNum); if (name.equals("infolink")) { - return WikiLinks.linkHTML( + return WikiLinks.linkDynamicForm( flys, record.getAttribute("link"), record.getLinkText());