changeset 2500:69a498896c9c

Create a link to an online help page and put it in front of the input panels. flys-client/trunk@4336 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 03 May 2012 06:19:04 +0000
parents 8f36d4b5890c
children 87634a9a8478
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ImgLink.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DataList.java
diffstat 7 files changed, 116 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed May 02 19:07:23 2012 +0000
+++ b/flys-client/ChangeLog	Thu May 03 06:19:04 2012 +0000
@@ -1,3 +1,25 @@
+2012-05-03  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java:
+	  Parse 'helpText' field in DESCRIBE document.
+
+	* src/main/java/de/intevation/flys/client/shared/model/DataList.java:
+	  Added an attribute 'helpText' to store an URL reference to an online help
+	  page.
+
+	* src/main/java/de/intevation/flys/client/client/ui/UIProvider.java,
+	  src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java:
+	  Defined and implemented a method to create a Canvas with a link to an
+	  online help page.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ParameterList.java:
+	  Create the link to an online help page for each current parameter and
+	  put it in front of the input panel.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ImgLink.java: Added an
+	  attribute 'newTab' that could be used to open the link in a new tab
+	  (HTML target='_blank').
+
 2012-05-02	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java	Wed May 02 19:07:23 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java	Thu May 03 06:19:04 2012 +0000
@@ -165,6 +165,15 @@
     }
 
 
+    @Override
+    public Canvas createHelpLink(DataList dataList, Data data) {
+        String iUrl    = GWT.getHostPageBaseURL() + MSG.getFeatureInfo();
+        String helpUrl = dataList.getHelpText();
+
+        return new ImgLink(iUrl, helpUrl, 30, 30, true);
+    }
+
+
     /**
      * Creates the 'back' button to step back to a previous state.
      *
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ImgLink.java	Wed May 02 19:07:23 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ImgLink.java	Thu May 03 06:19:04 2012 +0000
@@ -12,6 +12,8 @@
     private String href;
     private String imgUrl;
 
+    private boolean newTab;
+
 
     public ImgLink(String imgUrl, String href, int width, int height) {
         super();
@@ -20,13 +22,24 @@
         this.height = height;
         this.href   = href;
         this.imgUrl = imgUrl;
+        this.newTab = false;
+
+        update();
+    }
+
+
+    public ImgLink(String imgUrl, String href, int w, int h, boolean newTab) {
+        this(imgUrl, href, w, h);
+        this.newTab = newTab;
 
         update();
     }
 
 
     protected void update() {
-        setContents("<a href='" + href + "'><img src='" + imgUrl + "'></a>");
+        String target = newTab ? "_blank" : "_self";
+
+        setContents("<a target='" + target + "' href='" + href + "'><img src='" + imgUrl + "'></a>");
         setWidth(width);
         setHeight(height);
         setOverflow(Overflow.VISIBLE);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Wed May 02 19:07:23 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Thu May 03 06:19:04 2012 +0000
@@ -539,7 +539,13 @@
 
         if (current != null && uiProvider != null) {
             Canvas c = uiProvider.create(current);
-            currentItems.addMember(c);
+            Canvas h = uiProvider.createHelpLink(current, null);
+
+            HLayout wrapper = new HLayout();
+            wrapper.addMember(h);
+            wrapper.addMember(c);
+
+            currentItems.addMember(wrapper);
         }
         else if (uiProvider != null) {
             Canvas c = uiProvider.create(null);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java	Wed May 02 19:07:23 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java	Thu May 03 06:19:04 2012 +0000
@@ -5,6 +5,7 @@
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.layout.VLayout;
 
+import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.Artifact;
 import de.intevation.flys.client.shared.model.Collection;
@@ -39,6 +40,9 @@
     public Canvas createOld(DataList dataList);
 
 
+    public Canvas createHelpLink(DataList dataList, Data data);
+
+
     /**
      * This method injects a container that is used to position helper widgets.
      *
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Wed May 02 19:07:23 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Thu May 03 06:19:04 2012 +0000
@@ -51,6 +51,8 @@
 
     public static final String XPATH_UIPROVIDER = "@art:uiprovider";
 
+    public static final String XPATH_HELP_TEXT = "@art:helpText";
+
     public static final String XPATH_REACHABLE_STATE = "art:state";
 
     public static final String XPATH_STATIC_STATE_NODE = "art:state";
@@ -118,6 +120,7 @@
         logger.debug("ArtifactDescriptionFactory.extractCurrentData");
 
         NodeList data     = ClientProtocolUtils.getSelectNode(dynamicNode);
+        String help       = extractHelpText(dynamicNode);
         String uiProvider = extractUIProvider(dynamicNode);
 
         if (data == null || data.getLength() == 0) {
@@ -125,7 +128,7 @@
         }
 
         int      dataNum = data.getLength();
-        DataList list    = new DataList(state, dataNum, uiProvider);
+        DataList list    = new DataList(state, dataNum, uiProvider, null, help);
 
         for (int i = 0; i < dataNum; i++) {
             Element   d  = (Element) data.item(i);
@@ -381,6 +384,8 @@
                 tmp, "@art:uiprovider", ArtifactNamespaceContext.INSTANCE);
             String label = XMLUtils.xpathString(
                 tmp, "@art:label", ArtifactNamespaceContext.INSTANCE);
+            String help = XMLUtils.xpathString(
+                tmp, "@art:helpText", ArtifactNamespaceContext.INSTANCE);
 
             NodeList dataNodes = (NodeList) XMLUtils.xpath(
                 tmp,
@@ -393,7 +398,7 @@
             }
 
             int size      = dataNodes.getLength();
-            DataList list = new DataList(name, size, uiprovider, label);
+            DataList list = new DataList(name, size, uiprovider, label, help);
 
             for (int j = 0; j < size; j++) {
                 Node dataNode = dataNodes.item(j);
@@ -425,6 +430,22 @@
 
 
     /**
+     * This method extracts the help text specified by the data node.
+     *
+     * @param ui The data node.
+     *
+     * @return the help text.
+     */
+    protected static String extractHelpText(Node ui) {
+        return (String) XMLUtils.xpath(
+            ui,
+            XPATH_HELP_TEXT,
+            XPathConstants.STRING,
+            ArtifactNamespaceContext.INSTANCE);
+    }
+
+
+    /**
      * This method extracts the reachable states of the current artifact.
      *
      * @param reachable The reachable states node.
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DataList.java	Wed May 02 19:07:23 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DataList.java	Thu May 03 06:19:04 2012 +0000
@@ -21,6 +21,9 @@
     /** The label that should be used to label data objects. */
     protected String label;
 
+    /** The help text (URL) that should be displayed for this data object. */
+    protected String helpText;
+
 
     /**
      * The default constructor that creates a new DataList without Data objects
@@ -73,6 +76,28 @@
 
 
     /**
+     * A constructor that creates a new DataList without Data objects and no
+     * UIProvider. Size defines the initial size of the list.
+     *
+     * @param state The name of the state that this list belongs to.
+     * @param size The initial size of the list.
+     * @param uiprovider The UIProvider that should be used to render this list.
+     * @param label The label.
+     * @param helpText The help text (should be an URL).
+     */
+    public DataList(
+        String state,
+        int    size,
+        String uiprovider,
+        String label,
+        String helpText
+    ) {
+        this(state, size, uiprovider, label);
+        this.helpText = helpText;
+    }
+
+
+    /**
      * Adds a new Data object to the list.
      *
      * @param obj The Data object.
@@ -163,12 +188,23 @@
     }
 
 
+    /**
+     * Returns the help text which should be an URL.
+     *
+     * @return the help text.
+     */
+    public String getHelpText() {
+        return helpText;
+    }
+
+
     public Object clone() {
         DataList clone = new DataList(
             this.state,
             this.data.size(),
             this.uiprovider,
-            this.label);
+            this.label,
+            this.helpText);
         clone.data = (List<Data>) ((ArrayList<Data>)data).clone();
 
         return clone;

http://dive4elements.wald.intevation.org