X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram.profile%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fprofile%2Fview%2FAvailableGroups.java;h=2e9f16a13ef37f8432b350274fb58d76dd3f3952;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=67c16a7543562e6d9aaf6fdbc20f3db75e628307;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/AvailableGroups.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/AvailableGroups.java index 67c16a754..2e9f16a13 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/AvailableGroups.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/AvailableGroups.java @@ -1,49 +1,49 @@ -/******************************************************************************* - * 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.diagram.profile.view; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ObjectsWithType; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.adapter.Instances; -import org.simantics.diagram.stubs.DiagramResource; - -public class AvailableGroups extends ViewpointContributor { - - @Override - public Collection getContribution(ReadGraph graph, Resource runtimeDiagram) throws DatabaseException { - - DiagramResource dr = DiagramResource.getInstance(graph); - String modelURI = graph.getPossibleRelatedValue((Resource)runtimeDiagram, dr.RuntimeDiagram_HasModelURI); - if (modelURI == null) - return Collections.emptyList(); - - Resource model = graph.getPossibleResource(modelURI); - if (model == null) - return Collections.emptyList(); - - Instances query = graph.adapt(dr.Group, Instances.class); - - ArrayList result = new ArrayList(); - result.addAll(query.find(graph, model)); - result.addAll(graph.syncRequest(new ObjectsWithType(model, L0.ConsistsOf, dr.Group))); - return result; - - } - -} +/******************************************************************************* + * 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.diagram.profile.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.adapter.Instances; +import org.simantics.diagram.stubs.DiagramResource; + +public class AvailableGroups extends ViewpointContributor { + + @Override + public Collection getContribution(ReadGraph graph, Resource runtimeDiagram) throws DatabaseException { + + DiagramResource dr = DiagramResource.getInstance(graph); + String modelURI = graph.getPossibleRelatedValue((Resource)runtimeDiagram, dr.RuntimeDiagram_HasModelURI); + if (modelURI == null) + return Collections.emptyList(); + + Resource model = graph.getPossibleResource(modelURI); + if (model == null) + return Collections.emptyList(); + + Instances query = graph.adapt(dr.Group, Instances.class); + + ArrayList result = new ArrayList(); + result.addAll(query.find(graph, model)); + result.addAll(graph.syncRequest(new ObjectsWithType(model, L0.ConsistsOf, dr.Group))); + return result; + + } + +}