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