--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.image.ui.modelBrowser;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.image2.ontology.ImageResource;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class Image extends ViewpointContributor<ImagesNode> {\r
+\r
+ @Override\r
+ public final Collection<?> getContribution(ReadGraph graph, ImagesNode lib) throws DatabaseException {\r
+ ArrayList<AbstractNode<?>> result = new ArrayList<AbstractNode<?>>();\r
+ Read<Collection<Resource>> read = getChildRequest(graph, lib);\r
+ if (read != null) {\r
+ for (Resource r : graph.syncRequest(read)) {\r
+ try {\r
+ AbstractNode<?> n = graph.adapt(r, AbstractNode.class);\r
+ result.add(n);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+ protected Read<Collection<Resource>> getChildRequest(ReadGraph graph, ImagesNode lib) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ ImageResource IMG = ImageResource.getInstance(graph);\r
+ return new ObjectsWithType(lib.data, L0.ConsistsOf, IMG.Image);\r
+ }\r
+\r
+}\r