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;
14 import org.simantics.browsing.ui.NodeContext;
15 import org.simantics.browsing.ui.PrimitiveQueryUpdater;
16 import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;
17 import org.simantics.browsing.ui.common.labelers.LabelerContent;
18 import org.simantics.db.AsyncReadGraph;
19 import org.simantics.db.procedure.Listener;
20 import org.simantics.db.procedure.Procedure;
21 import org.simantics.utils.ui.ErrorLogger;
24 * Implement {@link #children(AsyncReadGraph)} and {@link #hasChildren(AsyncReadGraph)}.
26 * @author Tuukka Lehtonen
28 abstract public class LabelerContributionImpl extends FinalLabelerContributionImpl {
30 public LabelerContributionImpl(PrimitiveQueryUpdater updater,
31 NodeContext context, LabelerKey key) {
32 super(updater, context, key);
36 protected Procedure<LabelerContent> createProcedure() {
38 return new Listener<LabelerContent>() {
40 boolean executed = false;
41 boolean disposed = false;
44 public void execute(LabelerContent result) {
45 replaceResult(result);
50 public boolean isDisposed() {
52 if(disposed) return true;
54 if((updater.isDisposed() || !updater.isShown(context)) && executed) {
55 setContent(LabelerContent.NO_CONTENT);
65 public void exception(Throwable t) {
66 ErrorLogger.defaultLogError("LazyContributionImpl.childQuery failed, see exception for details.", t);