package org.simantics.views.swt.client.base;\r
\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.layout.RowLayoutFactory;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.layout.GridData;\r
import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.layout.RowData;\r
+import org.eclipse.swt.layout.RowLayout;\r
import org.eclipse.swt.widgets.Layout;\r
import org.simantics.browsing.ui.Column;\r
import org.simantics.browsing.ui.Column.Align;\r
import org.simantics.views.ViewUtils.ColumnBean;\r
import org.simantics.views.ViewUtils.GridDataBean;\r
import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutDataBean;\r
+import org.simantics.views.ViewUtils.RowDataBean;\r
+import org.simantics.views.ViewUtils.RowLayoutBean;\r
\r
public class SWTViewUtils {\r
\r
result.marginBottom = bean.marginBottom;\r
return result;\r
}\r
- \r
- \r
+\r
+ public static Layout toLayout(RowLayoutBean bean) {\r
+ RowLayout result = RowLayoutFactory.fillDefaults().create();\r
+ result.type = bean.type;\r
+ result.spacing = bean.spacing;\r
+ result.center = bean.center;\r
+ result.fill = bean.fill;\r
+ result.justify = bean.justify;\r
+ result.pack = bean.pack;\r
+ result.wrap = bean.wrap;\r
+ result.marginLeft = bean.marginLeft;\r
+ result.marginRight = bean.marginRight;\r
+ result.marginTop = bean.marginTop;\r
+ result.marginBottom = bean.marginBottom;\r
+ return result;\r
+ }\r
+\r
public static GridData toGridData(GridDataBean bean) {\r
- GridData result = new GridData(SWT.FILL, SWT.FILL, true, false); \r
+ GridData result = new GridData(SWT.FILL, SWT.FILL, true, false);\r
result.horizontalSpan = bean.horizontalSpan;\r
result.grabExcessHorizontalSpace = bean.grabExcessHorizontalSpace;\r
result.grabExcessVerticalSpace = bean.grabExcessVerticalSpace;\r
\r
}\r
\r
+ public static RowData toRowData(RowDataBean bean) {\r
+ return new RowData(bean.width, bean.height);\r
+ }\r
+\r
+ public static Layout toLayout(LayoutBean layout) {\r
+ if (layout instanceof GridLayoutBean)\r
+ return toLayout((GridLayoutBean) layout);\r
+ if (layout instanceof RowLayoutBean)\r
+ return toLayout((RowLayoutBean) layout);\r
+ throw new IllegalArgumentException("unrecognized layout: " + layout);\r
+ }\r
+\r
+\r
+ public static Object toLayoutData(LayoutDataBean layoutData) {\r
+ if (layoutData instanceof GridDataBean)\r
+ return toGridData((GridDataBean) layoutData);\r
+ if (layoutData instanceof RowDataBean)\r
+ return toRowData((RowDataBean) layoutData);\r
+ throw new IllegalArgumentException("unrecognized layout data: " + layoutData);\r
+ }\r
+\r
private static Align getAlign(String alignment) {\r
if("LEFT".equals(alignment)) return Align.LEFT;\r
else if("CENTER".equals(alignment)) return Align.CENTER;\r