Mercurial > dive4elements > river
view gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6518:1a7f5d09b9d8
Longitudinal sections: partly renamed outs and configured recommendations at once
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 28 Jun 2013 21:08:23 +0200 |
parents | c28f13c80979 |
children | 7106f9b75004 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.client.client.ui; import com.smartgwt.client.types.FormMethod; import com.smartgwt.client.widgets.form.DynamicForm; 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; public class WikiLinks { public static String imageLinkHTML(FLYS instance, String url, String imageUrl) { String saml = null; if (instance != null && instance.getCurrentUser() != null) { saml = instance.getCurrentUser().getSamlXMLBase64(); } String quotedUrl = SafeHtmlUtils.htmlEscape(url); String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl); if (saml != null) { return "<form method=\"POST\" target=\"_blank\" action=\"" + quotedUrl + "\">" + "<input type=\"hidden\" name=\"saml\" value=\"" + SafeHtmlUtils.htmlEscape(saml) + "\">" + "<input type=\"image\" src=\""+ quotedImage + "\">" + "</form>"; } else { return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>"; } } public static DynamicForm linkHTML(FLYS flys, String url, String text) { String saml = flys.getCurrentUser().getSamlXMLBase64(); String quotedUrl = SafeHtmlUtils.htmlEscape(url); String quotedText = SafeHtmlUtils.htmlEscape(text); if (saml != null) { final DynamicForm form = new DynamicForm(); form.setMethod(FormMethod.POST); form.setTarget("_blank"); form.setAction(quotedUrl); form.setCanSubmit(true); LinkItem item = new LinkItem("saml"); item.setShowTitle(false); item.setLinkTitle(quotedText); item.setValue(SafeHtmlUtils.htmlEscape(saml)); item.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { form.submitForm(); } }); form.setFields(item); return form; } else { DynamicForm form = new DynamicForm(); LinkItem item = new LinkItem(quotedText); item.setShowTitle(false); item.setTarget(quotedUrl); return form; } } }