1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.browser.contributions;
\r
14 import org.eclipse.jface.resource.ImageDescriptor;
\r
15 import org.simantics.browsing.ui.common.node.AbstractNode;
\r
16 import org.simantics.browsing.ui.swt.ImagerContributor;
\r
17 import org.simantics.db.ReadGraph;
\r
18 import org.simantics.db.Resource;
\r
19 import org.simantics.db.exception.DatabaseException;
\r
20 import org.simantics.sysdyn.SysdynResource;
\r
21 import org.simantics.sysdyn.ui.Activator;
\r
22 import org.simantics.sysdyn.ui.browser.nodes.BookNode;
\r
23 import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;
\r
24 import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;
\r
25 import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;
\r
26 import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;
\r
27 import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;
\r
28 import org.simantics.sysdyn.ui.browser.nodes.InputNode;
\r
29 import org.simantics.sysdyn.ui.browser.nodes.ModelNode;
\r
30 import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;
\r
31 import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;
\r
32 import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;
\r
33 import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode;
\r
34 import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;
\r
35 import org.simantics.sysdyn.ui.browser.nodes.SheetNode;
\r
36 import org.simantics.sysdyn.ui.browser.nodes.VariableNode;
\r
38 public class AbstractNodeImager extends ImagerContributor<AbstractNode<Resource>> {
\r
41 public ImageDescriptor getDescriptor(ReadGraph graph, AbstractNode<Resource> node) throws DatabaseException {
\r
43 String image = null;
\r
44 if (node instanceof SharedFunctionsFolder)
\r
45 image = "icons/folder_link.png";
\r
46 else if (node instanceof ExperimentsFolder ||
\r
47 node instanceof ModulesNode ||
\r
48 node instanceof FunctionsFolder ||
\r
49 node instanceof FunctionLibraryNode ||
\r
50 node instanceof SharedFunctionLibraryNode)
\r
51 image = "icons/folder.png";
\r
52 else if (node instanceof ModuleTypeNode || node instanceof ModuleNode || node instanceof ConfigurationNode)
\r
53 image = "icons/bricks.png";
\r
54 else if (node instanceof ExperimentNode) {
\r
55 SysdynResource sr = SysdynResource.getInstance(graph);
\r
56 if(graph.isInstanceOf(node.data, sr.PlaybackExperiment))
\r
57 image = "icons/timeline_marker.png";
\r
59 image = "icons/time.png";
\r
60 } else if (node instanceof InputNode)
\r
61 image = "icons/brick_link.png";
\r
62 else if (node instanceof ModelNode)
\r
63 image = "icons/chart_organisation.png";
\r
64 else if (node instanceof VariableNode)
\r
65 image = "icons/brick.png";
\r
66 else if (node instanceof BookNode)
\r
67 image = "icons/table_multiple.png";
\r
68 else if (node instanceof SheetNode)
\r
69 image = "icons/table.png";
\r
72 return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource(image));
\r