1 /*******************************************************************************
\r
2 * Copyright (c) 2007- VTT Technical Research Centre of Finland.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.processeditor.monitors;
\r
13 import java.util.ArrayList;
\r
14 import java.util.Collection;
\r
15 import java.util.List;
\r
17 import org.simantics.db.Graph;
\r
18 import org.simantics.db.Resource;
\r
19 import org.simantics.layer0.utils.EntityFactory;
\r
20 import org.simantics.layer0.utils.IEntity;
\r
21 import org.simantics.layer0.utils.ResourceDebugUtils;
\r
22 import org.simantics.processeditor.ProcessResource;
\r
27 public class ObjectPropertyProvider implements MonitorTextProvider {
\r
29 private Resource instance;
\r
30 private Resource properties[];
\r
33 public void setSource(IEntity instance) {
\r
34 this.instance = instance.getResource();
\r
35 Collection<IEntity> props = instance.getRelatedObjects(ProcessResource.builtins.HasProperty);
\r
36 List<Resource> res = new ArrayList<Resource>();
\r
37 for (IEntity t : props)
\r
38 res.add(t.getResource());
\r
39 properties = new Resource[res.size()];
\r
40 properties = res.toArray(properties);
\r
41 name = ResourceDebugUtils.getReadableNameForEntity(instance);
\r
44 public ArrayList<String> getTexts(Graph graph) {
\r
45 ArrayList<String> titles = new ArrayList<String>();
\r
46 if (instance == null)
\r
48 IEntity thing = EntityFactory.create(graph,instance);
\r
49 name = ResourceDebugUtils.getReadableNameForEntity(thing);
\r
52 for (Resource p : properties) {
\r
53 thing = EntityFactory.create(graph,p);
\r
54 //if (p.isInstanceOf(Builtins.Double)) {
\r
55 //typeResources = p.getRelatedResources(Builtins.InstanceOf);
\r
56 //name = PropertyUtils.getScalarStringProperty(typeResources[0],Builtins.HasName);
\r
57 name = ResourceDebugUtils.getReadableNameForEntity(thing);
\r