1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.graph.impl.contribution;
\r
14 import java.util.Map;
\r
16 import org.eclipse.jface.resource.ImageDescriptor;
\r
17 import org.simantics.browsing.ui.BuiltinKeys.ImagerKey;
\r
18 import org.simantics.browsing.ui.NodeContext;
\r
19 import org.simantics.browsing.ui.PrimitiveQueryUpdater;
\r
20 import org.simantics.db.AsyncReadGraph;
\r
21 import org.simantics.db.procedure.Listener;
\r
22 import org.simantics.db.procedure.Procedure;
\r
23 import org.simantics.utils.ui.ErrorLogger;
\r
26 * Implement {@link #children(AsyncReadGraph)} and {@link #hasChildren(AsyncReadGraph)}.
\r
28 * @author Tuukka Lehtonen
\r
30 @SuppressWarnings("unchecked")
\r
31 public abstract class ImagerContributionImpl extends FinalImagerContributionImpl {
\r
33 public ImagerContributionImpl(PrimitiveQueryUpdater updater,
\r
34 NodeContext context, ImagerKey key) {
\r
35 super(updater, context, key);
\r
39 protected Procedure<Map<String, ImageDescriptor>> createProcedure() {
\r
41 return new Listener<Map<String, ImageDescriptor>>() {
\r
43 boolean executed = false;
\r
44 boolean disposed = false;
\r
47 public void execute(Map<String, ImageDescriptor> result) {
\r
48 replaceResult(result);
\r
53 public boolean isDisposed() {
\r
55 if(disposed) return true;
\r
57 if((updater.isDisposed() || !updater.isShown(context)) && executed) {
\r
68 public void exception(Throwable t) {
\r
69 ErrorLogger.defaultLogError("ImagerContributionImpl.imagerQuery failed, see exception for details.", t);
\r