blob: 51299bc05d7d8f9d29c418533132e0dbc4a0d9c1 [file] [log] [blame]
mwenz8bcdbbe2010-07-22 13:03:03 +00001<html>
2
3<head>
4<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
5<title>Page Title</title>
6<link rel=Stylesheet type="text/css" media=all href="../book.css"">
7<style>
8/* Font Definitions */
9@font-face {
10 font-family: Tahoma;
11 panose-1: 2 11 6 4 3 5 4 4 2 4;
12}
13
14/* Style Definitions */
15p.MsoNormal,li.MsoNormal,div.MsoNormal {
16 margin: 0cm;
17 margin-bottom: .0001pt;
18 font-size: 12.0pt;
19 font-family: "Times New Roman";
20 color: windowtext;
21}
22
23h1 {
24 margin-top: 12.0pt;
25 margin-right: 0cm;
26 margin-bottom: 3.0pt;
27 margin-left: 0cm;
28 page-break-after: avoid;
29 font-size: 16.0pt;
30 font-weight: bold;
31}
32
33h2 {
34 margin-top: 12.0pt;
35 margin-right: 0cm;
36 margin-bottom: 3.0pt;
37 margin-left: 0cm;
38 page-break-after: avoid;
39 font-size: 14.0pt;
40 font-weight: bold;
41 font-style: italic;
42}
43
44h3 {
45 margin-top: 12.0pt;
46 margin-right: 0cm;
47 margin-bottom: 3.0pt;
48 margin-left: 0cm;
49 page-break-after: avoid;
50 font-size: 13.0pt;
51 font-weight: bold;
52}
53
54h4 {
55 margin-top: 11.25pt;
56 margin-right: 0cm;
57 margin-bottom: 1.7pt;
58 margin-left: 0cm;
59 font-size: 12.0pt;
60 font-weight: bold;
61 font-style: italic;
62}
63
64h5 {
65 margin-right: 0cm;
66 margin-left: 0cm;
67 font-size: 10.0pt;
68 font-weight: bold;
69}
70
71p.MsoCaption,li.MsoCaption,div.MsoCaption {
72 margin-top: 6.0pt;
73 margin-right: 0cm;
74 margin-bottom: 24.0pt;
75 margin-left: 0cm;
76 text-align: justify;
77 font-size: 10.0pt;
78 font-weight: bold;
79}
80
81a:link,span.MsoHyperlink {
82 color: blue;
83 text-decoration: underline;
84}
85
86a:visited,span.MsoHyperlinkFollowed {
87 color: purple;
88 text-decoration: underline;
89}
90
91p {
92 margin-top: 5.65pt;
93 margin-right: 0cm;
94 margin-bottom: 5.65pt;
95 margin-left: 0cm;
96 font-size: 12.0pt;
97}
98
99pre {
100 margin-top: 0cm;
101 margin-right: 0cm;
102 margin-bottom: 0cm;
103 margin-left: 3.4pt;
104 margin-bottom: .0001pt;
105 font-size: 11.0pt;
106}
107
108p.MsoAcetate,li.MsoAcetate,div.MsoAcetate {
109 margin: 0cm;
110 margin-bottom: .0001pt;
111 font-size: 8.0pt;
112 font-family: Tahoma;
113}
114
115p.code,li.code,div.code {
116 margin-top: 0cm;
117 margin-right: 0cm;
118 margin-bottom: 0cm;
119 margin-left: 15.0pt;
120 margin-bottom: .0001pt;
121 font-size: 12.0pt;
122}
123
124p.note,li.note,div.note {
125 margin-top: 19.5pt;
126 margin-right: 0cm;
127 margin-bottom: 19.5pt;
128 margin-left: 30.0pt;
129 font-size: 13.0pt;
130 font-style: italic;
131}
132
133p.comment,li.comment,div.comment {
134 margin-top: 5.65pt;
135 margin-right: 0cm;
136 margin-bottom: 5.65pt;
137 margin-left: 0cm;
138 font-size: 12.0pt;
139 font-weight: bold;
140}
141
142span.code1 {
143 font-style: italic;
144}
145
146@page Section1 {
147 size: 595.45pt 841.7pt;
148 margin: 72.0pt 89.85pt 72.0pt 89.85pt;
149}
150
151div.Section1 {
152 page: Section1;
153}
154</style>
155
156</head>
157
158<body bgcolor=white link=blue vlink=purple style='margin-bottom: 12.0pt'>
159
mwenz8bcdbbe2010-07-22 13:03:03 +0000160<h1><span>Non-EMF Domain Objects</span></h1>
161
mwenz05390352011-04-13 07:53:34 +0000162<p class=MsoNormal>By default Graphiti supports domain models from
mwenz8bcdbbe2010-07-22 13:03:03 +0000163the EMF world and offers automated support for reacting to changes and
164updating the editor. Since not only EObjects but simple POJOs can be
mwenz05390352011-04-13 07:53:34 +0000165passed to all relevant framework APIs, it is also possible to use
166non-EMF domain objects with Graphiti. This page describes the
167differences the user of Graphiti has to deal with when using non-EMF
168domain models.</p>
169
170<h2><span>Domain Model Change Notifications</span></h2>
mwenz8bcdbbe2010-07-22 13:03:03 +0000171<p class=MsoNormal>Of course the framework cannot support automated
172notification to changes in such domain models, so the tool builder needs
173to hook an appropriate listener into the framework. Here's the process
174how to do this:</p>
175
176<ol>
mwenz05390352011-04-13 07:53:34 +0000177 <li class=MsoNormal>Create an appropriate specific domain listener
178 class. As an example you can have a look at DomainModelChangeListener
179 in the Graphiti framework; this class does this job for EMF models.</li>
mwenz8bcdbbe2010-07-22 13:03:03 +0000180 <li class=MsoNormal>Subclass DiagramEditor and override its method
181 registerBOListener. In that method create an instance of your listener
182 from step 1 and register it.</li>
mwenz05390352011-04-13 07:53:34 +0000183 <li class=MsoNormal>Create an appropriate notification service
184 class by subclassing DefaultNotificationService or implementing its
185 interface. An instance of this class is used by the framework to get
186 the connection between domain objects and their graphical
187 representation (method calculateLinkedPictogramElements) and triggers
188 the actual update of the graphical representation in the diagram
tkaisere8678512011-05-03 08:13:54 +0000189 (method updatePictogramElements) using the appropriate update
tkaiser14a43e52011-05-03 08:12:50 +0000190 features. The class DefaultNotificationService does the job for EMF
mwenz05390352011-04-13 07:53:34 +0000191 models.</li>
192 <li class=MsoNormal>In your Diagram Type Provider implementation
193 create and return an instance of the class from step 3 within the
194 method getNotificationService.</li>
mwenz8bcdbbe2010-07-22 13:03:03 +0000195</ol>
mwenz8bcdbbe2010-07-22 13:03:03 +0000196
mwenz05390352011-04-13 07:53:34 +0000197<h2><span>Support for Undo and Redo</span></h2>
198<p class=MsoNormal>For standard EMF domain models users do not need
tkaiser58cb0072011-05-03 08:08:46 +0000199to care about implementing undo/redo functionality within their
mwenz05390352011-04-13 07:53:34 +0000200features. This is all cared about by the framework by using EMF <i>TransactionalCommandStacks</i>
201and <i>RecordingCommands</i> for executing features. But in case users
202have domain models implemented in another technology than EMF, they need
203to care about implementing undo/redo for their domain model changes by
204themself. (The changes done to the graphical representation (Graphiti <i>PictogramElements</i>
205and <i>GraphicsAlgorithms</i>) are still handled automatically.)</p>
206<p class=MsoNormal>In order to provide undo/redo for non-EMF domain
207models users can implement the new interface <i>ICustomUndoableFeature</i>
208within their features. In case a feature implements this interface the
209Graphiti command stack will care about the EMF undo/redo and
210additionally to the standard EMF-undo/redo call the appropriate methods
211(<i>canUndo</i> and <i>undo</i> resp. <i>canRedo</i> and <i>redo</i>)
212within the feature.</p>
213<p class=MsoNormal>Inside the feature coding for those methods users
214can use the information passed (the executed feature instance will be
215called with the instance of its context) to undo the operations done
216while executing the feature. Within the features <i>execute</i> method
217users might add additional information needed to perform the undo to the
218context object.</p>
219<p class=MsoNormal>The decision to implement <i>ICustomUndoableFeature</i>
220can be taken individually for each feature.</p>
221<p class=MsoNormal>For the pattern approach a similar interface has
222been introduced: <i>ICustomUndoablePattern</i>, for which the before
223mentioned also applies accordingly.</p>
224<p class=MsoNormal>By introducing this functionality it is now
225possible for users of Graphiti to implement undo and redo
226functionalities also for non-EMF domain changes; nevertheless this
227functionality might also by used for EMF domain models in case they need
228to implement additional undo/redo functionality.</p>
229<p class=MsoNormal>Still there is one thing to be aware of: All
230changes done inside the Graphiti diagram editor (no matter if EMF
231changes or non-EMF changes) will write an <i>IExecutionInfo</i> entry to
232the stack that will be available with the according feature and context
233for undo/redo. External changes (e.g. changes done from the standard
234property sheet) will not break the editor, but will not necessarily lead
235to data being available inside the <i>IExecutionInfo</i> object written:</p>
236<ul>
237 <li>EMF changes done on the EMF command stack (e.g. from the
238 standard property sheet) have no associated feature and context.
239 Therefore an empty <i>IExecutionInfo</i> entry will be written. On the
240 other hand all changes done in that case will automatically be
241 undone/redone by the EMF command stack, so there should be no need to
242 do additional stuff</li>
243 <li>Non-EMF changes done e.g. from a standard property sheet will
244 naturally not go through the EMF command stack of the editor, so no <i>IExecutionInfo</i>
245 stack entry will be written (in fact also no EMF command stack entry
246 will be written so there is no issue within the editor). In this case
247 users are responsible to add their own undo/redo functionality relying
248 on whatever technology they use for their domain model.</li>
249</ul>
250</p>
251
252
mwenz8bcdbbe2010-07-22 13:03:03 +0000253<hr>
254<a href="http://www.eclipse.org/legal/epl-v10.html" shape="rect">Copyright
255(c) SAP AG 2005, 2010.</a>
256
257</body>
258
259</html>