X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.views%2Fsrc%2Forg%2Fsimantics%2Fviews%2FViewUtils.java;h=749c2856e3b7d38a7721349174641f5293bf4c96;hp=f22e5ad836bc53e5f463b722bd83802789827703;hb=25b6c25959c1fb3c60bb41cd0e1f0808e7fc3769;hpb=ccc1271c9d6657fb9dcf4cf3cb115fa0c8cb9589 diff --git a/bundles/org.simantics.views/src/org/simantics/views/ViewUtils.java b/bundles/org.simantics.views/src/org/simantics/views/ViewUtils.java index f22e5ad83..749c2856e 100644 --- a/bundles/org.simantics.views/src/org/simantics/views/ViewUtils.java +++ b/bundles/org.simantics.views/src/org/simantics/views/ViewUtils.java @@ -32,20 +32,35 @@ public class ViewUtils { } public static final Binding EXTENDED_MARGINS_BINDING = Bindings.getBindingUnchecked(ExtendedMargins.class); - - public static class GridLayoutBean extends Bean { - - public int numColumns; - public int horizontalSpacing; - public int verticalSpacing; + + public static class LayoutBean extends Bean { public int marginLeft; public int marginRight; public int marginTop; public int marginBottom; + } + + public static class GridLayoutBean extends LayoutBean { + + public int numColumns; + public int horizontalSpacing; + public int verticalSpacing; } - - public static class GridDataBean extends Bean { + + public static class RowLayoutBean extends LayoutBean { + public int type; + public int spacing; + public boolean center; + public boolean fill; + public boolean justify; + public boolean pack; + public boolean wrap; + } + + public static class LayoutDataBean extends Bean {} + + public static class GridDataBean extends LayoutDataBean { public int horizontalSpan; public boolean grabExcessHorizontalSpace; @@ -56,7 +71,12 @@ public class ViewUtils { public int heightHint; } - + + public static class RowDataBean extends LayoutDataBean { + public int width; + public int height; + } + public static class ColumnBean extends Bean { public String key; @@ -128,6 +148,50 @@ public class ViewUtils { } + public static RowLayoutBean getRowLayout(RequestProcessor processor, Resource configuration) throws DatabaseException { + return processor.sync(new ResourceRead(configuration) { + @Override + public RowLayoutBean perform(ReadGraph graph) throws DatabaseException { + ViewsResources VIEW = ViewsResources.getInstance(graph); + Integer type = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_type, Bindings.INTEGER); + Integer spacing = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_spacing, Bindings.INTEGER); + Boolean center = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_center, Bindings.BOOLEAN); + Boolean fill = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_fill, Bindings.BOOLEAN); + Boolean justify = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_justify, Bindings.BOOLEAN); + Boolean pack = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_pack, Bindings.BOOLEAN); + Boolean wrap = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_wrap, Bindings.BOOLEAN); + ExtendedMargins extendedMargins = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_extendedMargins, EXTENDED_MARGINS_BINDING); + + RowLayoutBean layout = new RowLayoutBean(); + layout.type = type; + layout.spacing = spacing; + layout.center = center; + layout.fill = fill; + layout.justify = justify; + layout.pack = pack; + layout.wrap = wrap; + layout.marginLeft = extendedMargins.left; + layout.marginRight = extendedMargins.right; + layout.marginTop = extendedMargins.top; + layout.marginBottom = extendedMargins.bottom; + return layout; + } + }); + } + + public static RowDataBean getRowData(RequestProcessor processor, Resource configuration) throws DatabaseException { + return processor.sync(new ResourceRead(configuration) { + @Override + public RowDataBean perform(ReadGraph graph) throws DatabaseException { + ViewsResources VIEW = ViewsResources.getInstance(graph); + RowDataBean data = new RowDataBean(); + data.width = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredWidth, Bindings.INTEGER); + data.height = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredHeight, Bindings.INTEGER); + return data; + } + }); + } + public static int getStyle(RequestProcessor processor, Resource configuration) throws DatabaseException { return processor.sync(new ResourceRead(configuration) { @@ -188,6 +252,7 @@ public class ViewUtils { Simantics.getSession().async(new TernaryRead (configuration, context, relationURI) { + @SuppressWarnings("unchecked") @Override public T perform(ReadGraph graph) throws DatabaseException { Object value = graph.getRelatedValue2(parameter, graph.getResource(parameter3), parameter2);