Explicitly specify server base for img.
[lgpl/argeo-commons.git] / org.argeo.cms.ui / src / org / argeo / cms / ui / util / CmsUiUtils.java
index 5d6030ec4b72aa6de533281405ef7fff89eacd91..428c910e54133dee353aa8d034ffc388fb8f30a5 100644 (file)
@@ -156,6 +156,9 @@ public class CmsUiUtils implements CmsConstants {
                return new GridData(horizontalAlignment, horizontalAlignment, false, true);
        }
 
+       /*
+        * ROW LAYOUT
+        */
        public static RowData rowData16px() {
                return new RowData(16, 16);
        }
@@ -164,7 +167,7 @@ public class CmsUiUtils implements CmsConstants {
         * FORM LAYOUT
         */
 
-       public static FormData coversAll() {
+       public static FormData coverAll() {
                FormData fdLabel = new FormData();
                fdLabel.top = new FormAttachment(0, 0);
                fdLabel.left = new FormAttachment(0, 0);
@@ -182,8 +185,9 @@ public class CmsUiUtils implements CmsConstants {
                if (style == null)
                        return widget;// does nothing
                EclipseUiSpecificUtils.setStyleData(widget, style);
-               if (widget instanceof Control)
-                       CmsView.getCmsView(((Control) widget).getParent()).applyStyles(widget);
+               if (widget instanceof Control) {
+                       CmsView.getCmsView((Control) widget).applyStyles(widget);
+               }
                return widget;
        }
 
@@ -276,6 +280,15 @@ public class CmsUiUtils implements CmsConstants {
        }
 
        // IMAGES
+       public static String img(Node fileNode, String width, String height) {
+               return img(null, fileNode, width, height);
+       }
+
+       public static String img(String serverBase, Node fileNode, String width, String height) {
+               String src = (serverBase != null ? serverBase : "") + NodeUtils.getDataPath(fileNode);
+               return imgBuilder(src, width, height).append("/>").toString();
+       }
+
        public static String img(String src, String width, String height) {
                return imgBuilder(src, width, height).append("/>").toString();
        }