]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/ui/DiagramModelHints.java
84a25f2de4654eb489bed7460f8a5e1cd8f91c2a
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / ui / DiagramModelHints.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2019 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  *     Semantum Oy - gitlab #399
12  *******************************************************************************/
13 package org.simantics.diagram.ui;
14
15 import java.util.Set;
16
17 import org.simantics.db.Resource;
18 import org.simantics.db.UndoContext;
19 import org.simantics.db.common.ResourceArray;
20 import org.simantics.diagram.adapter.ConnectionVisualsLoader;
21 import org.simantics.diagram.adapter.ElementFactory;
22 import org.simantics.diagram.adapter.IDiagramLoader;
23 import org.simantics.diagram.synchronization.graph.ElementLoader;
24 import org.simantics.diagram.synchronization.graph.ElementWriter;
25 import org.simantics.g2d.canvas.ICanvasContext;
26 import org.simantics.g2d.diagram.IDiagram;
27 import org.simantics.simulation.experiment.IExperiment;
28 import org.simantics.structural2.modelingRules.IModelingRules;
29 import org.simantics.utils.datastructures.hints.IHintContext.Key;
30 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
31
32 /**
33  * 
34  * @Author Toni Kalajainen
35  */
36 public class DiagramModelHints {
37
38     public static final Key KEY_DIAGRAM_RESOURCE = new KeyOf(Resource.class, "DIAGRAM_RESOURCE");
39
40     public static final Key KEY_DIAGRAM_MODEL_URI = new KeyOf(String.class, "DIAGRAM_MODEL_URI");
41
42     public static final Key KEY_DIAGRAM_RUNTIME_RESOURCE = new KeyOf(Resource.class, "DIAGRAM_RUNTIME_RESOURCE");
43
44     public static final Key KEY_DIAGRAM_RESOURCE_ARRAY = new KeyOf(ResourceArray.class, "DIAGRAM_RESOURCE_ARRAY");
45
46     /**
47      * Holds a value of Set<String> which should contain the type {@link Resource}
48      * URIs of all the types of the diagram resource. This allows doing
49      * type-checking for the diagram based on pure string instead of having to do
50      * database transactions to check types.
51      */
52     public static final Key KEY_DIAGRAM_RESOURCE_TYPE_URIS = new KeyOf(Set.class, "DIAGRAM_RESOURCE_TYPE_URIS");
53
54     /**
55      * Holds a value of Set<String> which should contain the type {@link Resource}
56      * URIs of all the types of the composite resource mapped to the diagram
57      * resource. This allows doing type-checking for the diagram based on pure
58      * string instead of having to do database transactions to check types.
59      */
60     public static final Key KEY_MAPPED_COMPOSITE_RESOURCE_TYPE_URIS = new KeyOf(Set.class, "MAPPED_DIAGRAM_COMPOSITE_RESOURCE_TYPE_URIS");
61
62     /**
63      * Set to the object value if the current diagram editor has a single
64      * statement/object for the {@link ModelingResources#URIs#HasDiagramSource}
65      * relation.
66      */
67     public static final Key KEY_HAS_DIAGRAM_SOURCE = new KeyOf(Resource.class, "MOD.HasDiagramSource");
68
69     /**
70      * A hint for defining and extra pass for loading/initializing an element
71      * after the current pass. It is possible to request for infinitely many
72      * passes by always setting a new ElementLoader hint into the loaded element
73      * during loading. The loading process will loop until none of the loaded
74      * elements have a loader hint. An {@link ElementFactory} or
75      * {@link ElementLoader} is only allowed to set this hint on the element it
76      * is loading, not on any other element.
77      */
78     public static final Key KEY_ELEMENT_LOADER = new KeyOf(ElementLoader.class, "ELEMENT_LOADER");
79
80     /**
81      * Allows customizable external control over how the an IElement gets
82      * written into backing storage (graph) when it is added to a diagram.
83      * 
84      * This hint will be removed after it has been used by the synchronizer.
85      */
86     public static final Key KEY_ELEMENT_WRITER = new KeyOf(ElementWriter.class, "ELEMENT_WRITER");
87
88     /**
89      * TODO: what is this for?
90      */
91     public static final Key KEY_ACTIVE_EXPERIMENT = new KeyOf(IExperiment.class, "ACTIVE_EXPERIMENT");
92
93     /**
94      * Operating UI requires this for some unknown reason.
95      * TODO: find out what this is
96      */
97     public static final Key KEY_SESSION_ID = new KeyOf(String.class, "SESSION_ID");
98
99     /**
100      * Externally definable rules for topological modeling, i.e. how nodes and
101      * edges and their connectivity is bounded.
102      */
103     public static final Key KEY_MODELING_RULES = new KeyOf(IModelingRules.class, "MODELING_RULES");
104
105     /**
106      * For customizing how connection segments are loaded for a diagram. Give
107      * this hint as an initial hint to {@link IDiagramLoader} to use your own
108      * version in diagram loading.
109      */
110     public static final Key KEY_CONNECTION_VISUALS_LOADER = new KeyOf(ConnectionVisualsLoader.class, "CONNECTION_VISUALS_LOADER");
111
112     /**
113      * For storing an {@link UndoContext} in {@link IDiagram} or
114      * {@link ICanvasContext}.
115      * 
116      * @deprecated to be removed down, do not use anymore
117      */
118     public static final Key KEY_UNDO_CONTEXT = new KeyOf(UndoContext.class, "UNDO_CONTEXT");
119
120     /**
121      * An informational hint that functions only as a trigger for listeners to
122      * tell that the diagram contents have changed and that the changes have
123      * been noticed and updated into the runtime diagram model ({@link IDiagram}
124      * ). The hint is given the value {@link Boolean#TRUE} every time the update
125      * happens, i.e. the value is of no importance, only the trigger aspect is.
126      */
127     public static final Key KEY_DIAGRAM_CONTENTS_UPDATED = new KeyOf(Boolean.class, "DIAGRAM_CONTENTS_UPDATED");
128
129
130 }