X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FmodelBrowser%2Fmodel%2FModel.java;h=38412b434cc9431ea51c3a6f5a7f91ec05679365;hb=aa5e7bb5d56b050cfbd2e4a5ab2cc4fdfe40850b;hp=55635f98a0644e65367f5958f0171cfd5e4d7036;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Model.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Model.java index 55635f98a..38412b434 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Model.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Model.java @@ -1,124 +1,124 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * 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 org.simantics.modeling.ui.modelBrowser.model; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.common.node.IModifiable; -import org.simantics.browsing.ui.content.Labeler.Modifier; -import org.simantics.browsing.ui.graph.impl.LabelModifier; -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.Session; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.modeling.ui.Activator; -import org.simantics.simulation.ontology.SimulationResource; - -@Deprecated -public class Model extends Node implements IModifiable { - - final static boolean showFolders = true; - - Resource configuration; - Session session; - - public Model(ReadGraph g, Resource resource) throws DatabaseException { - super(resource); - this.configuration = g.getPossibleObject(resource, SimulationResource.getInstance(g).HasConfiguration); - this.session = g.getSession(); - } - - public File getModelDir() throws DatabaseException { - IPath location = Platform.getLocation(); - File f = location.toFile(); - - String modelName = - (String) session.syncRequest( - org.simantics.db.common.request.Queries.getRelatedValue(resource, Layer0.URIs.HasName, Bindings.STRING)); - - File modelDir = new File(f, modelName); - return modelDir; - } - - @Override - public Collection getChildren(ReadGraph g) throws DatabaseException { - Collection ret = new ArrayList(3); - if(configuration != null) { - ret.add(new Decorator(g.adapt(configuration, INode.class)) { - @Override - public String getLabel(ReadGraph g) { - return "Configuration"; - } - }); - } - ret.add(new Experiments(resource)); - ret.add(new States(resource)); -// ret.add(new Queries(g, resource)); - ret.add(new Charts(resource)); - ret.add(new Subscriptions(resource)); - ret.add(new Images(resource)); -// ret.add(new Spreadsheets(resource)); - ret.add(new RelationViews(resource)); - - /*if(!showFolders) { - ArrayList flatten = new ArrayList(); - for(INode n : ret) - flatten.addAll(n.getChildren(g)); - return flatten; - }*/ - return ret; - } - - @Override - public ImageDescriptor getImage(ReadGraph g) { - return Activator.MODEL_ICON; - } - - @Override - public boolean equals(Object obj) { - if(this == obj) - return true; - if(obj == null) - return false; - if(!getClass().equals(obj.getClass())) - return false; - Model other = (Model)obj; - if(configuration == null) { - return resource.equals(other.resource) && other.configuration == null; - } else { - return resource.equals(other.resource) - && configuration.equals(other.configuration); - } - } - - @Override - public int hashCode() { - if(configuration == null) { - return getClass().hashCode()*31 + resource.hashCode(); - } else { - return (getClass().hashCode()*31 - + configuration.hashCode())*31 + resource.hashCode(); - } - } - - @Override - public Modifier getModifier(final Session session, String columnId) { - return new LabelModifier(session, resource); - } -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * 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 org.simantics.modeling.ui.modelBrowser.model; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.simantics.browsing.ui.common.node.IModifiable; +import org.simantics.browsing.ui.content.Labeler.Modifier; +import org.simantics.browsing.ui.graph.impl.LabelModifier; +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.modeling.ui.Activator; +import org.simantics.simulation.ontology.SimulationResource; + +@Deprecated +public class Model extends Node implements IModifiable { + + final static boolean showFolders = true; + + Resource configuration; + Session session; + + public Model(ReadGraph g, Resource resource) throws DatabaseException { + super(resource); + this.configuration = g.getPossibleObject(resource, SimulationResource.getInstance(g).HasConfiguration); + this.session = g.getSession(); + } + + public File getModelDir() throws DatabaseException { + IPath location = Platform.getLocation(); + File f = location.toFile(); + + String modelName = + (String) session.syncRequest( + org.simantics.db.common.request.Queries.getRelatedValue(resource, Layer0.URIs.HasName, Bindings.STRING)); + + File modelDir = new File(f, modelName); + return modelDir; + } + + @Override + public Collection getChildren(ReadGraph g) throws DatabaseException { + Collection ret = new ArrayList(3); + if(configuration != null) { + ret.add(new Decorator(g.adapt(configuration, INode.class)) { + @Override + public String getLabel(ReadGraph g) { + return "Configuration"; + } + }); + } + ret.add(new Experiments(resource)); + ret.add(new States(resource)); +// ret.add(new Queries(g, resource)); + ret.add(new Charts(resource)); + ret.add(new Subscriptions(resource)); + ret.add(new Images(resource)); +// ret.add(new Spreadsheets(resource)); + ret.add(new RelationViews(resource)); + + /*if(!showFolders) { + ArrayList flatten = new ArrayList(); + for(INode n : ret) + flatten.addAll(n.getChildren(g)); + return flatten; + }*/ + return ret; + } + + @Override + public ImageDescriptor getImage(ReadGraph g) { + return Activator.MODEL_ICON; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) + return true; + if(obj == null) + return false; + if(!getClass().equals(obj.getClass())) + return false; + Model other = (Model)obj; + if(configuration == null) { + return resource.equals(other.resource) && other.configuration == null; + } else { + return resource.equals(other.resource) + && configuration.equals(other.configuration); + } + } + + @Override + public int hashCode() { + if(configuration == null) { + return getClass().hashCode()*31 + resource.hashCode(); + } else { + return (getClass().hashCode()*31 + + configuration.hashCode())*31 + resource.hashCode(); + } + } + + @Override + public Modifier getModifier(final Session session, String columnId) { + return new LabelModifier(session, resource); + } +}