]> gerrit.simantics Code Review - simantics/platform.git/blob
ce2538c03e9eefb82aa9645c523a7cd6ec36c14b
[simantics/platform.git] /
1 package org.simantics.document.swt.core.widget;
2
3 import org.eclipse.jface.layout.GridLayoutFactory;
4 import org.eclipse.swt.SWT;
5 import org.eclipse.swt.widgets.Composite;
6 import org.simantics.datatypes.literal.RGB;
7 import org.simantics.document.server.JSONObject;
8 import org.simantics.document.swt.core.SWTDocument;
9 import org.simantics.document.swt.core.base.HasWidgetsWidgetManager;
10 import org.simantics.document.swt.core.bean.MarginsBean;
11
12 public class GridComposite extends HasWidgetsWidgetManager<Composite> {
13
14         @Override
15         protected void doUpdateProperties(SWTDocument document, Composite control, JSONObject object) {
16         }
17
18         @Override
19         protected Composite doCreateControl(SWTDocument document, Composite parent, JSONObject object) {
20                 
21                 MarginsBean extendedMargins = object.getBeanJSONFieldDefault("extendedMargins", MarginsBean.BINDING, new MarginsBean(0, 0, 0, 0));
22                 RGB.Integer background = object.getBeanJSONFieldDefault("background", RGB.Integer.BINDING, new RGB.Integer(255,0, 0));
23                 Integer numColumns = object.getJSONFieldDefault("numColumns", 1);
24                 
25                 Composite result = new Composite(parent, SWT.NONE);
26                 GridLayoutFactory.fillDefaults().
27                         numColumns(numColumns).
28                         extendedMargins(extendedMargins.left, extendedMargins.right, extendedMargins.top, extendedMargins.bottom).
29                         spacing(0, 0).
30                         applyTo(result);
31                 result.setBackground(document.getColor(background));
32                 return result;
33                 
34         }
35         
36 }