]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/LeafWidgetManager.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.document.swt.core / src / org / simantics / document / swt / core / base / LeafWidgetManager.java
1 package org.simantics.document.swt.core.base;
2
3
4 import java.util.TreeMap;
5
6 import org.eclipse.swt.widgets.Composite;
7 import org.eclipse.swt.widgets.Control;
8 import org.simantics.document.server.JSONObject;
9 import org.simantics.document.server.client.WidgetData;
10 import org.simantics.document.swt.core.SWTDocument;
11
12 public abstract class LeafWidgetManager<W extends Control> extends PropertyWidgetManager<WidgetContainer<W>> {
13
14         class Container extends WidgetContainer<W> {
15                 
16                 @SuppressWarnings("unchecked")
17                 @Override
18                 protected void doUpdateProperties(SWTDocument document, Control control, JSONObject object) {
19                         LeafWidgetManager.this.doUpdateProperties(document, (W)control, object);
20                 }
21                 
22                 @Override
23                 protected Control doCreateControl(SWTDocument document, Composite parent, JSONObject object) {
24                         return LeafWidgetManager.this.doCreateControl(document, parent, object);
25                 }
26                 
27         }
28         
29         @Override
30         public WidgetContainer<W> createWidget(JSONObject object) {
31                 return new Container();
32         }       
33         
34         @Override
35         public void updateChildren(SWTDocument document, JSONObject object, WidgetContainer<W> widget, TreeMap<String,WidgetData> childMap) {
36                 throw new UnsupportedOperationException("Widget type " + object.getType() + " does not support children");
37         }
38         
39         @Override
40         public void updateProperties(SWTDocument document, JSONObject object, WidgetContainer<W> widget) {
41                 widget.updateProperties(document, object);
42         }
43         
44         abstract protected void doUpdateProperties(SWTDocument document, W control, JSONObject object);
45         abstract protected W doCreateControl(SWTDocument document, Composite parent, JSONObject object);
46         
47 }