]> gerrit.simantics Code Review - simantics/platform.git/blob - modelBrowser/model/States.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / modelBrowser / model / States.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.modeling.ui.modelBrowser.model;
13
14 import java.util.ArrayList;
15 import java.util.Collection;
16
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.Resource;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.layer0.Layer0;
22 import org.simantics.modeling.ui.Activator;
23 import org.simantics.simulation.ontology.SimulationResource;
24
25 @Deprecated
26 public class States extends Node {
27
28     public States(Resource resource) {
29         super(resource);
30     }
31
32     @Override
33     public Resource getResource() {
34         return resource;
35     }
36
37     @Override
38     public String getLabel(ReadGraph g) {
39         return "States";
40     }
41
42     @Override
43     public Collection<?> getChildren(ReadGraph g) throws DatabaseException {
44         Layer0 b = Layer0.getInstance(g);
45         SimulationResource SIMU = SimulationResource.getInstance(g);
46         Collection<INode> ret = new ArrayList<INode>();
47         for (Resource r : g.getObjects(resource, b.ConsistsOf)) {
48             if (g.isInstanceOf(r, SIMU.State)) {
49                 ret.add(g.adapt(r, INode.class));
50             }
51         }
52         return ret;
53     }
54
55     @Override
56     public ImageDescriptor getImage(ReadGraph g) {
57         return Activator.STATES_ICON;
58     }
59
60     @SuppressWarnings("unchecked")
61     @Override
62     public Object getAdapter(Class adapter) {
63         // deny adaptability, prevent showing of properties this way.
64         return null;
65     }
66
67 }