X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FmodelBrowser2%2Fcontributions%2FDependenciesViewContributor.java;h=4932cb0f5c3d0f695e498d7b7e657a91a57d8e67;hp=c075530345c049cbd182cde30fc2753f98fb87cf;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/contributions/DependenciesViewContributor.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/contributions/DependenciesViewContributor.java index c07553034..4932cb0f5 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/contributions/DependenciesViewContributor.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/contributions/DependenciesViewContributor.java @@ -1,57 +1,57 @@ -/******************************************************************************* - * 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.modelBrowser2.contributions; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.Queries; -import org.simantics.db.exception.DatabaseException; -import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode; - -/** - * @author Tuukka Lehtonen - */ -public class DependenciesViewContributor implements RelationViewContributor { - - public Collection getContribution(ReadGraph graph, Collection> indexedResults) throws DatabaseException { - ArrayList result = new ArrayList(); - - for(Map entry : indexedResults) { - Object resource = entry.get("Resource"); - if (resource != null) { - AbstractNode node = graph.syncRequest(Queries.adapt((Resource) resource, AbstractNode.class, true)); - if (node != null) { - result.add(node); - } else { - result.add(resource); - } - } else { - Object name = entry.get("Name"); - if (name != null) { - result.add(name); - } else { - StringBuilder b = new StringBuilder(); - for (Map.Entry e : entry.entrySet()) { - b.append(e.getValue().toString()); - } - result.add(b.toString()); - } - } - } - - 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.modeling.ui.modelBrowser2.contributions; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.Queries; +import org.simantics.db.exception.DatabaseException; +import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode; + +/** + * @author Tuukka Lehtonen + */ +public class DependenciesViewContributor implements RelationViewContributor { + + public Collection getContribution(ReadGraph graph, Collection> indexedResults) throws DatabaseException { + ArrayList result = new ArrayList(); + + for(Map entry : indexedResults) { + Object resource = entry.get("Resource"); + if (resource != null) { + AbstractNode node = graph.syncRequest(Queries.adapt((Resource) resource, AbstractNode.class, true)); + if (node != null) { + result.add(node); + } else { + result.add(resource); + } + } else { + Object name = entry.get("Name"); + if (name != null) { + result.add(name); + } else { + StringBuilder b = new StringBuilder(); + for (Map.Entry e : entry.entrySet()) { + b.append(e.getValue().toString()); + } + result.add(b.toString()); + } + } + } + + return result; + } +}