]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalInfoBean.java
Fixed ComponentTypeCommands.setUnit to support unit == null
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / typicals / TypicalInfoBean.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
3  * 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.modeling.typicals;
13
14 import java.util.Map;
15 import java.util.Set;
16
17 import org.simantics.databoard.Bindings;
18 import org.simantics.databoard.annotations.Identifier;
19 import org.simantics.databoard.annotations.Optional;
20 import org.simantics.databoard.binding.Binding;
21 import org.simantics.databoard.util.Bean;
22 import org.simantics.db.Resource;
23
24 /**
25  * Information structure for a single typical diagram instance diagram.
26  * 
27  * @author Tuukka Lehtonen
28  */
29 public class TypicalInfoBean extends Bean.Id {
30
31     public static final Binding BINDING = Bindings.getBindingUnchecked(TypicalInfoBean.class);
32
33     /**
34      * All DIA.Elements in the typical diagram instance.
35      */
36     @Identifier public Set<Resource>           instanceElements;
37
38     /**
39      * Maps all typical diagram instance elements to template elements where
40      * a MOD.HasElementSource mapping exists.
41      */
42     @Identifier public Map<Resource, Resource> instanceToTemplate;
43
44     /**
45      * Inverse map of {@link #instanceToTemplate}
46      */
47     public Map<Resource, Resource>             templateToInstance;
48
49     /**
50      * Describes the set of DIA.Elements that are marked with
51      * MOD.IsTemplatized tag.
52      */
53     @Identifier public Set<Resource>           isTemplatized;
54
55     /**
56      * Current set of template diagram elements.
57      */
58     @Optional public transient Set<Resource>   templateElements;
59
60     /**
61      * Auxiliary transient data passed on during synchronization.
62      */
63     @Optional public transient Map<Object, Object> auxiliary;
64
65     public TypicalInfoBean() {
66         super(BINDING);
67     }
68
69     @SuppressWarnings("unchecked")
70     public <T> T getAux(Object key) {
71         return auxiliary == null ? null : (T) auxiliary.get(key);
72     }
73
74 }