]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/FillComposite.java
Improvements to modelled SWT documents
[simantics/platform.git] / bundles / org.simantics.document.swt.core / src / org / simantics / document / swt / core / widget / FillComposite.java
1 /*******************************************************************************
2  * Copyright (c) 2019 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.document.swt.core.widget;
13
14 import java.util.TreeMap;
15
16 import org.eclipse.jface.layout.GridDataFactory;
17 import org.eclipse.jface.layout.GridLayoutFactory;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.simantics.document.server.JSONObject;
22 import org.simantics.document.server.client.WidgetData;
23 import org.simantics.document.swt.core.SWTDocument;
24 import org.simantics.document.swt.core.base.HasWidgetsWidgetManager;
25 import org.simantics.document.swt.core.base.WidgetContainer;
26
27 public class FillComposite extends HasWidgetsWidgetManager<Composite> {
28
29         @Override
30         protected void doUpdateProperties(SWTDocument document, Composite control, JSONObject object) {
31         }
32
33         @Override
34         protected Composite doCreateControl(SWTDocument document, Composite parent, JSONObject object) {
35                 Composite result = new Composite(parent, SWT.NONE);
36 //              result.setLayout(new FillLayout(SWT.VERTICAL));
37                 //GridDataFactory.fillDefaults().grab(true, true).minSize(1, 1).applyTo(result);
38                 GridLayoutFactory.fillDefaults().applyTo(result);
39 //              result.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
40                 return result;
41         }
42
43         @SuppressWarnings("unchecked")
44         @Override
45         public void updateChildren(SWTDocument document, JSONObject object, WidgetContainer widget, TreeMap<String, WidgetData> childMap) {
46
47                 super.updateChildren(document, object, widget, childMap);
48
49                 WidgetData child = childMap.values().iterator().next();
50                 WidgetContainer container = (WidgetContainer)child.widget;
51                 if(container.getControl() == null) return;
52                 GridDataFactory.fillDefaults().grab(true, true).minSize(1, 1).applyTo((Control)container.getControl());
53
54         }
55
56 }