1 /*******************************************************************************
\r
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
\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.g3d.scenegraph.structural;
\r
14 import java.util.ArrayList;
\r
15 import java.util.Collection;
\r
16 import java.util.List;
\r
18 import org.simantics.g3d.ontology.G3D;
\r
19 import org.simantics.g3d.property.annotations.GetPropertyValue;
\r
20 import org.simantics.g3d.property.annotations.SetPropertyValue;
\r
21 import org.simantics.g3d.scenegraph.base.ParentNode;
\r
22 import org.simantics.layer0.Layer0;
\r
23 import org.simantics.objmap.graph.annotations.RelatedGetValue;
\r
24 import org.simantics.objmap.graph.annotations.RelatedSetValue;
\r
25 import org.simantics.objmap.structural.IStructuralObject;
\r
27 public abstract class StructuralParentNode<T extends IStructuralNode> extends ParentNode<T> implements IStructuralNode{
\r
29 private String name;
\r
32 @RelatedGetValue(Layer0.URIs.HasName)
\r
33 @GetPropertyValue(value = Layer0.URIs.HasName, tabId = "Default", name = "Name")
\r
34 public String getName() {
\r
38 @RelatedSetValue(Layer0.URIs.HasName)
\r
39 @SetPropertyValue(Layer0.URIs.HasName)
\r
40 public void setName(String name) {
\r
44 firePropertyChanged(Layer0.URIs.HasName);
\r
48 public String toString() {
\r
52 public boolean isPartOfInstantiatedModel() {
\r
53 return ctx.size() > 0;
\r
56 public boolean isExposed() {
\r
57 if (ctx.size() == 0)
\r
59 return getPublishedBy().contains(ctx.get(0));
\r
63 public boolean isInstantiatedModelRoot() {
\r
64 return ctx.size() == 1 && this.equals(ctx.get(0));
\r
68 public boolean isPublishable() {
\r
69 return !isPartOfInstantiatedModel();
\r
72 private List<IStructuralObject> ctx = new ArrayList<IStructuralObject>(1);
\r
74 public List<IStructuralObject> getContext() {
\r
79 public void setContext(List<IStructuralObject> object) {
\r
83 private List<IStructuralNode> publisher = new ArrayList<IStructuralNode>(1);
\r
86 public void addPublishedBy(IStructuralNode node) {
\r
87 publisher.add(node);
\r
88 firePropertyChanged(G3D.URIs.publishes);
\r
92 public Collection<IStructuralNode> getPublishedBy() {
\r
97 public void removePublishedBy(IStructuralNode node) {
\r
98 if (publisher.remove(node))
\r
99 firePropertyChanged(G3D.URIs.publishes);
\r
103 public void remove() {
\r
104 IStructuralRootNode root = (IStructuralRootNode)getRootNode();
\r
105 if (root.getPublished().contains(this))
\r
106 root.removePublished(this);
\r