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