1 package org.simantics.views.swt.client.base;
3 import org.eclipse.jface.resource.JFaceResources;
4 import org.eclipse.jface.resource.LocalResourceManager;
5 import org.eclipse.jface.resource.ResourceManager;
6 import org.eclipse.swt.widgets.Composite;
7 import org.eclipse.swt.widgets.Control;
8 import org.eclipse.ui.IWorkbenchSite;
10 public class SWTRoot extends SWTParentNode implements ISWTViewNode {
12 private static final long serialVersionUID = -3208359073385767918L;
14 private final IWorkbenchSite site;
16 private LocalResourceManager resourceManager;
18 private Composite body;
20 public SWTRoot(IWorkbenchSite site) {
29 public SWTRoot getRootNode() {
30 // This is a root node!
34 public ResourceManager getResourceManager() {
35 if (resourceManager == null)
36 throw new IllegalStateException("resource manager is null");
37 return resourceManager;
40 public ResourceManager peekResourceManager() {
41 return resourceManager;
45 public Control getControl() {
50 public IWorkbenchSite getSite() {
54 public void setFocus() {
58 public void setVisible(boolean value) {
59 body.setVisible(value);
62 public void createControls(Composite parent) {
64 resourceManager = new LocalResourceManager(JFaceResources.getResources(), body);
65 for(ISWTViewNode child : children.values()) child.createControls(body);
68 public Control getSingleChild() {
69 if(children.size() != 1) throw new IllegalStateException("SWTRoot should have exactly one child (has " + children.size() + ").");
70 return children.values().iterator().next().getControl();