]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTSashForm.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.views.swt.client / src / org / simantics / views / swt / client / impl / SWTSashForm.java
diff --git a/bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTSashForm.java b/bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTSashForm.java
new file mode 100644 (file)
index 0000000..5bc8b23
--- /dev/null
@@ -0,0 +1,48 @@
+package org.simantics.views.swt.client.impl;\r
+\r
+import org.eclipse.swt.custom.SashForm;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Sash;\r
+import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.swt.client.base.SWTViewUtils;\r
+import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
+\r
+public class SWTSashForm extends SingleSWTViewNode<SashForm> {\r
+       \r
+       private static final long serialVersionUID = 7932335224632082902L;\r
+       \r
+       public GridLayoutBean layout;\r
+       public int[] weights;\r
+       public Integer orientation;\r
+       \r
+       @Override\r
+       public void createControls(org.eclipse.swt.widgets.Composite parent) {\r
+               \r
+       control = new SashForm(parent, style);\r
+       \r
+       createChildComposites();\r
+       \r
+       setProperties();\r
+       \r
+       }\r
+\r
+       final public void synchronizeLayout(GridLayoutBean layout) {\r
+               if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));\r
+       }\r
+\r
+       final public void synchronizeWeights(int[] weights) {\r
+               if(weights != null) {\r
+                       int childCount = 0; \r
+                       for(Control c : control.getChildren()) {\r
+                               if (c instanceof Sash) continue;\r
+                               childCount++;\r
+                       }\r
+                       if(weights.length != childCount) throw new IllegalStateException("Got " + weights.length + " weights, but had " + childCount + " children.");\r
+                       control.setWeights(weights);\r
+               }\r
+       }\r
+       final public void synchronizeOrientation(Integer orientation) {\r
+               if(orientation != null) control.setOrientation(orientation);\r
+       }\r
+       \r
+}\r