]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contribution/ViewpointContributionImpl.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / contribution / ViewpointContributionImpl.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.browsing.ui.graph.impl.contribution;
13
14 import java.util.Collection;
15
16 import org.simantics.browsing.ui.NodeContext;
17 import org.simantics.browsing.ui.PrimitiveQueryUpdater;
18 import org.simantics.browsing.ui.BuiltinKeys.ViewpointContributionKey;
19 import org.simantics.db.AsyncReadGraph;
20 import org.simantics.db.procedure.Listener;
21 import org.simantics.db.procedure.Procedure;
22 import org.simantics.utils.ui.ErrorLogger;
23
24 /**
25  * Implement {@link #children(AsyncReadGraph)} and {@link #hasChildren(AsyncReadGraph)}.
26  * 
27  * @author Tuukka Lehtonen
28  */
29 abstract public class ViewpointContributionImpl extends FinalViewpointContributionImpl {
30
31     public ViewpointContributionImpl(PrimitiveQueryUpdater updater,
32             NodeContext context, ViewpointContributionKey key) {
33         super(updater, context, key);
34     }
35
36     @Override
37     protected Procedure<Collection<NodeContext>> createProcedure() {
38
39         return new Listener<Collection<NodeContext>>() {
40
41             @Override
42             public void execute(Collection<NodeContext> result) {
43                 replaceChildrenResult(result);
44             }
45
46             @Override
47             public boolean isDisposed() {
48                 return updater.isDisposed();
49             }
50
51             public void exception(Throwable t) {
52                 ErrorLogger.defaultLogError("LazyContributionImpl.childQuery failed, see exception for details.", t);
53             }
54
55             @Override
56             public String toString() {
57                 return "LazyContributionImpl[" + System.identityHashCode(ViewpointContributionImpl.this) + "].childProcedure";
58             }
59
60         };
61
62     }
63
64
65 }