From 9a569748367f2db8c591cd60124a3a9b12953ce4 Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Wed, 6 Oct 2010 08:47:56 +0000
Subject: [PATCH] minor: added info to xml schema and xslt script fields

SVN: 18162
---
 .../client/web/client/application/Dict.java   | 10 ++-
 .../PropertyTypeRegistrationForm.java         | 22 ++++-
 .../application/ui/widget/FieldUtil.java      | 86 ++++++++++++-------
 .../cisd/openbis/public/common-dictionary.js  |  4 +-
 4 files changed, 81 insertions(+), 41 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java
index c6ca52cfada..aba3ca08115 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java
@@ -44,7 +44,7 @@ public abstract class Dict
 
     //
     // Common Labels
-    // 
+    //
 
     public static final String ATTACHMENT = "attachment";
 
@@ -368,8 +368,12 @@ public abstract class Dict
 
     public static final String XML_SCHEMA = "xml_schema";
 
+    public static final String XML_SCHEMA_INFO = "xml_schema_info";
+
     public static final String XSLT = "xslt";
 
+    public static final String XSLT_INFO = "xslt_info";
+
     //
     // Property Type Assignment Browser
     //
@@ -728,12 +732,12 @@ public abstract class Dict
 
     public static final String ALLOW_ANY_TYPE = "allow_any_type";
 
-    // 
+    //
     // Material Import
     //
     public static final String MATERIAL_IMPORT = "material_import";
 
-    // 
+    //
     // Material Chooser
     //
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java
index 1b68f064ede..825f3373e36 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java
@@ -20,6 +20,7 @@ import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
 import com.extjs.gxt.ui.client.event.SelectionChangedListener;
 import com.extjs.gxt.ui.client.widget.LayoutContainer;
 import com.extjs.gxt.ui.client.widget.form.Field;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
 
 import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict;
@@ -83,7 +84,7 @@ public final class PropertyTypeRegistrationForm extends AbstractRegistrationForm
 
     private PropertyTypeRegistrationForm(final IViewContext<ICommonClientServiceAsync> viewContext)
     {
-        super(viewContext, ID);
+        super(viewContext, ID, DEFAULT_LABEL_WIDTH + 20, DEFAULT_FIELD_WIDTH);
         this.viewContext = viewContext;
 
         this.propertyTypeCodeField = createPropertyTypeCodeField();
@@ -114,7 +115,8 @@ public final class PropertyTypeRegistrationForm extends AbstractRegistrationForm
     {
         String label = viewContext.getMessage(Dict.ALLOW_ANY_TYPE);
         MaterialTypeSelectionWidget chooser =
-                MaterialTypeSelectionWidget.createWithAdditionalOption(viewContext, label, null, ID);
+                MaterialTypeSelectionWidget
+                        .createWithAdditionalOption(viewContext, label, null, ID);
         FieldUtil.markAsMandatory(chooser);
         return chooser;
     }
@@ -142,12 +144,24 @@ public final class PropertyTypeRegistrationForm extends AbstractRegistrationForm
 
     private final XmlField createXmlSchemaField()
     {
-        return new XmlField(viewContext.getMessage(Dict.XML_SCHEMA), false);
+        final String label = viewContext.getMessage(Dict.XML_SCHEMA);
+        final String description = viewContext.getMessage(Dict.XML_SCHEMA_INFO);
+        final AbstractImagePrototype infoIcon =
+                AbstractImagePrototype.create(viewContext.getImageBundle().getInfoIcon());
+        final XmlField field = new XmlField(label, false);
+        FieldUtil.addInfoIcon(field, description, infoIcon.createImage());
+        return field;
     }
 
     private final XmlField createXslTransformationsField()
     {
-        return new XmlField(viewContext.getMessage(Dict.XSLT), false);
+        final String label = viewContext.getMessage(Dict.XSLT);
+        final String description = viewContext.getMessage(Dict.XSLT_INFO);
+        final AbstractImagePrototype infoIcon =
+                AbstractImagePrototype.create(viewContext.getImageBundle().getInfoIcon());
+        final XmlField field = new XmlField(label, false);
+        FieldUtil.addInfoIcon(field, description, infoIcon.createImage());
+        return field;
     }
 
     private final DataTypeSelectionWidget createDataTypeSelectionWidget()
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/FieldUtil.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/FieldUtil.java
index 3ab0ab3eb24..d7130742826 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/FieldUtil.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/FieldUtil.java
@@ -110,6 +110,12 @@ public class FieldUtil
         field.enableEvents(true);
     }
 
+    //
+    // info icon support
+    // WORKAROUND: Based on GXT functionality for displaying error icon, until there is no
+    // dedicated mechanism for showing info icons in GXT
+    //
+
     /**
      * Adds '?' to the field and allows to display chosen message in the info box.
      * 
@@ -117,51 +123,65 @@ public class FieldUtil
      */
     public static void addInfoIcon(final Field<?> field, final String message, final Image image)
     {
-        // WORKAROUND: Based on GXT functionality for displaying error icon, until there is no
-        // dedicated mechanism for showing info icons in GXT
+        final WidgetComponent infoIcon = createInfoIcon(message, image);
+
+        final IDelegatedAction alignInfoIcon = new IDelegatedAction()
+            {
+                public void execute()
+                {
+                    infoIcon.el().alignTo(field.getElement(), INFO_LINK_POSITION,
+                            INFO_LINK_FIELD_OFFSETS);
+                }
+            };
+
         field.addListener(Events.Render, new Listener<BaseEvent>()
             {
                 public void handleEvent(BaseEvent be)
                 {
-                    final WidgetComponent info = new WidgetComponent(image);
-                    info.setStyleName("hands");
-                    info.setStyleAttribute("cursor", "hand");
-                    GWTUtils.setToolTip(info, message);
-                    info.sinkEvents(Events.OnClick.getEventCode());
-                    info.addListener(Events.OnClick, new Listener<BaseEvent>()
-                        {
-                            public void handleEvent(BaseEvent e)
-                            {
-                                MessageBox.info("Info", message, null);
-                            }
-                        });
-
                     Element parent = field.el().getParent().dom;
-                    info.render(parent);
-                    info.setStyleAttribute("display", "block");
-                    info.el().makePositionable(true);
-                    if (!info.isAttached())
+                    infoIcon.render(parent);
+                    infoIcon.setStyleAttribute("display", "block");
+                    infoIcon.el().makePositionable(true);
+                    if (!infoIcon.isAttached())
                     {
-                        ComponentHelper.doAttach(info);
+                        ComponentHelper.doAttach(infoIcon);
                     }
-                    final IDelegatedAction alignInfo = new IDelegatedAction()
-                        {
-
-                            public void execute()
-                            {
-                                info.el().alignTo(field.getElement(), INFO_LINK_POSITION,
-                                        INFO_LINK_FIELD_OFFSETS);
-                            }
-
-                        };
-                    GWTUtils.executeDelayed(alignInfo);
+                    GWTUtils.executeDelayed(alignInfoIcon);
                     if (GXT.isIE || GXT.isOpera)
                     {
-                        // TODO 2010-07-13, Piotr Buczek: still needed?
-                        GWTUtils.executeDelayed(alignInfo); 
+                        GWTUtils.executeDelayed(alignInfoIcon);
                     }
                     field.el().repaint();
                 }
             });
+        field.addListener(Events.Show, new Listener<BaseEvent>()
+            {
+                public void handleEvent(BaseEvent be)
+                {
+                    GWTUtils.executeDelayed(alignInfoIcon);
+                    if (GXT.isIE || GXT.isOpera)
+                    {
+                        GWTUtils.executeDelayed(alignInfoIcon);
+                    }
+                }
+            });
+    }
+
+    private static WidgetComponent createInfoIcon(final String message, final Image image)
+    {
+        final WidgetComponent info = new WidgetComponent(image);
+        info.setStyleName("hands");
+        info.setStyleAttribute("cursor", "hand");
+        GWTUtils.setToolTip(info, message);
+        info.sinkEvents(Events.OnClick.getEventCode());
+        info.addListener(Events.OnClick, new Listener<BaseEvent>()
+            {
+                public void handleEvent(BaseEvent e)
+                {
+                    MessageBox.info("Info", message, null);
+                }
+            });
+        return info;
     }
+
 }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js
index 17ed60edf4e..e58a3c69205 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js
@@ -256,7 +256,9 @@ var common = {
   default_value_tooltip: "The value of the assigned property for all currently existing entities.",
   entity_type_assignments: "{0} Type Assignment{1}",
   xml_schema: "XML Schema",
-  xslt: "XSLT",
+  xml_schema_info: "XML Schema that will be used for validation of user provided XML documents.<br><br>If no schema is specified only well-formedness of the documents will be checked.",
+  xslt: "XSLT Script",
+  xslt_info: "XSLT Script that will be used for rendering of user provided XML documents e.g. in tables.<br><br>If no script is specified the original XML document will be displayed.",
   
   
   //
-- 
GitLab