/******************************************************************************* * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package fi.vtt.simantics.processeditor.monitors; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.simantics.db.Graph; import org.simantics.db.Resource; import org.simantics.layer0.utils.EntityFactory; import org.simantics.layer0.utils.IEntity; import org.simantics.layer0.utils.ResourceDebugUtils; import fi.vtt.simantics.processeditor.ProcessResource; public class ObjectPropertyProvider implements MonitorTextProvider { private Resource instance; private Resource properties[]; String name; public void setSource(IEntity instance) { this.instance = instance.getResource(); Collection props = instance.getRelatedObjects(ProcessResource.builtins.HasProperty); List res = new ArrayList(); for (IEntity t : props) res.add(t.getResource()); properties = new Resource[res.size()]; properties = res.toArray(properties); name = ResourceDebugUtils.getReadableNameForEntity(instance); } public ArrayList getTexts(Graph graph) { ArrayList titles = new ArrayList(); if (instance == null) return titles; IEntity thing = EntityFactory.create(graph,instance); name = ResourceDebugUtils.getReadableNameForEntity(thing); titles.add(name); for (Resource p : properties) { thing = EntityFactory.create(graph,p); //if (p.isInstanceOf(Builtins.Double)) { //typeResources = p.getRelatedResources(Builtins.InstanceOf); //name = PropertyUtils.getScalarStringProperty(typeResources[0],Builtins.HasName); name = ResourceDebugUtils.getReadableNameForEntity(thing); titles.add(name); //} } return titles; } }