mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 1 | <html> |
| 2 | |
| 3 | <head> |
| 4 | <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> |
| 5 | <meta name=Generator content="Microsoft Word 11 (filtered)"> |
| 6 | <title>Tool behavior provider</title> |
| 7 | <link rel=Stylesheet type="text/css" media=all href="../book.css"> |
| 8 | <style> |
| 9 | <!-- |
| 10 | /* Font Definitions */ |
| 11 | @font-face |
| 12 | {font-family:Tahoma; |
| 13 | panose-1:2 11 6 4 3 5 4 4 2 4;} |
| 14 | /* Style Definitions */ |
| 15 | p.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 | h1 |
| 22 | {margin-top:12.0pt; |
| 23 | margin-right:0cm; |
| 24 | margin-bottom:3.0pt; |
| 25 | margin-left:0cm; |
| 26 | page-break-after:avoid; |
| 27 | font-size:16.0pt; |
| 28 | font-weight:bold;} |
| 29 | h2 |
| 30 | {margin-top:12.0pt; |
| 31 | margin-right:0cm; |
| 32 | margin-bottom:3.0pt; |
| 33 | margin-left:0cm; |
| 34 | page-break-after:avoid; |
| 35 | font-size:14.0pt; |
| 36 | font-weight:bold; |
| 37 | font-style:italic;} |
| 38 | h3 |
| 39 | {margin-top:12.0pt; |
| 40 | margin-right:0cm; |
| 41 | margin-bottom:3.0pt; |
| 42 | margin-left:0cm; |
| 43 | page-break-after:avoid; |
| 44 | font-size:13.0pt; |
| 45 | font-weight:bold;} |
| 46 | h4 |
| 47 | {margin-top:11.25pt; |
| 48 | margin-right:0cm; |
| 49 | margin-bottom:1.7pt; |
| 50 | margin-left:0cm; |
| 51 | font-size:12.0pt; |
| 52 | font-weight:bold; |
| 53 | font-style:italic;} |
| 54 | h5 |
| 55 | {margin-right:0cm; |
| 56 | margin-left:0cm; |
| 57 | font-size:10.0pt; |
| 58 | font-weight:bold;} |
| 59 | a:link, span.MsoHyperlink |
| 60 | {color:blue; |
| 61 | text-decoration:underline;} |
| 62 | a:visited, span.MsoHyperlinkFollowed |
| 63 | {color:purple; |
| 64 | text-decoration:underline;} |
| 65 | p |
| 66 | {font-size:12.0pt;} |
| 67 | pre |
| 68 | {margin-top:0cm; |
| 69 | margin-bottom:0cm; |
| 70 | margin-bottom:.0001pt; |
| 71 | font-size:11.0pt;} |
| 72 | p.MsoAcetate, li.MsoAcetate, div.MsoAcetate |
| 73 | {margin:0cm; |
| 74 | margin-bottom:.0001pt; |
| 75 | font-size:8.0pt; |
| 76 | font-family:Tahoma;} |
| 77 | p.code, li.code, div.code |
| 78 | {font-size:12.0pt;} |
| 79 | p.note, li.note, div.note |
| 80 | {font-size:13.0pt;} |
| 81 | span.code1 |
| 82 | {font-style:italic;} |
| 83 | span.code0 |
| 84 | {font-style:italic;} |
| 85 | @page Section1 |
| 86 | {size:595.45pt 841.7pt; |
| 87 | margin:72.0pt 89.85pt 72.0pt 89.85pt;} |
| 88 | div.Section1 |
| 89 | {page:Section1;} |
| 90 | /* List Definitions */ |
| 91 | ol |
| 92 | {margin-bottom:0cm;} |
| 93 | ul |
| 94 | {margin-bottom:0cm;} |
| 95 | --> |
| 96 | </style> |
| 97 | |
| 98 | </head> |
| 99 | |
| 100 | <body bgcolor=white lang=DE link=blue vlink=purple style='margin-bottom:12.0pt'> |
| 101 | |
| 102 | <div class=Section1> |
| 103 | |
| 104 | <h1><span lang=EN-GB>Tool Behavior Provider</span></h1> |
| 105 | |
| 106 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 107 | |
| 108 | <p class=MsoNormal><span lang=EN-GB style='color:black'>The tool behavior |
| 109 | provider is needed to integrate into the standard workbench tools. In most |
| 110 | cases this means adding functionality to existing editing concepts of the |
| 111 | workbench.</span></p> |
| 112 | |
| 113 | <p class=MsoNormal><span lang=EN-GB style='color:black'>Typical examples are:</span></p> |
| 114 | |
| 115 | <ul style='margin-top:0cm' type=disc> |
| 116 | <li class=MsoNormal style='color:black'><span lang=EN-GB>Adding features to |
| 117 | the palette or tool-bar</span></li> |
| 118 | <li class=MsoNormal style='color:black'><span lang=EN-GB>Specifying the |
| 119 | double-click behaviour</span></li> |
| 120 | <li class=MsoNormal style='color:black'><span lang=EN-GB>Adding features to |
| 121 | the context menu or context buttons of pictogram elements</span></li> |
| 122 | </ul> |
| 123 | |
| 124 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 125 | |
| 126 | <h2><span lang=EN-GB>Creating a Tool Behavior Provider</span></h2> |
| 127 | |
| 128 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 129 | |
| 130 | <p class=MsoNormal><span lang=EN-GB style='color:black'>To create a tool |
| 131 | behavior provider the interface <a |
| 132 | href="../../../javadoc/com/sap/tc/emf/gfw/tb/IToolBehaviorProvider.html">IToolBehaviorProvider</a> |
| 133 | has to be implemented. Instead of implementing this directly you should extend |
jpasch | c422123 | 2010-06-18 08:48:05 +0000 | [diff] [blame^] | 134 | the base classe <a |
| 135 | href="../../../javadoc/com/sap/tc/emf/gfw/tb/DefaultToolBehaviorProvider.html">DefaultToolBehaviorProvider</a>.</span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 136 | |
| 137 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 138 | |
| 139 | <p class=MsoNormal><span lang=EN-GB style='color:black'>At this point we will |
jpasch | c422123 | 2010-06-18 08:48:05 +0000 | [diff] [blame^] | 140 | just create an empty tool behavior provider by extending the base class. </span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 141 | |
| 142 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 143 | |
| 144 | <p class=MsoNormal><span lang=EN-GB style='color:black'>You can see the |
jpasch | c422123 | 2010-06-18 08:48:05 +0000 | [diff] [blame^] | 145 | implementation of the empty tool behavior provider <a href="custom-feature.htm">here</a> |
| 146 | . </span><span lang=EN-GB style='color:black'>We will add further functionality |
| 147 | in the next chapters.</span></p> |
mwenz | b5dc2f9 | 2010-06-16 13:24:52 +0000 | [diff] [blame] | 148 | |
| 149 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 150 | |
| 151 | <p class=MsoNormal><span lang=EN-GB style='color:black'>Additionally the |
| 152 | diagram type provider has to deliver this newly created tool behavior provider |
| 153 | (overwrite the method </span><span class=code1><span style='color:black'><a |
| 154 | href="../../../javadoc/com/sap/tc/emf/gfw/dt/IDiagramTypeProvider.html#getAvailableToolBehaviorProviders()"><span |
| 155 | lang=EN-US style='font-style:normal'>getAvailableToolBehaviorProviders</span></a></span></span><span |
| 156 | class=code1><span lang=EN-GB style='color:black;font-style:normal'>)</span></span><i><span |
| 157 | lang=EN-GB style='color:black'>. </span></i></p> |
| 158 | |
| 159 | <p class=MsoNormal><span lang=EN-GB style='color:black'>This implementation can |
| 160 | be seen here:</span></p> |
| 161 | |
| 162 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 163 | |
| 164 | <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=907 |
| 165 | style='width:18.0cm;border-collapse:collapse'> |
| 166 | <tr> |
| 167 | <td width=907 valign=top style='width:18.0cm;border:solid windowtext 1.0pt; |
| 168 | padding:0cm 5.4pt 0cm 5.4pt'> |
| 169 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-GB |
| 170 | style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'> </span></p> |
| 171 | <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| 172 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>package</span></b><span |
| 173 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 174 | org.eclipse.graphiti.examples.tutorial.diagram;</span></p> |
| 175 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 176 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 177 | <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| 178 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>import</span></b><span |
| 179 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 180 | org.eclipse.graphiti.dt.AbstractDiagramTypeProvider;</span></p> |
| 181 | <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| 182 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>import</span></b><span |
| 183 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 184 | org.eclipse.graphiti.tb.IToolBehaviorProvider;</span></p> |
| 185 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 186 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 187 | <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| 188 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span |
| 189 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 190 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>class</span></b><span |
| 191 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 192 | TutorialDiagramTypeProvider </span><b><span lang=EN-US style='font-size:10.0pt; |
| 193 | font-family:"Courier New";color:#7F0055'>extends</span></b><span lang=EN-US |
| 194 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 195 | AbstractDiagramTypeProvider {</span></p> |
| 196 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 197 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 198 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 199 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 200 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>private</span></b><span |
| 201 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 202 | IToolBehaviorProvider[] </span><span lang=EN-US style='font-size:10.0pt; |
| 203 | font-family:"Courier New";color:#0000C0'>toolBehaviorProviders</span><span |
| 204 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 205 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 206 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 207 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 208 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 209 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span |
| 210 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 211 | TutorialDiagramTypeProvider() {</span></p> |
| 212 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 213 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 214 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>super</span></b><span |
| 215 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>();</span></p> |
| 216 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 217 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 218 | setFeatureProvider(</span><b><span lang=EN-US style='font-size:10.0pt; |
| 219 | font-family:"Courier New";color:#7F0055'>new</span></b><span lang=EN-US |
| 220 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 221 | TutorialFeatureProvider(</span><b><span lang=EN-US style='font-size:10.0pt; |
| 222 | font-family:"Courier New";color:#7F0055'>this</span></b><span lang=EN-US |
| 223 | style='font-size:10.0pt;font-family:"Courier New";color:black'>));</span></p> |
| 224 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 225 | style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span></p> |
| 226 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 227 | style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| 228 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 229 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span |
| 230 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#646464'>@Override</span></p> |
| 231 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 232 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 233 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span |
| 234 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 235 | IToolBehaviorProvider[] getAvailableToolBehaviorProviders() {</span></p> |
| 236 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 237 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| 238 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if</span></b><span |
| 239 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> (</span><span |
| 240 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>toolBehaviorProviders</span><span |
| 241 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> == |
| 242 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 243 | color:#7F0055'>null</span></b><span lang=EN-US style='font-size:10.0pt; |
| 244 | font-family:"Courier New";color:black'>) {</span></p> |
| 245 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 246 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span |
| 247 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>toolBehaviorProviders</span><span |
| 248 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> =</span></p> |
| 249 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 250 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 251 | </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| 252 | color:#7F0055'>new</span></b><span lang=EN-US style='font-size:10.0pt; |
| 253 | font-family:"Courier New";color:black'> IToolBehaviorProvider[] { </span><b><span |
| 254 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span |
| 255 | lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 256 | TutorialToolBehaviorProvider(</span></p> |
| 257 | <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| 258 | style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| 259 | </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>this</span></b><span |
| 260 | style='font-size:10.0pt;font-family:"Courier New";color:black'>) };</span></p> |
| 261 | <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| 262 | font-family:"Courier New";color:black'> }</span></p> |
| 263 | <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| 264 | font-family:"Courier New";color:black'> </span><b><span |
| 265 | style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>return</span></b><span |
| 266 | style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span |
| 267 | style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>toolBehaviorProviders</span><span |
| 268 | style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| 269 | <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| 270 | font-family:"Courier New";color:black'> }</span></p> |
| 271 | <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| 272 | font-family:"Courier New";color:black'>}</span></p> |
| 273 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 274 | </td> |
| 275 | </tr> |
| 276 | </table> |
| 277 | |
| 278 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 279 | |
| 280 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 281 | |
| 282 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 283 | |
| 284 | <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| 285 | |
| 286 | </div> |
| 287 | <hr> |
| 288 | <a href="http://www.eclipse.org/legal/epl-v10.html" shape="rect">Copyright (c) SAP AG 2005, 2010.</a> |
| 289 | |
| 290 | </body> |
| 291 | |
| 292 | </html> |