]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/content/Viewpoint.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.browsing.ui / src / org / simantics / browsing / ui / content / Viewpoint.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.content;
13
14 import org.simantics.browsing.ui.GraphExplorer;
15 import org.simantics.browsing.ui.NodeContext;
16 import org.simantics.browsing.ui.PrimitiveQueryUpdater;
17
18 /**
19  * A Viewpoint is used for describing the child node generation of a single UI
20  * (e.g. tree) node. Viewpoints are created on a per UI node basis, including
21  * the invisible root input of provided to
22  * {@link GraphExplorer#setRoot(Object)}. Viewpoints are created by
23  * {@link ViewpointFactory}s.
24  * 
25  * <p>
26  * A Viewpoint is responsible for informing of any changes happening in the set
27  * of children provided by it. Updates are performed using the
28  * {@link PrimitiveQueryUpdater} received by the {@link ViewpointFactory} that
29  * created the Viewpoint. To signal that the set of children has (possibly)
30  * changed, invoke
31  * {@link PrimitiveQueryUpdater#scheduleReplace(NodeContext, org.simantics.browsing.ui.NodeContext.PrimitiveQueryKey, Object)}
32  * and eventually the query system will re-request the viewpoint for the new
33  * children.
34  * </p>
35  * 
36  * @author Antti Villberg
37  * 
38  * @see ViewpointStub
39  */
40 public interface Viewpoint {
41
42     static final NodeContext[] PENDING_CHILDREN     = {};
43     static final Boolean        PENDING_HAS_CHILDREN = new Boolean(false);
44
45     /**
46      * @return an array of child contexts
47      */
48     NodeContext[] getChildren();
49
50     /**
51      * @return <code>true</code> if the viewpoint <em>may</em> produce > 0,
52      *         <code>false</code> otherwise.
53      */
54     Boolean getHasChildren();
55
56 }