1 package org.simantics.document.swt.core.widget;
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;
12 public class GridComposite extends HasWidgetsWidgetManager<Composite> {
15 protected void doUpdateProperties(SWTDocument document, Composite control, JSONObject object) {
19 protected Composite doCreateControl(SWTDocument document, Composite parent, JSONObject object) {
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);
25 Composite result = new Composite(parent, SWT.NONE);
26 GridLayoutFactory.fillDefaults().
27 numColumns(numColumns).
28 extendedMargins(extendedMargins.left, extendedMargins.right, extendedMargins.top, extendedMargins.bottom).
31 result.setBackground(document.getColor(background));