]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTSashForm.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.views.swt.client / src / org / simantics / views / swt / client / impl / SWTSashForm.java
1 package org.simantics.views.swt.client.impl;
2
3 import org.eclipse.swt.custom.SashForm;
4 import org.eclipse.swt.widgets.Control;
5 import org.eclipse.swt.widgets.Sash;
6 import org.simantics.views.ViewUtils.LayoutBean;
7 import org.simantics.views.swt.client.base.SWTViewUtils;
8 import org.simantics.views.swt.client.base.SingleSWTViewNode;
9
10 public class SWTSashForm extends SingleSWTViewNode<SashForm> {
11         
12         private static final long serialVersionUID = 7932335224632082902L;
13         
14         public LayoutBean layout;
15         public int[] weights;
16         public Integer orientation;
17         
18         @Override
19         public void createControls(org.eclipse.swt.widgets.Composite parent) {
20                 
21         control = new SashForm(parent, style);
22         
23         createChildComposites();
24         
25         setProperties();
26         
27         }
28
29         final public void synchronizeLayout(LayoutBean layout) {
30                 if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));
31         }
32
33         final public void synchronizeWeights(int[] weights) {
34                 if(weights != null) {
35                         int childCount = 0; 
36                         for(Control c : control.getChildren()) {
37                                 if (c instanceof Sash) continue;
38                                 childCount++;
39                         }
40                         if(weights.length != childCount) throw new IllegalStateException("Got " + weights.length + " weights, but had " + childCount + " children.");
41                         control.setWeights(weights);
42                 }
43         }
44         final public void synchronizeOrientation(Integer orientation) {
45                 if(orientation != null) control.setOrientation(orientation);
46         }
47         
48 }