1 /*******************************************************************************
2 * Copyright (c) 2019 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.document.swt.core.widget;
14 import org.eclipse.jface.layout.GridLayoutFactory;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.widgets.Composite;
17 import org.simantics.datatypes.literal.RGB;
18 import org.simantics.document.server.JSONObject;
19 import org.simantics.document.swt.core.SWTDocument;
20 import org.simantics.document.swt.core.base.HasWidgetsWidgetManager;
21 import org.simantics.document.swt.core.bean.MarginsBean;
23 public class GridComposite extends HasWidgetsWidgetManager<Composite> {
26 protected void doUpdateProperties(SWTDocument document, Composite control, JSONObject object) {
30 protected Composite doCreateControl(SWTDocument document, Composite parent, JSONObject object) {
32 MarginsBean extendedMargins = object.getBeanJSONFieldDefault("extendedMargins", MarginsBean.BINDING, new MarginsBean(0, 0, 0, 0));
33 RGB.Integer background = object.getBeanJSONFieldDefault("background", RGB.Integer.BINDING, new RGB.Integer(255, 255, 255));
34 Integer numColumns = object.getJSONFieldDefault("numColumns", 1);
36 Composite result = new Composite(parent, SWT.NONE);
37 GridLayoutFactory.fillDefaults().
38 numColumns(numColumns).
39 extendedMargins(extendedMargins.left, extendedMargins.right, extendedMargins.top, extendedMargins.bottom).
42 result.setBackground(document.getColor(background));