X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural.ui%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fui%2FmodelBrowser%2Fcontributions%2FAbstractNodeImager.java;fp=bundles%2Forg.simantics.structural.ui%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fui%2FmodelBrowser%2Fcontributions%2FAbstractNodeImager.java;h=df3a8798d62c7bfae67412279f908fa0aa003f2d;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.structural.ui/src/org/simantics/structural/ui/modelBrowser/contributions/AbstractNodeImager.java b/bundles/org.simantics.structural.ui/src/org/simantics/structural/ui/modelBrowser/contributions/AbstractNodeImager.java new file mode 100644 index 000000000..df3a8798d --- /dev/null +++ b/bundles/org.simantics.structural.ui/src/org/simantics/structural/ui/modelBrowser/contributions/AbstractNodeImager.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.structural.ui.modelBrowser.contributions; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.simantics.browsing.ui.swt.ImagerContributor; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode; +import org.simantics.ui.icons.ImageDescriptorProvider; + +public class AbstractNodeImager extends ImagerContributor { + + @Override + public ImageDescriptor getDescriptor(ReadGraph graph, AbstractNode node) throws DatabaseException { + if (!graph.hasStatement(node.resource)) + return null; + ImageDescriptorProvider provider = graph.getPossibleAdapter(node.resource, ImageDescriptorProvider.class); + return provider != null ? provider.get() : null; + } + +}