| <html> |
| |
| <head> |
| <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> |
| <meta name=Generator content="Microsoft Word 12 (filtered)"> |
| <title>Providing context buttons</title> |
| <link rel=Stylesheet type="text/css" media=all href="../book.css"> |
| <style> |
| <!-- |
| /* Font Definitions */ |
| @font-face |
| {font-family:"Cambria Math"; |
| panose-1:2 4 5 3 5 4 6 3 2 4;} |
| @font-face |
| {font-family:Cambria; |
| panose-1:2 4 5 3 5 4 6 3 2 4;} |
| @font-face |
| {font-family:Tahoma; |
| panose-1:2 11 6 4 3 5 4 4 2 4;} |
| @font-face |
| {font-family:Consolas; |
| panose-1:2 11 6 9 2 2 4 3 2 4;} |
| /* Style Definitions */ |
| p.MsoNormal, li.MsoNormal, div.MsoNormal |
| {margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| h1 |
| {mso-style-link:"Überschrift 1 Zchn"; |
| margin-top:12.0pt; |
| margin-right:0cm; |
| margin-bottom:3.0pt; |
| margin-left:0cm; |
| page-break-after:avoid; |
| font-size:16.0pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold;} |
| h2 |
| {mso-style-link:"Überschrift 2 Zchn"; |
| margin-top:12.0pt; |
| margin-right:0cm; |
| margin-bottom:3.0pt; |
| margin-left:0cm; |
| page-break-after:avoid; |
| font-size:14.0pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold; |
| font-style:italic;} |
| h3 |
| {mso-style-link:"Überschrift 3 Zchn"; |
| margin-top:12.0pt; |
| margin-right:0cm; |
| margin-bottom:3.0pt; |
| margin-left:0cm; |
| page-break-after:avoid; |
| font-size:13.0pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold;} |
| h4 |
| {mso-style-link:"Überschrift 4 Zchn"; |
| margin-top:11.25pt; |
| margin-right:0cm; |
| margin-bottom:1.7pt; |
| margin-left:0cm; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold; |
| font-style:italic;} |
| h5 |
| {mso-style-link:"Überschrift 5 Zchn"; |
| margin-right:0cm; |
| margin-left:0cm; |
| font-size:10.0pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold;} |
| h6 |
| {mso-style-link:"Überschrift 6 Zchn"; |
| margin-right:0cm; |
| margin-left:0cm; |
| font-size:7.5pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold;} |
| p.MsoCaption, li.MsoCaption, div.MsoCaption |
| {margin-top:6.0pt; |
| margin-right:0cm; |
| margin-bottom:24.0pt; |
| margin-left:0cm; |
| text-align:justify; |
| font-size:10.0pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold;} |
| a:link, span.MsoHyperlink |
| {color:blue; |
| text-decoration:underline;} |
| a:visited, span.MsoHyperlinkFollowed |
| {color:purple; |
| text-decoration:underline;} |
| p.MsoDocumentMap, li.MsoDocumentMap, div.MsoDocumentMap |
| {mso-style-link:"Dokumentstruktur Zchn"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:8.0pt; |
| font-family:"Tahoma","sans-serif";} |
| p |
| {margin-top:5.65pt; |
| margin-right:0cm; |
| margin-bottom:5.65pt; |
| margin-left:0cm; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| pre |
| {mso-style-link:"HTML Vorformatiert Zchn"; |
| margin-top:0cm; |
| margin-right:0cm; |
| margin-bottom:0cm; |
| margin-left:3.4pt; |
| margin-bottom:.0001pt; |
| font-size:11.0pt; |
| font-family:"Courier New";} |
| p.MsoAcetate, li.MsoAcetate, div.MsoAcetate |
| {mso-style-link:"Sprechblasentext Zchn"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:8.0pt; |
| font-family:"Tahoma","sans-serif";} |
| span.berschrift1Zchn |
| {mso-style-name:"Überschrift 1 Zchn"; |
| mso-style-link:"Überschrift 1"; |
| font-family:"Cambria","serif"; |
| color:#365F91; |
| font-weight:bold;} |
| span.berschrift2Zchn |
| {mso-style-name:"Überschrift 2 Zchn"; |
| mso-style-link:"Überschrift 2"; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold;} |
| span.berschrift3Zchn |
| {mso-style-name:"Überschrift 3 Zchn"; |
| mso-style-link:"Überschrift 3"; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold;} |
| span.berschrift4Zchn |
| {mso-style-name:"Überschrift 4 Zchn"; |
| mso-style-link:"Überschrift 4"; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold; |
| font-style:italic;} |
| span.berschrift5Zchn |
| {mso-style-name:"Überschrift 5 Zchn"; |
| mso-style-link:"Überschrift 5"; |
| font-family:"Cambria","serif"; |
| color:#243F60;} |
| span.berschrift6Zchn |
| {mso-style-name:"Überschrift 6 Zchn"; |
| mso-style-link:"Überschrift 6"; |
| font-family:"Cambria","serif"; |
| color:#243F60; |
| font-style:italic;} |
| span.HTMLVorformatiertZchn |
| {mso-style-name:"HTML Vorformatiert Zchn"; |
| mso-style-link:"HTML Vorformatiert"; |
| font-family:Consolas;} |
| span.DokumentstrukturZchn |
| {mso-style-name:"Dokumentstruktur Zchn"; |
| mso-style-link:Dokumentstruktur; |
| font-family:"Tahoma","sans-serif";} |
| span.SprechblasentextZchn |
| {mso-style-name:"Sprechblasentext Zchn"; |
| mso-style-link:Sprechblasentext; |
| font-family:"Tahoma","sans-serif";} |
| p.code, li.code, div.code |
| {mso-style-name:code; |
| margin-top:0cm; |
| margin-right:0cm; |
| margin-bottom:0cm; |
| margin-left:15.0pt; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| p.note, li.note, div.note |
| {mso-style-name:note; |
| margin-top:19.5pt; |
| margin-right:0cm; |
| margin-bottom:19.5pt; |
| margin-left:30.0pt; |
| font-size:13.0pt; |
| font-family:"Times New Roman","serif"; |
| font-style:italic;} |
| p.msochpdefault, li.msochpdefault, div.msochpdefault |
| {mso-style-name:msochpdefault; |
| margin-top:5.65pt; |
| margin-right:0cm; |
| margin-bottom:5.65pt; |
| margin-left:0cm; |
| font-size:10.0pt; |
| font-family:"Times New Roman","serif";} |
| p.comment, li.comment, div.comment |
| {mso-style-name:comment; |
| margin-top:5.65pt; |
| margin-right:0cm; |
| margin-bottom:5.65pt; |
| margin-left:0cm; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif"; |
| font-weight:bold;} |
| span.Heading1Char |
| {mso-style-name:"Heading 1 Char"; |
| mso-style-link:"Heading 1"; |
| font-family:"Cambria","serif"; |
| color:#365F91; |
| font-weight:bold;} |
| p.Heading1, li.Heading1, div.Heading1 |
| {mso-style-name:"Heading 1"; |
| mso-style-link:"Heading 1 Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.Heading2Char |
| {mso-style-name:"Heading 2 Char"; |
| mso-style-link:"Heading 2"; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold;} |
| p.Heading2, li.Heading2, div.Heading2 |
| {mso-style-name:"Heading 2"; |
| mso-style-link:"Heading 2 Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.Heading3Char |
| {mso-style-name:"Heading 3 Char"; |
| mso-style-link:"Heading 3"; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold;} |
| p.Heading3, li.Heading3, div.Heading3 |
| {mso-style-name:"Heading 3"; |
| mso-style-link:"Heading 3 Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.Heading4Char |
| {mso-style-name:"Heading 4 Char"; |
| mso-style-link:"Heading 4"; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold; |
| font-style:italic;} |
| p.Heading4, li.Heading4, div.Heading4 |
| {mso-style-name:"Heading 4"; |
| mso-style-link:"Heading 4 Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.Heading5Char |
| {mso-style-name:"Heading 5 Char"; |
| mso-style-link:"Heading 5"; |
| font-family:"Cambria","serif"; |
| color:#243F60;} |
| p.Heading5, li.Heading5, div.Heading5 |
| {mso-style-name:"Heading 5"; |
| mso-style-link:"Heading 5 Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.Heading6Char |
| {mso-style-name:"Heading 6 Char"; |
| mso-style-link:"Heading 6"; |
| font-family:"Cambria","serif"; |
| color:#243F60; |
| font-style:italic;} |
| p.Heading6, li.Heading6, div.Heading6 |
| {mso-style-name:"Heading 6"; |
| mso-style-link:"Heading 6 Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.HTMLPreformattedChar |
| {mso-style-name:"HTML Preformatted Char"; |
| mso-style-link:"HTML Preformatted"; |
| font-family:Consolas;} |
| p.HTMLPreformatted, li.HTMLPreformatted, div.HTMLPreformatted |
| {mso-style-name:"HTML Preformatted"; |
| mso-style-link:"HTML Preformatted Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.BalloonTextChar |
| {mso-style-name:"Balloon Text Char"; |
| mso-style-link:"Balloon Text"; |
| font-family:"Tahoma","sans-serif";} |
| p.BalloonText, li.BalloonText, div.BalloonText |
| {mso-style-name:"Balloon Text"; |
| mso-style-link:"Balloon Text Char"; |
| margin:0cm; |
| margin-bottom:.0001pt; |
| font-size:12.0pt; |
| font-family:"Times New Roman","serif";} |
| span.heading1char0 |
| {mso-style-name:heading1char; |
| font-family:"Cambria","serif"; |
| color:#365F91; |
| font-weight:bold;} |
| span.heading2char0 |
| {mso-style-name:heading2char; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold;} |
| span.heading3char0 |
| {mso-style-name:heading3char; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold;} |
| span.heading4char0 |
| {mso-style-name:heading4char; |
| font-family:"Cambria","serif"; |
| color:#4F81BD; |
| font-weight:bold; |
| font-style:italic;} |
| span.heading5char0 |
| {mso-style-name:heading5char; |
| font-family:"Cambria","serif"; |
| color:#243F60;} |
| span.heading6char0 |
| {mso-style-name:heading6char; |
| font-family:"Cambria","serif"; |
| color:#243F60; |
| font-style:italic;} |
| span.htmlpreformattedchar0 |
| {mso-style-name:htmlpreformattedchar; |
| font-family:Consolas;} |
| span.balloontextchar0 |
| {mso-style-name:balloontextchar; |
| font-family:"Tahoma","sans-serif";} |
| span.code1 |
| {mso-style-name:code1; |
| font-style:italic;} |
| span.code0 |
| {mso-style-name:code0; |
| font-style:italic;} |
| span.code2 |
| {mso-style-name:code2; |
| font-style:italic;} |
| .MsoChpDefault |
| {font-size:10.0pt;} |
| @page WordSection1 |
| {size:595.45pt 841.7pt; |
| margin:72.0pt 89.85pt 72.0pt 89.85pt;} |
| div.WordSection1 |
| {page:WordSection1;} |
| /* List Definitions */ |
| ol |
| {margin-bottom:0cm;} |
| ul |
| {margin-bottom:0cm;} |
| --> |
| </style> |
| |
| </head> |
| |
| <body bgcolor=white lang=DE link=blue vlink=purple style='margin-bottom:12.0pt'> |
| |
| <div class=WordSection1> |
| |
| <h1><a name="_Toc179099521"><span lang=EN-GB>Providing </span></a><span |
| lang=EN-GB>Context Buttons</span></h1> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Context buttons allow |
| adding actions as small, automatically appearing icons for each pictogram |
| element in the diagram.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>They are shown along |
| the borders of a pictogram element when the mouse is positioned on that |
| pictogram element. They are hidden again when the mouse is positioned outside |
| the area built by the pictogram element and the context buttons.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Context buttons can |
| provide the same functionality as a <a href="context-menu.htm">context menu</a>, |
| but in a nicer and quicker way: the context buttons are shown immediately. |
| Another advantage of context buttons over context menus is, that each context |
| button can have several drag and drop features, which get activated when the |
| user drags from a context button and drops onto the canvas or another object.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <h2><span lang=EN-GB>Enhancing the Tool Behavior Provider</span></h2> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Context buttons are |
| defined in the tool behavior provider.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>If you didnt do so |
| already you must <b>first create a tool behavior provider and add it to the |
| diagram type provider as described <a href="tool-behavior-provider.htm">here</a>.</b></span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>There is one method of |
| the tool behavior provider to overwrite: </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>The method <a |
| href="../../../javadoc/org/eclipse/graphiti/tb/IToolBehaviorProvider.html#getContextButtonPad(org.eclipse.graphiti.features.context.IPictogramElementContext)">getContextButtonPad</a> |
| has to return the context buttons for the given context (which implement <a |
| href="../../../javadoc/org/eclipse/graphiti/tb/IContextButtonEntry.html">IContextButtonEntry</a>). |
| </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>There are different |
| groups of context buttons:</span></p> |
| |
| <ul style='margin-top:0cm' type=disc> |
| <li class=MsoNormal style='color:black'><span lang=EN-GB>Generic context |
| buttons: their look and behaviour is standardized for all tools (e.g. |
| delete, remove and update). They are shown at the top of the |
| pictogram element in a predefined order. A specific tool can only choose |
| which of the generic context buttons to switch on/off.</span></li> |
| <li class=MsoNormal style='color:black'><span lang=EN-GB>Domain specific |
| context buttons: they are specific for each tool (e.g. create sub-class |
| in a class editor). They are shown at the right (and if necessary also |
| bottom) of the pictogram element. A specific tool must define the look and |
| behaviour for all domain specific context buttons. </span></li> |
| <li class=MsoNormal style='color:black'><span lang=EN-GB>Collapse context |
| button: the look and position for the collapse context button is |
| standardized for all tools. A specific tool must define the behavior of |
| the collapse context button by defining the feature to call (see <a |
| href="../../../javadoc/org/eclipse/graphiti/tb/ContextEntryHelper.html#createCollapseContextButton(boolean, org.eclipse.graphiti.features.IFeature, org.eclipse.graphiti.features.context.IContext)">createCollapseContextButton</a>).</span></li> |
| </ul> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>The following |
| restrictions are defined by usability engineers of SAP AG (but currently not |
| checked technically): there can be 0-3 generic context buttons, 0-5 domain specific |
| context buttons and 0-1 collapse context button.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-US> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>The functionality of |
| context buttons is always provided by features. </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Each context button can |
| have one click-feature, which is executed when clicking the context-button, |
| and/or several drag & drop features, which are executed when the user |
| starts dragging a connection from the context button. If several drag & |
| drop features are available, a context-menu will be offered to the user when he |
| drops the connection, and he can choose the feature to execute.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>In this example we want |
| to create one context button, which offers all available <a |
| href="create-connection-feature.htm">create connection features</a> as drag |
| & drop features, but has no click-feature. </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span style='color:black'><img border=0 width=353 |
| height=120 src="visio/context-buttons-click.gif"></span><span lang=EN-GB |
| style='color:black'> </span></p> |
| |
| <p class=MsoCaption><span lang=EN-GB>Figure: A context button, which the user |
| can click or start drag&drop from it</span></p> |
| |
| <p class=MsoNormal><span style='color:black'><img border=0 width=353 |
| height=102 src="visio/context-buttons-drag.gif"></span></p> |
| |
| <p class=MsoCaption><span lang=EN-GB>Figure: The user started dragging from the |
| context button</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>You can see the |
| complete implementation of the context button here:</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=680 |
| style='width:18.0cm;border-collapse:collapse'> |
| <tr> |
| <td width=680 valign=top style='width:18.0cm;border:solid windowtext 1.0pt; |
| padding:0cm 5.4pt 0cm 5.4pt'> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#646464'>@Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> IContextButtonPadData |
| getContextButtonPad(</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| IPictogramElementContext context) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| IContextButtonPadData data = </span><b><span lang=EN-US style='font-size: |
| 10.0pt;font-family:"Courier New";color:#7F0055'>super</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>.getContextButtonPad(context);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| PictogramElement pe = context.getPictogramElement();</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// 1. set the generic context buttons</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// note, that we do not add 'remove' (just as an example)</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| setGenericContextButtons(data, pe, </span><i><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>CONTEXT_BUTTON_DELETE</span></i><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> | </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><i><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#0000C0'>CONTEXT_BUTTON_UPDATE</span></i><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// 2. set the collapse button </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// simply use a dummy custom feature (senseless example)</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| CustomContext cc = </span><b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:#7F0055'>new</span></b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| CustomContext(</span><b><span lang=EN-US style='font-size:10.0pt;font-family: |
| "Courier New";color:#7F0055'>new</span></b><span lang=EN-US style='font-size: |
| 10.0pt;font-family:"Courier New";color:black'> PictogramElement[] { pe });</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ICustomFeature[] cf = getFeatureProvider().getCustomFeatures(cc);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>for</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> (</span><b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> i |
| = 0; i < cf.</span><span lang=EN-US style='font-size:10.0pt;font-family: |
| "Courier New";color:#0000C0'>length</span><span lang=EN-US style='font-size: |
| 10.0pt;font-family:"Courier New";color:black'>; i++) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ICustomFeature iCustomFeature = cf[i];</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> (iCustomFeature </span><b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> TutorialCollapseDummyFeature) |
| {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| IContextButtonEntry collapseButton = ContextEntryHelper.<br> |
| |
| <i>createCollapseContextButton</i>(</span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>true</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>, |
| iCustomFeature, cc);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| data.setCollapseContextButton(collapseButton);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>break</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'>;</span><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'><br> |
| |
| <span style='color:black'>}</span></span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }<br> |
| </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// 3. add one domain specific context-button, which offers all |
| </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// available connection-features as drag&drop features...</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// 3.a. create new CreateConnectionContext</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| CreateConnectionContext ccc = </span><b><span lang=EN-US style='font-size: |
| 10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| CreateConnectionContext();</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ccc.setSourcePictogramElement(pe);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| Anchor anchor = </span><b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:#7F0055'>null</span></b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> (pe </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| Anchor) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| anchor = (Anchor) pe;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| } </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>else</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| (pe </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>instanceof</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> AnchorContainer) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// assume, that our shapes always have <u>chopbox</u> anchors</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=FR style='font-size:10.0pt;font-family:"Courier New"; |
| color:black'>anchor = Graphiti.getPeService()<br> |
| |
| .<i>getChopboxAnchor</i>((AnchorContainer) pe);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=FR |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:black'>}</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ccc.setSourceAnchor(anchor);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// 3.b. create context button and add all applicable features</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ContextButtonEntry button = </span><b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:#7F0055'>new</span></b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ContextButtonEntry(</span><b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:#7F0055'>null</span></b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'>, context);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| button.setText(</span><span lang=EN-US style='font-size:10.0pt;font-family: |
| "Courier New";color:#2A00FF'>"Create connection"</span><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| button.setIconId(MyTutorialImageProvider.</span><i><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>IMG_EREFERENCE</span></i><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ICreateConnectionFeature[] features =</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| getFeatureProvider().getCreateConnectionFeatures();</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>for</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> (ICreateConnectionFeature feature : |
| features) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> (feature.isAvailable(ccc) && |
| feature.canStartConnection(ccc))</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| button.addDragAndDropFeature(feature);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#3F7F5F'>// 3.c. add context button, if it contains at least one |
| feature</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> |
| (button.getDragAndDropFeatures().size() > 0) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| data.getDomainSpecificContextButtons().add(button);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> |
| </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>return</span></b><span |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> data;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span></p> |
| </td> |
| </tr> |
| </table> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>The implementation of <i>MyTutorialImageProvider</i> |
| can be found <a href="images.htm">here</a>. The implementation of the <i>TutorialCollapseDummyFeature</i> |
| can be found at <a href="#_Implementation_of_the">the end of this page</a>.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-US> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-US>The context button entries contain |
| information about icon, display text and tooltip description.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-US>The positioning of the context buttons can |
| be influenced by changing the rectangle around which the context buttons are |
| placed (see <a |
| href="../../../javadoc/org/eclipse/graphiti/tb/IContextButtonPadData.html#getPadLocation()">getPadLocation</a>). |
| By default the selection area is used (see <a href="selection-behavior.htm">selection |
| behavior</a>) if defined, or otherwise the bounds of the pictogram elements |
| main graphics algorithm are used.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-US style='color:black'> </span></p> |
| |
| <h2><span lang=EN-GB>Test: Create a Connection by Drag&Drop from a Context |
| Button</span></h2> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Note that previously we |
| implemented one <a href="create-connection-feature.htm">create connection |
| feature</a> which allows creating an association between two EClasses.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Now start the editor |
| and test this new context button:</span></p> |
| |
| <ol style='margin-top:0cm' start=1 type=1> |
| <li class=MsoNormal style='color:black;text-align:justify'><span lang=EN-GB>Create |
| or open a diagram and create two EClasses in the diagram.</span></li> |
| <li class=MsoNormal style='color:black;text-align:justify'><span lang=EN-GB>Position |
| the mouse on top of the first EClass and the context button should appear |
| in the south-east of the shape.</span></li> |
| <li class=MsoNormal style='color:black;text-align:justify'><span lang=EN-GB>Start |
| dragging with the mouse from the context-button.</span></li> |
| <li class=MsoNormal style='color:black;text-align:justify'><span lang=EN-GB>Drop |
| the connection onto the second EClass, which will result in one of the |
| following possibilities:</span></li> |
| </ol> |
| |
| <ol style='margin-top:0cm' start=1 type=1> |
| <li class=MsoNormal style='color:black;text-align:justify'><span lang=EN-GB>If |
| only one create connection feature for the EClass exists, then the association |
| will be created immediately.</span></li> |
| <li class=MsoNormal style='color:black;text-align:justify'><span lang=EN-GB>If |
| several create connection features for the EClass exist, then a |
| context-menu will be shown to the user, where he can choose the feature to |
| execute. Tip: if you have only one create connection feature you can try this |
| behaviour by simply duplicating the line </span><span lang=EN-GB |
| style='font-size:10.0pt;font-family:"Courier New"'>button.addDragAndDropFeature(feature);</span><span |
| lang=EN-GB>.</span></li> |
| </ol> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Note, that our |
| implementation of the create connection feature does not allow a connection, if |
| the source and target business object are identical. If you have two different |
| shapes associated with the same business object (e.g. via copy & paste), |
| then creating a connection between them is not possible.</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <h2><a name="_Implementation_of_the"></a><span lang=EN-GB>Implementation of the |
| TutorialCollapseDummyFeature</span></h2> |
| |
| <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=680 |
| style='width:18.0cm;border-collapse:collapse'> |
| <tr> |
| <td width=680 valign=top style='width:18.0cm;border:solid windowtext 1.0pt; |
| padding:0cm 5.4pt 0cm 5.4pt'> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> <span |
| style='color:black'> </span></span></p> |
| <p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family: |
| "Courier New";color:#7F0055'>package</span></b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| org.eclipse.graphiti.examples.tutorial.features;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'> </span></b></p> |
| <p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>class</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| TutorialCollapseDummyFeature </span><b><span lang=EN-US style='font-size: |
| 10.0pt;font-family:"Courier New";color:#7F0055'>extends</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| AbstractCustomFeature {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> |
| TutorialCollapseDummyFeature(IFeatureProvider fp) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>super</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'>(fp);</span><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'><br> |
| <span style='color:black'>}</span></span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#646464'>@Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>boolean</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| canExecute(ICustomContext context) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>boolean</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> ret = </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| PictogramElement[] pes = context.getPictogramElements();</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> (pes != </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>null</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| && pes.</span><span lang=EN-US style='font-size:10.0pt;font-family: |
| "Courier New";color:#0000C0'>length</span><span lang=EN-US style='font-size: |
| 10.0pt;font-family:"Courier New";color:black'> == 1) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| Object bo = getBusinessObjectForPictogramElement(pes[0]);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> (bo </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>instanceof</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| EClass) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ret = </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>true</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'>;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> ret;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#646464'>@Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> String getName() {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:#7F0055'>return</span></b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Collapse"</span><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#646464'>@Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> String getDescription() {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Collapse |
| Figure"</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:black'>;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#646464'>@Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> String getImageId() {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> IPlatformImageConstants.</span><i><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>IMG_EDIT_COLLAPSE</span></i><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#646464'>@Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>boolean</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| isAvailable(IContext context) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>true</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| }</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New"'> </span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#646464'>@Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>void</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| execute(ICustomContext context) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| MessageDialog.openInformation(PlatformUI.<i>getWorkbench</i>()<br> |
| |
| .getActiveWorkbenchWindow().getShell(), </span><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Information"</span><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#2A00FF'>"The 'Collapse Feature' is intentionally not implemented |
| yet."</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:black'>);</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt; |
| font-family:"Courier New";color:black'>} </span></p> |
| </td> |
| </tr> |
| </table> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>Finally the feature |
| provider has to deliver our newly created custom feature (overwrite the method </span><span |
| class=code1><span lang=EN-US style='color:black'><a |
| href="../../../javadoc/org/eclipse/graphiti/features/IFeatureProvider.html#getCustomFeatures(org.eclipse.graphiti.features.context.ICustomContext)"><span |
| style='font-style:normal'>getCustomFeatures</span></a></span></span><span |
| class=code1><span lang=EN-US style='color:black;font-style:normal'>)</span></span><i><span |
| lang=EN-GB style='color:black'>. </span></i></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'>This implementation can |
| be seen here:</span></p> |
| |
| <p class=MsoNormal><span lang=EN-GB style='color:black'> </span></p> |
| |
| <table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=680 |
| style='width:18.0cm;border-collapse:collapse'> |
| <tr> |
| <td width=680 valign=top style='width:18.0cm;border:solid windowtext 1.0pt; |
| padding:0cm 5.4pt 0cm 5.4pt'> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#646464'> |
| @Override</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>public</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> ICustomFeature[] |
| getCustomFeatures(ICustomContext context) {</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>return</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> </span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| ICustomFeature[] </span><span lang=EN-US style='font-size:10.0pt;font-family: |
| "Courier New"'><br> |
| <span |
| style='color:black'>{ </span><b><span style='color:#7F0055'>new</span></b><span |
| style='color:black'> TutorialRenameEClassFeature(</span><b><span |
| style='color:#7F0055'>this</span></b><span style='color:black'>),</span></span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>new</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> TutorialDrillDownEClassFeature(</span><b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>this</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>),</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>new</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> |
| TutorialAssociateDiagramEClassFeature(</span><b><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>this</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>),</span></p> |
| <p class=MsoNormal style='text-autospace:none'><span lang=EN-US |
| style='font-size:10.0pt;font-family:"Courier New";color:black'> |
| </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:#7F0055'>new</span></b><span lang=EN-US style='font-size:10.0pt; |
| font-family:"Courier New";color:black'> TutorialCollapseDummyFeature(</span><b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>this</span></b><span |
| lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>)};</span></p> |
| <p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"; |
| color:black'> }</span></p> |
| </td> |
| </tr> |
| </table> |
| |
| <p class=MsoNormal><span lang=EN-US> </span></p> |
| |
| <div class=MsoNormal align=center style='text-align:center'> |
| |
| <hr size=2 width="100%" align=center> |
| |
| </div> |
| |
| <p class=MsoNormal><a href="http://www.eclipse.org/legal/epl-v10.html" |
| shape=rect><span lang=EN-US>Copyright (c) SAP AG 2005, 2010.</span></a> </p> |
| |
| </div> |
| |
| </body> |
| |
| </html> |