]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.views/src/org/simantics/views/ViewUtils.java
Sync git svn branch with SVN repository r33153.
[simantics/platform.git] / bundles / org.simantics.views / src / org / simantics / views / ViewUtils.java
index f22e5ad836bc53e5f463b722bd83802789827703..749c2856e3b7d38a7721349174641f5293bf4c96 100644 (file)
@@ -32,20 +32,35 @@ public class ViewUtils {
     }\r
 \r
     public static final Binding EXTENDED_MARGINS_BINDING = Bindings.getBindingUnchecked(ExtendedMargins.class);\r
-       \r
-       public static class GridLayoutBean extends Bean {\r
-               \r
-               public int numColumns;\r
-               public int horizontalSpacing;\r
-               public int verticalSpacing;\r
+\r
+       public static class LayoutBean extends Bean {\r
                public int marginLeft;\r
                public int marginRight;\r
                public int marginTop;\r
                public int marginBottom;\r
+       }\r
+\r
+       public static class GridLayoutBean extends LayoutBean {\r
+               \r
+               public int numColumns;\r
+               public int horizontalSpacing;\r
+               public int verticalSpacing;\r
                \r
        }\r
-       \r
-       public static class GridDataBean extends Bean {\r
+\r
+       public static class RowLayoutBean extends LayoutBean {\r
+               public int type;\r
+               public int spacing;\r
+               public boolean center;\r
+               public boolean fill;\r
+               public boolean justify;\r
+               public boolean pack;\r
+               public boolean wrap;\r
+       }\r
+\r
+       public static class LayoutDataBean extends Bean {}\r
+\r
+       public static class GridDataBean extends LayoutDataBean {\r
                \r
                public int horizontalSpan;\r
                public boolean grabExcessHorizontalSpace;\r
@@ -56,7 +71,12 @@ public class ViewUtils {
                public int heightHint;\r
                \r
        }\r
-       \r
+\r
+       public static class RowDataBean extends LayoutDataBean {\r
+               public int width;\r
+               public int height;\r
+       }\r
+\r
        public static class ColumnBean extends Bean {\r
                \r
                public String key;\r
@@ -128,6 +148,50 @@ public class ViewUtils {
     \r
        }\r
 \r
+       public static RowLayoutBean getRowLayout(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
+           return processor.sync(new ResourceRead<RowLayoutBean>(configuration) {\r
+               @Override\r
+               public RowLayoutBean perform(ReadGraph graph) throws DatabaseException {\r
+                   ViewsResources VIEW = ViewsResources.getInstance(graph);\r
+                   Integer type = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_type, Bindings.INTEGER);\r
+                   Integer spacing = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_spacing, Bindings.INTEGER);\r
+                   Boolean center = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_center, Bindings.BOOLEAN);\r
+                Boolean fill = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_fill, Bindings.BOOLEAN);\r
+                Boolean justify = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_justify, Bindings.BOOLEAN);\r
+                   Boolean pack = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_pack, Bindings.BOOLEAN);\r
+                   Boolean wrap = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_wrap, Bindings.BOOLEAN);\r
+                   ExtendedMargins extendedMargins = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_extendedMargins, EXTENDED_MARGINS_BINDING);\r
+\r
+                   RowLayoutBean layout = new RowLayoutBean();\r
+                   layout.type = type;\r
+                   layout.spacing = spacing;\r
+                layout.center = center;\r
+                layout.fill = fill;\r
+                layout.justify = justify;\r
+                   layout.pack = pack;\r
+                   layout.wrap = wrap;\r
+                   layout.marginLeft = extendedMargins.left;\r
+                   layout.marginRight = extendedMargins.right;\r
+                   layout.marginTop = extendedMargins.top;\r
+                   layout.marginBottom = extendedMargins.bottom;\r
+                   return layout;\r
+               }\r
+           });\r
+       }\r
+\r
+       public static RowDataBean getRowData(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
+           return processor.sync(new ResourceRead<RowDataBean>(configuration) {\r
+               @Override\r
+               public RowDataBean perform(ReadGraph graph) throws DatabaseException {\r
+                   ViewsResources VIEW = ViewsResources.getInstance(graph);\r
+                   RowDataBean data = new RowDataBean();\r
+                   data.width = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredWidth, Bindings.INTEGER);\r
+                   data.height = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredHeight, Bindings.INTEGER);\r
+                   return data;\r
+               }\r
+           });\r
+       }\r
+\r
        public static int getStyle(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
                \r
                return processor.sync(new ResourceRead<Integer>(configuration) {\r
@@ -188,6 +252,7 @@ public class ViewUtils {
 \r
                Simantics.getSession().async(new TernaryRead<Resource, Variable, String, T> (configuration, context, relationURI) {\r
 \r
+                       @SuppressWarnings("unchecked")\r
                        @Override\r
                        public T perform(ReadGraph graph) throws DatabaseException {\r
                                Object value = graph.getRelatedValue2(parameter, graph.getResource(parameter3), parameter2);\r