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