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 java.util.TreeMap;
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;
27 public class FillComposite extends HasWidgetsWidgetManager<Composite> {
30 protected void doUpdateProperties(SWTDocument document, Composite control, JSONObject object) {
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));
43 @SuppressWarnings("unchecked")
45 public void updateChildren(SWTDocument document, JSONObject object, WidgetContainer widget, TreeMap<String, WidgetData> childMap) {
47 super.updateChildren(document, object, widget, childMap);
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());