X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.graph.impl%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fgraph%2Fimpl%2Fcontributor%2Fimager%2FImagerContributorImpl.java;h=ba63fd4e9213979f15382e4db710b64ac4a8931c;hp=672ccdb7cb261942ee110fa949ba24c0559ab690;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/imager/ImagerContributorImpl.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/imager/ImagerContributorImpl.java index 672ccdb7c..ba63fd4e9 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/imager/ImagerContributorImpl.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/imager/ImagerContributorImpl.java @@ -1,97 +1,97 @@ -/******************************************************************************* - * 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.browsing.ui.graph.impl.contributor.imager; - -import java.util.Map; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.BuiltinKeys; -import org.simantics.browsing.ui.BuiltinKeys.ImagerKey; -import org.simantics.browsing.ui.NodeContext; -import org.simantics.browsing.ui.PrimitiveQueryUpdater; -import org.simantics.browsing.ui.Tester; -import org.simantics.browsing.ui.common.ColumnKeys; -import org.simantics.browsing.ui.content.Contributor; -import org.simantics.browsing.ui.content.Imager; -import org.simantics.browsing.ui.content.ImagerFactory; -import org.simantics.browsing.ui.graph.impl.contribution.ImagerContributionImpl; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.utils.ReflectionUtils; -import org.simantics.utils.datastructures.ArrayMap; - -abstract public class ImagerContributorImpl implements Contributor { - - abstract public ImageDescriptor getDescriptor(ReadGraph graph, T input) throws DatabaseException; - - final private Class clazz; - - @Override - public String toString() { - return getClass().getName(); - } - - @Override - public Tester getNodeContextTester() { - return null; - } - - public ImagerContributorImpl() { - clazz = ReflectionUtils.getSingleParameterType(getClass()); - } - - public ImagerContributorImpl(Class clazz) { - this.clazz = clazz; - } - - @Override - public ImagerFactory getFactory() { - - return new ImagerFactory() { - - @Override - public String toString() { - return ImagerContributorImpl.this.toString(); - } - - @SuppressWarnings("unchecked") - @Override - public Imager create(final PrimitiveQueryUpdater updater, NodeContext context, final ImagerKey key) { - - return new ImagerContributionImpl(updater, context, key) { - - @Override - public Map getDescriptors(ReadGraph graph, NodeContext context) throws DatabaseException { - - T input = (T)context.getConstant(BuiltinKeys.INPUT); - - ImageDescriptor value = ImagerContributorImpl.this.getDescriptor(graph, input); - - return new ArrayMap(ColumnKeys.KEYS_SINGLE, - new ImageDescriptor[] { value }); - - } - - }; - - } - - }; - - } - - @Override - public Class getInputClass() { - return clazz; - } - -} +/******************************************************************************* + * 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.browsing.ui.graph.impl.contributor.imager; + +import java.util.Map; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.simantics.browsing.ui.BuiltinKeys; +import org.simantics.browsing.ui.BuiltinKeys.ImagerKey; +import org.simantics.browsing.ui.NodeContext; +import org.simantics.browsing.ui.PrimitiveQueryUpdater; +import org.simantics.browsing.ui.Tester; +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.content.Contributor; +import org.simantics.browsing.ui.content.Imager; +import org.simantics.browsing.ui.content.ImagerFactory; +import org.simantics.browsing.ui.graph.impl.contribution.ImagerContributionImpl; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.utils.ReflectionUtils; +import org.simantics.utils.datastructures.ArrayMap; + +abstract public class ImagerContributorImpl implements Contributor { + + abstract public ImageDescriptor getDescriptor(ReadGraph graph, T input) throws DatabaseException; + + final private Class clazz; + + @Override + public String toString() { + return getClass().getName(); + } + + @Override + public Tester getNodeContextTester() { + return null; + } + + public ImagerContributorImpl() { + clazz = ReflectionUtils.getSingleParameterType(getClass()); + } + + public ImagerContributorImpl(Class clazz) { + this.clazz = clazz; + } + + @Override + public ImagerFactory getFactory() { + + return new ImagerFactory() { + + @Override + public String toString() { + return ImagerContributorImpl.this.toString(); + } + + @SuppressWarnings("unchecked") + @Override + public Imager create(final PrimitiveQueryUpdater updater, NodeContext context, final ImagerKey key) { + + return new ImagerContributionImpl(updater, context, key) { + + @Override + public Map getDescriptors(ReadGraph graph, NodeContext context) throws DatabaseException { + + T input = (T)context.getConstant(BuiltinKeys.INPUT); + + ImageDescriptor value = ImagerContributorImpl.this.getDescriptor(graph, input); + + return new ArrayMap(ColumnKeys.KEYS_SINGLE, + new ImageDescriptor[] { value }); + + } + + }; + + } + + }; + + } + + @Override + public Class getInputClass() { + return clazz; + } + +}