1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
;
16 import java
.text
.MessageFormat
;
17 import java
.util
.ArrayList
;
18 import java
.util
.List
;
19 import java
.util
.Timer
;
20 import java
.util
.TimerTask
;
22 import org
.eclipse
.jface
.contexts
.IContextIds
;
23 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
24 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
25 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
26 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
27 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
28 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfTimestamp
;
30 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BaseMessage
;
31 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BasicExecutionOccurrence
;
32 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Frame
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.ITimeRange
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Lifeline
;
36 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Metrics
;
37 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialog
;
38 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialogUI
;
39 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IColor
;
40 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDCollapseProvider
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.LoadersManager
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
44 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
45 import org
.eclipse
.swt
.SWT
;
46 import org
.eclipse
.swt
.accessibility
.ACC
;
47 import org
.eclipse
.swt
.accessibility
.Accessible
;
48 import org
.eclipse
.swt
.accessibility
.AccessibleAdapter
;
49 import org
.eclipse
.swt
.accessibility
.AccessibleControlAdapter
;
50 import org
.eclipse
.swt
.accessibility
.AccessibleControlEvent
;
51 import org
.eclipse
.swt
.accessibility
.AccessibleEvent
;
52 import org
.eclipse
.swt
.events
.DisposeEvent
;
53 import org
.eclipse
.swt
.events
.DisposeListener
;
54 import org
.eclipse
.swt
.events
.FocusEvent
;
55 import org
.eclipse
.swt
.events
.FocusListener
;
56 import org
.eclipse
.swt
.events
.KeyEvent
;
57 import org
.eclipse
.swt
.events
.MouseEvent
;
58 import org
.eclipse
.swt
.events
.SelectionEvent
;
59 import org
.eclipse
.swt
.events
.SelectionListener
;
60 import org
.eclipse
.swt
.events
.TraverseEvent
;
61 import org
.eclipse
.swt
.events
.TraverseListener
;
62 import org
.eclipse
.swt
.graphics
.GC
;
63 import org
.eclipse
.swt
.graphics
.Image
;
64 import org
.eclipse
.swt
.graphics
.ImageData
;
65 import org
.eclipse
.swt
.graphics
.Rectangle
;
66 import org
.eclipse
.swt
.printing
.Printer
;
67 import org
.eclipse
.swt
.printing
.PrinterData
;
68 import org
.eclipse
.swt
.widgets
.Canvas
;
69 import org
.eclipse
.swt
.widgets
.Caret
;
70 import org
.eclipse
.swt
.widgets
.Composite
;
71 import org
.eclipse
.swt
.widgets
.Control
;
72 import org
.eclipse
.swt
.widgets
.Display
;
73 import org
.eclipse
.swt
.widgets
.Event
;
74 import org
.eclipse
.swt
.widgets
.Listener
;
75 import org
.eclipse
.swt
.widgets
.MenuItem
;
76 import org
.eclipse
.ui
.contexts
.IContextService
;
77 import org
.eclipse
.ui
.part
.ViewPart
;
81 * This class implements sequence diagram widget used in the sequence diagram view.
87 public class SDWidget
extends ScrollView
implements SelectionListener
,
88 IPropertyChangeListener
, DisposeListener
, ITimeCompressionListener
{
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
95 * The frame to display in the sequence diagram widget.
97 protected Frame fFrame
;
99 * The overview image to display.
101 protected Image fOverView
= null;
103 * The zoom in menu item.
105 protected MenuItem fZoomIn
= null;
107 * The zoom out menu item.
109 protected MenuItem fZoomOut
= null;
111 * The sequence diagram selection provider.
113 protected SDWidgetSelectionProvider fSelProvider
= null;
115 * The current zoom value.
117 public float fZoomValue
= 1;
119 * The current zoomInMode (true for zoom in).
121 protected boolean fZoomInMode
= false;
123 * The current zoomOutMode (true for zoom out).
125 protected boolean fZoomOutMode
= false;
127 * The current list of selected graph nodes.
129 protected List
<GraphNode
> fSelectedNodeList
= null;
131 * Flag whether ctrl button is selected or not.
133 protected boolean fCtrlSelection
= false;
135 * A reference to the view site.
137 protected ViewPart fSite
= null;
139 * The current graph node (the last selected one).
141 public GraphNode fCurrentGraphNode
= null;
143 * The first graph node in list (multiple selection).
145 public GraphNode fListStart
= null;
147 * The previous graph node (multiple selection).
149 public List
<GraphNode
> fPrevList
= null;
151 * The time compression bar.
153 protected TimeCompressionBar fTimeBar
= null;
155 * The current diagram tool tip.
157 protected DiagramToolTip fToolTip
= null;
159 * The accessible object reference of view control.
161 protected Accessible fAccessible
= null;
163 * The current node for the tooltip to display.
165 protected GraphNode fToolTipNode
;
167 * The life line to drag and drop.
169 protected Lifeline fDragAndDrop
= null;
171 * The number of focused widgets.
173 protected int fFocusedWidget
= -1;
177 protected float fPrinterZoom
= 0;
179 * Y coordinate for printer.
181 protected int fPrinterY
= 0;
183 * X coordinate for printer.
185 protected int fPrinterX
= 0;
187 * Flag whether drag and drop is enabled or not.
189 protected boolean fIsDragAndDrop
= false;
191 * The x coordinate for drag.
193 protected int fDragX
= 0;
195 * The y coordinate for drag.
197 protected int fDragY
= 0;
201 protected boolean fReorderMode
= false;
203 * The collapse caret image.
205 protected Image fCollapaseCaretImg
= null;
207 * The arrow up caret image.
209 protected Image fArrowUpCaretImg
= null;
211 * The current caret image.
213 protected Image fCurrentCaretImage
= null;
215 * A sequence diagramm collapse provider (for collapsing graph nodes)
217 protected ISDCollapseProvider fCollapseProvider
= null;
219 * The insertion caret.
221 protected Caret fInsertionCartet
= null;
223 * The reorder list when in reorder mode.
225 protected List
<Lifeline
[]> fReorderList
= null;
227 * Flag to specify whether in printing mode or not.
229 protected boolean fIsPrinting
= false;
231 * A printer reference.
233 protected Printer fPrinter
= null;
235 * Flag whether shift was selected or not.
237 protected boolean fShiftSelection
= false;
239 * The scroll tooltip.
241 protected DiagramToolTip fScrollToolTip
= null;
243 * Timer for auto_scroll feature
245 protected AutoScroll fLocalAutoScroll
= null;
247 * TimerTask for auto_scroll feature !=null when auto scroll is running
249 protected Timer fLocalAutoScrollTimer
= null;
251 // ------------------------------------------------------------------------
253 // ------------------------------------------------------------------------
255 * Constructor for SDWidget.
256 * @param c The parent composite
259 public SDWidget(Composite c
, int s
) {
260 super(c
, s
| SWT
.NO_BACKGROUND
, true);
261 setOverviewEnabled(true);
262 fSelectedNodeList
= new ArrayList
<GraphNode
>();
263 fSelProvider
= new SDWidgetSelectionProvider();
264 SDViewPref
.getInstance().addPropertyChangeListener(this);
265 fToolTip
= new DiagramToolTip(getViewControl());
266 super.addDisposeListener(this);
268 fScrollToolTip
= new DiagramToolTip(c
);
269 getVerticalBar().addListener(SWT
.MouseUp
, new Listener() {
272 public void handleEvent(Event event
) {
273 fScrollToolTip
.hideToolTip();
277 fAccessible
= getViewControl().getAccessible();
279 fAccessible
.addAccessibleListener(new AccessibleAdapter() {
282 * @see org.eclipse.swt.accessibility.AccessibleAdapter#getName(org.eclipse.swt.accessibility.AccessibleEvent)
285 public void getName(AccessibleEvent e
) {
287 if (e
.childID
== 0) {
288 if (fToolTipNode
!= null) {
289 if (fToolTipNode
instanceof Lifeline
) {
290 Lifeline lifeline
= (Lifeline
) fToolTipNode
;
291 e
.result
= lifeline
.getToolTipText();
293 e
.result
= fToolTipNode
.getName() + getPostfixForTooltip(true);
297 if (getFocusNode() != null) {
298 if (getFocusNode() instanceof Lifeline
) {
299 e
.result
= MessageFormat
.format(SDMessages
._1
, new Object
[] { String
.valueOf(getFocusNode().getName()) });
301 if (getFocusNode() instanceof BaseMessage
) {
302 BaseMessage mes
= (BaseMessage
) getFocusNode();
303 if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() != null)) {
304 e
.result
= MessageFormat
.format(
306 new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()), String
.valueOf(mes
.getEndLifeline().getName()),
307 Integer
.valueOf(mes
.getEndOccurrence()) });
308 } else if ((mes
.getStartLifeline() == null) && (mes
.getEndLifeline() != null)) {
309 e
.result
= MessageFormat
.format(SDMessages
._4
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getEndLifeline().getName()), Integer
.valueOf(mes
.getEndOccurrence()) });
310 } else if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() == null)) {
311 e
.result
= MessageFormat
.format(SDMessages
._3
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()) });
313 } else if (getFocusNode() instanceof BasicExecutionOccurrence
) {
314 BasicExecutionOccurrence exec
= (BasicExecutionOccurrence
) getFocusNode();
315 e
.result
= MessageFormat
.format(SDMessages
._5
,
316 new Object
[] { String
.valueOf(exec
.getName()), String
.valueOf(exec
.getLifeline().getName()), Integer
.valueOf(exec
.getStartOccurrence()), Integer
.valueOf(exec
.getEndOccurrence()) });
324 fAccessible
.addAccessibleControlListener(new AccessibleControlAdapter() {
327 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getFocus(org.eclipse.swt.accessibility.AccessibleControlEvent)
330 public void getFocus(AccessibleControlEvent e
) {
331 if (fFocusedWidget
== -1) {
332 e
.childID
= ACC
.CHILDID_SELF
;
334 e
.childID
= fFocusedWidget
;
340 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getRole(org.eclipse.swt.accessibility.AccessibleControlEvent)
343 public void getRole(AccessibleControlEvent e
) {
345 case ACC
.CHILDID_SELF
:
346 e
.detail
= ACC
.ROLE_CLIENT_AREA
;
349 e
.detail
= ACC
.ROLE_TOOLTIP
;
352 e
.detail
= ACC
.ROLE_LABEL
;
361 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getState(org.eclipse.swt.accessibility.AccessibleControlEvent)
364 public void getState(AccessibleControlEvent e
) {
365 e
.detail
= ACC
.STATE_FOCUSABLE
;
366 if (e
.childID
== ACC
.CHILDID_SELF
) {
367 e
.detail
|= ACC
.STATE_FOCUSED
;
369 e
.detail
|= ACC
.STATE_SELECTABLE
;
370 if (e
.childID
== fFocusedWidget
) {
371 e
.detail
|= ACC
.STATE_FOCUSED
| ACC
.STATE_SELECTED
| ACC
.STATE_CHECKED
;
377 fInsertionCartet
= new Caret((Canvas
) getViewControl(), SWT
.NONE
);
378 fInsertionCartet
.setVisible(false);
380 fCollapaseCaretImg
= Activator
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
);
381 fArrowUpCaretImg
= Activator
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
);
383 fReorderList
= new ArrayList
<Lifeline
[]>();
384 getViewControl().addTraverseListener(new LocalTraverseListener());
386 addTraverseListener(new LocalTraverseListener());
388 getViewControl().addFocusListener(new FocusListener() {
392 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
395 public void focusGained(FocusEvent e
) {
396 SDViewPref
.getInstance().setNoFocusSelection(false);
397 fCtrlSelection
= false;
398 fShiftSelection
= false;
404 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
407 public void focusLost(FocusEvent e
) {
408 SDViewPref
.getInstance().setNoFocusSelection(true);
414 // ------------------------------------------------------------------------
416 // ------------------------------------------------------------------------
418 * Sets the time compression bar.
420 * @param bar The time compression bar to set
422 public void setTimeBar(TimeCompressionBar bar
) {
425 fTimeBar
.addTimeCompressionListener(this);
430 * Resize the contents to insure the frame fit into the view
432 * @param frame the frame which will be drawn in the view
434 public void resizeContents(Frame frame
) {
435 int width
= Math
.round((frame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
436 int height
= Math
.round((frame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
437 resizeContents(width
, height
);
441 * The frame to render (the sequence diagram)
443 * @param theFrame the frame to display
444 * @param resetPosition boolean
446 public void setFrame(Frame theFrame
, boolean resetPosition
) {
447 fReorderList
.clear();
448 fSelectedNodeList
.clear();
449 fSelProvider
.setSelection(new StructuredSelection());
452 setContentsPos(0, 0);
453 resizeContents(fFrame
);
456 // prepare the old overview to be reused
457 if (fOverView
!= null) {
461 resizeContents(fFrame
);
465 * Returns the current Frame (the sequence diagram container)
469 public Frame
getFrame() {
474 * Returns the selection provider for the current sequence diagram
476 * @return the selection provider
478 public ISelectionProvider
getSelectionProvider() {
483 * Returns a list of selected graph nodes.
485 * @return a list of selected graph nodes.
487 public List
<GraphNode
> getSelection() {
488 return fSelectedNodeList
;
492 * Adds a graph node to the selected nodes list.
494 * @param node A graph node
496 public void addSelection(GraphNode node
) {
500 fSelectedNodeList
.add(node
);
501 node
.setSelected(true);
502 fCurrentGraphNode
= node
;
503 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
504 fSelProvider
.setSelection(selection
);
508 * Adds a list of node to the selected nodes list.
510 * @param list of graph nodes
512 public void addSelection(List
<GraphNode
> list
) {
513 // selectedNodeList.addAll(list);
514 for (int i
= 0; i
< list
.size(); i
++) {
515 if (!fSelectedNodeList
.contains(list
.get(i
))) {
516 fSelectedNodeList
.add(list
.get(i
));
517 list
.get(i
).setSelected(true);
520 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
521 fSelProvider
.setSelection(selection
);
525 * Removes a node from the selected nodes list.
527 * @param node to remove
529 public void removeSelection(GraphNode node
) {
530 fSelectedNodeList
.remove(node
);
531 node
.setSelected(false);
532 node
.setFocused(false);
533 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
534 fSelProvider
.setSelection(selection
);
538 * Removes a list of graph nodes from the selected nodes list.
540 * @param list of nodes to remove.
542 public void removeSelection(List
<GraphNode
> list
) {
543 fSelectedNodeList
.removeAll(list
);
544 for (int i
= 0; i
< list
.size(); i
++) {
545 list
.get(i
).setSelected(false);
546 list
.get(i
).setFocused(false);
548 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
549 fSelProvider
.setSelection(selection
);
553 * Clear the list of GraphNodes which must be drawn selected.
555 public void clearSelection() {
556 for (int i
= 0; i
< fSelectedNodeList
.size(); i
++) {
557 fSelectedNodeList
.get(i
).setSelected(false);
558 fSelectedNodeList
.get(i
).setFocused(false);
560 fCurrentGraphNode
= null;
561 fSelectedNodeList
.clear();
562 fSelProvider
.setSelection(new StructuredSelection());
568 * @param viewSite The view part to set
570 public void setSite(ViewPart viewSite
) {
572 fSite
.getSite().setSelectionProvider(fSelProvider
);
573 IContextService service
= (IContextService
) fSite
.getSite().getWorkbenchWindow().getService(IContextService
.class);
574 service
.activateContext("org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"); //$NON-NLS-1$
575 service
.activateContext(IContextIds
.CONTEXT_ID_WINDOW
);
579 * Returns the GraphNode overView the mouse if any
581 * @return the current graph node
583 public GraphNode
getMouseOverNode() {
584 return fCurrentGraphNode
;
588 * Sets the zoom in mode.
591 * The mode value to set.
593 public void setZoomInMode(boolean value
) {
595 setZoomOutMode(false);
601 * Sets the zoom out mode.
604 * The mode value to set.
606 public void setZoomOutMode(boolean value
) {
608 setZoomInMode(false);
610 fZoomOutMode
= value
;
614 * Moves the Sequence diagram to ensure the given node is visible and draw it selected
616 * @param node the GraphNode to move to
618 public void moveTo(GraphNode node
) {
628 * Moves the Sequence diagram to ensure the given node is visible
630 * @param node the GraphNode to move to
632 public void ensureVisible(GraphNode node
) {
636 int x
= Math
.round(node
.getX() * fZoomValue
);
637 int y
= Math
.round(node
.getY() * fZoomValue
);
638 int width
= Math
.round(node
.getWidth() * fZoomValue
);
639 int height
= Math
.round(node
.getHeight() * fZoomValue
);
640 if ((node
instanceof BaseMessage
) && (height
== 0)) {
641 int header
= Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
* 2 + Metrics
.getLifelineHeaderFontHeigth();
642 height
= -Math
.round((Metrics
.getMessagesSpacing() + header
) * fZoomValue
);
643 y
= y
+ Math
.round(Metrics
.SYNC_INTERNAL_MESSAGE_HEIGHT
* fZoomValue
);
645 if (node
instanceof BasicExecutionOccurrence
) {
649 if (node
instanceof Lifeline
) {
651 height
= getVisibleHeight();
653 ensureVisible(x
, y
, width
, height
, SWT
.CENTER
, true);
658 * Returns the current zoom factor.
659 * @return the current zoom factor.
661 public float getZoomFactor() {
666 * Returns teh printer reference.
668 * @return the printer reference
670 public Printer
getPrinter() {
675 * Returns whether the widget is used for printing or not.
677 * @return whether the widget is used for printing or not
679 public boolean isPrinting() {
684 * Gets the overview image.
686 * @param rect Rectangle to include overview.
687 * @return the overview image
689 public Image
getOverview(Rectangle rect
) {
690 float oldzoom
= fZoomValue
;
691 if ((fOverView
!= null) && ((rect
.width
!= fOverView
.getBounds().width
) || (rect
.height
!= fOverView
.getBounds().height
))) {
695 if (fOverView
== null) {
696 int backX
= getContentsX();
697 int backY
= getContentsY();
698 setContentsPos(0, 0);
699 fOverView
= new Image(getDisplay(), rect
.width
, rect
.height
);
700 GC gcim
= new GC(fOverView
);
701 NGC context
= new NGC(this, gcim
);
702 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
703 fFrame
.draw(context
);
704 setContentsPos(backX
, backY
);
708 fZoomValue
= oldzoom
;
713 * Resets the zoom factor.
715 public void resetZoomFactor() {
716 int currentX
= Math
.round(getContentsX() / fZoomValue
);
717 int currentY
= Math
.round(getContentsY() / fZoomValue
);
719 if (fTimeBar
!= null && !fTimeBar
.isDisposed()) {
720 fTimeBar
.setZoom(fZoomValue
);
724 setContentsPos(currentX
, currentY
);
728 * Enable or disable the lifeline reodering using Drag and Drop
730 * @param mode - true to enable false otherwise
732 public void setReorderMode(boolean mode
) {
737 * Return the lifelines reorder sequence (using Drag and Drop) if the the reorder mode is turn on. Each ArryList
738 * element is of type Lifeline[2] with Lifeline[0] inserted before Lifeline[1] in the diagram
740 * @return - the re-odered sequence
742 public List
<Lifeline
[]> getLifelineReoderList() {
747 * Sets the focus on given graph node (current node).
750 * The graph node to focus on.
752 public void setFocus(GraphNode node
) {
756 if (fCurrentGraphNode
!= null) {
757 fCurrentGraphNode
.setFocused(false);
759 fCurrentGraphNode
= node
;
760 node
.setFocused(true);
766 * Returns the graph node focused on.
768 * @return the current graph node
770 public GraphNode
getFocusNode() {
771 return fCurrentGraphNode
;
775 * Method to traverse right.
777 public void traverseRight() {
778 Object selectedNode
= getFocusNode();
779 if (selectedNode
== null) {
782 GraphNode node
= null;
783 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
784 node
= fFrame
.getCalledMessage((BaseMessage
) selectedNode
);
786 if (selectedNode
instanceof BasicExecutionOccurrence
) {
787 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
789 if ((node
== null) && (selectedNode
instanceof Lifeline
)) {
790 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
791 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
< fFrame
.lifeLinesCount() - 1)) {
792 node
= fFrame
.getLifeline(i
+ 1);
804 * Method to traverse left.
806 public void traverseLeft() {
807 Object selectedNode
= getFocusNode();
808 GraphNode node
= null;
809 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
810 node
= fFrame
.getCallerMessage((BaseMessage
) selectedNode
);
812 if (selectedNode
instanceof BasicExecutionOccurrence
) {
813 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
816 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
817 selectedNode
= ((BaseMessage
) selectedNode
).getEndLifeline();
819 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
820 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
> 0)) {
821 node
= fFrame
.getLifeline(i
- 1);
825 if ((fFrame
.lifeLinesCount() > 0) && (node
== null)) {
826 node
= fFrame
.getLifeline(0);
836 * Method to traverse up.
838 public void traverseUp() {
839 Object selectedNode
= getFocusNode();
840 if (selectedNode
== null) {
843 GraphNode node
= null;
844 if (selectedNode
instanceof BaseMessage
) {
845 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
846 } else if (selectedNode
instanceof Lifeline
) {
847 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
848 if (!(node
instanceof Lifeline
)) {
851 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
852 node
= fFrame
.getPrevExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
854 node
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
857 if ((node
== null) && (selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
858 node
= ((BaseMessage
) selectedNode
).getStartLifeline();
868 * Method to traverse down.
870 public void traverseDown() {
871 Object selectedNode
= getFocusNode();
872 if (selectedNode
== null) {
876 if (selectedNode
instanceof BaseMessage
) {
877 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
878 } else if (selectedNode
instanceof Lifeline
) {
879 // node = frame.getNextLifelineMessage((Lifeline)selectedNode,null);
880 node
= fFrame
.getFirstExecution((Lifeline
) selectedNode
);
881 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
882 node
= fFrame
.getNextExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
894 * Method to traverse home.
896 public void traverseHome() {
897 Object selectedNode
= getFocusNode();
898 if (selectedNode
== null) {
901 GraphNode node
= null;
903 if (selectedNode
instanceof BaseMessage
) {
904 if (((BaseMessage
) selectedNode
).getStartLifeline() != null) {
905 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
907 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getEndLifeline(), null);
909 } else if (selectedNode
instanceof Lifeline
) {
910 node
= fFrame
.getNextLifelineMessage((Lifeline
) selectedNode
, null);
911 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
912 node
= fFrame
.getFirstExecution(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
914 if (fFrame
.lifeLinesCount() > 0) {
915 Lifeline lifeline
= fFrame
.getLifeline(0);
916 node
= fFrame
.getNextLifelineMessage(lifeline
, null);
927 * Method to traverse to the end.
929 public void traverseEnd() {
930 Object selectedNode
= getFocusNode();
931 if (selectedNode
== null) {
935 if (selectedNode
instanceof BaseMessage
) {
936 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
937 } else if (selectedNode
instanceof Lifeline
) {
938 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
939 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
940 node
= fFrame
.getLastExecOccurrence(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
942 if (fFrame
.lifeLinesCount() > 0) {
943 Lifeline lifeline
= fFrame
.getLifeline(0);
944 node
= fFrame
.getPrevLifelineMessage(lifeline
, null);
957 * Method to print UI.
959 * @param sdPrintDialog the sequence diagram printer dialog.
961 public void printUI(SDPrintDialogUI sdPrintDialog
) {
962 PrinterData data
= sdPrintDialog
.getPrinterData();
964 if ((data
== null) || (fFrame
== null)) {
968 fPrinter
= new Printer(data
);
970 String jobName
= MessageFormat
.format(SDMessages
._116
, new Object
[] { String
.valueOf(fSite
.getContentDescription()), String
.valueOf(fFrame
.getName()) });
971 fPrinter
.startJob(jobName
);
973 GC gc
= new GC(fPrinter
);
974 // Frame.setUserPref(SDViewPref.getInstance());
976 float lastZoom
= fZoomValue
;
978 Rectangle area
= getClientArea();
982 NGC context
= new NGC(this, gcim
);
984 // Set the metrics to use for lifeline text and message text
985 // using the Graphical Context
986 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
987 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
988 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
989 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
990 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
992 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS
));
993 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS_RET
));
994 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS
));
995 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS_RET
));
997 int messageFontHeight
= 0;
998 if (syncMessFontH
> syncMessRetFontH
) {
999 messageFontHeight
= syncMessFontH
;
1001 messageFontHeight
= syncMessRetFontH
;
1003 if (messageFontHeight
< asyncMessFontH
) {
1004 messageFontHeight
= asyncMessFontH
;
1006 if (messageFontHeight
< asyncMessRetFontH
) {
1007 messageFontHeight
= asyncMessRetFontH
;
1009 Metrics
.setMessageFontHeight(messageFontHeight
);
1010 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1012 int width
= Math
.round((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1013 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1014 if (width
< area
.width
) {
1017 if (height
< area
.height
) {
1018 height
= area
.height
;
1020 resizeContents(width
, height
);
1022 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1023 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1024 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1025 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1026 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1027 gcim
.setLineWidth(1);
1029 fPrinter
.startPage();
1030 fZoomValue
= lastZoom
;
1032 int restoreX
= getContentsX();
1033 int restoreY
= getContentsY();
1035 float zh
= sdPrintDialog
.getStepY() * sdPrintDialog
.getZoomFactor();
1036 float zw
= sdPrintDialog
.getStepX() * sdPrintDialog
.getZoomFactor();
1038 float zoomValueH
= fPrinter
.getClientArea().height
/ zh
;
1039 float zoomValueW
= fPrinter
.getClientArea().width
/ zw
;
1040 if (zoomValueH
> zoomValueW
) {
1041 fPrinterZoom
= zoomValueH
;
1043 fPrinterZoom
= zoomValueW
;
1046 if (sdPrintDialog
.printSelection()) {
1047 int[] pagesList
= sdPrintDialog
.getPageList();
1049 for (int pageIndex
= 0; pageIndex
< pagesList
.length
; pageIndex
++) {
1050 printPage(pagesList
[pageIndex
], sdPrintDialog
, context
);
1052 } else if (sdPrintDialog
.printAll()) {
1053 for (int pageIndex
= 1; pageIndex
<= sdPrintDialog
.maxNumOfPages(); pageIndex
++) {
1054 printPage(pageIndex
, sdPrintDialog
, context
);
1056 } else if (sdPrintDialog
.printCurrent()) {
1057 printPage(getContentsX(), getContentsY(), sdPrintDialog
, context
, 1);
1058 } else if (sdPrintDialog
.printRange()) {
1059 for (int pageIndex
= sdPrintDialog
.getFrom(); pageIndex
<= sdPrintDialog
.maxNumOfPages() && pageIndex
<= sdPrintDialog
.getTo(); pageIndex
++) {
1060 printPage(pageIndex
, sdPrintDialog
, context
);
1065 fIsPrinting
= false;
1070 fZoomValue
= lastZoom
;
1072 setContentsPos(restoreX
, restoreY
);
1078 public void print() {
1079 SDPrintDialog sdPrinter
= new SDPrintDialog(this.getShell(), this);
1081 if (sdPrinter
.open() != 0) {
1084 } catch (Exception e
) {
1085 Activator
.getDefault().logError("Error creating image", e
); //$NON-NLS-1$
1088 printUI(sdPrinter
.getDialogUI());
1092 * Method to print a page.
1094 * @param pageNum The page number
1095 * @param pd The sequence diagram print dialog
1096 * @param context The graphical context
1098 public void printPage(int pageNum
, SDPrintDialogUI pd
, NGC context
) {
1099 int j
= pageNum
/ pd
.getNbRow();
1100 int i
= pageNum
% pd
.getNbRow();
1110 i
= (int) (i
* pd
.getStepX());
1111 j
= (int) (j
* pd
.getStepY());
1113 printPage(i
, j
, pd
, context
, pageNum
);
1119 * Method to print page ranges.
1126 * The sequence diagram print dialog
1128 * The graphical context
1132 public void printPage(int i
, int j
, SDPrintDialogUI pd
, NGC context
, int pageNum
) {
1133 fIsPrinting
= false;
1134 int pageNumFontZoom
= fPrinter
.getClientArea().height
/ getVisibleHeight();
1137 setContentsPos(i
, j
);
1140 float lastZoom
= fZoomValue
;
1141 fZoomValue
= fPrinterZoom
* lastZoom
;
1143 fFrame
.draw(context
);
1145 fZoomValue
= pageNumFontZoom
;
1146 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1147 String currentPageNum
= String
.valueOf(pageNum
);
1148 int ii
= context
.textExtent(currentPageNum
);
1149 int jj
= context
.getCurrentFontHeight();
1150 // context.setBackground(ColorImpl.getSystemColor(SWT.COLOR_BLACK));
1151 // context.setForeground(ColorImpl.getSystemColor(SWT.COLOR_WHITE));
1152 fZoomValue
= fPrinterZoom
* lastZoom
;
1153 context
.drawText(currentPageNum
, Math
.round(fPrinterX
+ getVisibleWidth() / fPrinterZoom
- ii
/ fPrinterZoom
), Math
.round(fPrinterY
+ getVisibleHeight() / fPrinterZoom
- jj
/ fPrinterZoom
), false);
1154 fIsPrinting
= false;
1155 fZoomValue
= lastZoom
;
1159 * Sets the collapse provider.
1161 * @param provider The collapse provider to set
1163 protected void setCollapseProvider(ISDCollapseProvider provider
) {
1164 fCollapseProvider
= provider
;
1169 * Checks for focus of children.
1171 * @param children Control to check
1172 * @return true if child is on focus else false
1174 protected boolean checkFocusOnChilds(Control children
) {
1175 if (children
instanceof Composite
) {
1176 Control
[] child
= ((Composite
) children
).getChildren();
1177 for (int i
= 0; i
< child
.length
; i
++) {
1178 if (child
[i
].isFocusControl()) {
1181 checkFocusOnChilds(child
[i
]);
1188 * A post action for a tooltip (before displaying).
1190 * @param accessible true if accessible else false
1191 * @return the tooltip text.
1193 protected String
getPostfixForTooltip(boolean accessible
) {
1194 StringBuffer postfix
= new StringBuffer();
1195 // Determine if the tooltip must show the time difference between the current mouse position and
1196 // the last selected graphNode
1197 if ((fCurrentGraphNode
!= null) &&
1198 (fCurrentGraphNode
instanceof ITimeRange
) &&
1199 (fToolTipNode
instanceof ITimeRange
) &&
1200 (fCurrentGraphNode
!= fToolTipNode
) &&
1201 ((ITimeRange
) fToolTipNode
).hasTimeInfo() &&
1202 ((ITimeRange
) fCurrentGraphNode
).hasTimeInfo()) {
1203 postfix
.append(" -> "); //$NON-NLS-1$
1204 postfix
.append(fCurrentGraphNode
.getName());
1205 postfix
.append("\n"); //$NON-NLS-1$
1206 postfix
.append(SDMessages
._138
);
1207 postfix
.append(" "); //$NON-NLS-1$
1209 //double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
1210 ITmfTimestamp firstTime
= ((ITimeRange
) fCurrentGraphNode
).getEndTime();
1211 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1212 ITmfTimestamp delta
= lastTime
.getDelta(firstTime
);
1213 postfix
.append(delta
.toString());
1216 if ((fToolTipNode
instanceof ITimeRange
) && ((ITimeRange
) fToolTipNode
).hasTimeInfo()) {
1217 postfix
.append("\n"); //$NON-NLS-1$
1218 ITmfTimestamp firstTime
= ((ITimeRange
) fToolTipNode
).getStartTime();
1219 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1221 if (firstTime
!= null) {
1222 if (lastTime
!= null && firstTime
.compareTo(lastTime
, true) != 0) {
1223 postfix
.append("start: "); //$NON-NLS-1$
1224 postfix
.append(firstTime
.toString());
1225 postfix
.append("\n"); //$NON-NLS-1$
1226 postfix
.append("end: "); //$NON-NLS-1$
1227 postfix
.append(lastTime
.toString());
1228 postfix
.append("\n"); //$NON-NLS-1$
1230 postfix
.append(firstTime
.toString());
1233 else if (lastTime
!= null) {
1234 postfix
.append(lastTime
.toString());
1238 return postfix
.toString();
1242 * Sets a new focused widget.
1244 * @param newFocusShape A new focus shape.
1246 protected void setFocus(int newFocusShape
) {
1247 fFocusedWidget
= newFocusShape
;
1248 if (fFocusedWidget
== -1) {
1249 getViewControl().getAccessible().setFocus(ACC
.CHILDID_SELF
);
1251 getViewControl().getAccessible().setFocus(fFocusedWidget
);
1256 * Highlight the given GraphNode<br>
1257 * The GraphNode is then displayed using the system default selection color
1259 * @param node the GraphNode to highlight
1261 protected void performSelection(GraphNode node
) {
1262 if ((fCtrlSelection
) || (fShiftSelection
)) {
1264 if (fSelectedNodeList
.contains(node
)) {
1265 removeSelection(node
);
1281 * Returns a draw buffer image.
1283 * @return a Image containing the draw buffer.
1285 protected Image
getDrawBuffer() {
1288 Rectangle area
= getClientArea();
1289 Image dbuffer
= null;
1293 dbuffer
= new Image(getDisplay(), area
.width
, area
.height
);
1294 } catch (Exception e
) {
1295 Activator
.getDefault().logError("Error creating image", e
); //$NON-NLS-1$
1298 gcim
= new GC(dbuffer
);
1300 NGC context
= new NGC(this, gcim
);
1302 // Set the metrics to use for lifeline text and message text
1303 // using the Graphical Context
1304 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
1305 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
1306 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
1307 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
1308 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
1310 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS
));
1311 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS_RET
));
1312 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS
));
1313 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS_RET
));
1315 int messageFontHeight
= 0;
1316 if (syncMessFontH
> syncMessRetFontH
) {
1317 messageFontHeight
= syncMessFontH
;
1319 messageFontHeight
= syncMessRetFontH
;
1321 if (messageFontHeight
< asyncMessFontH
) {
1322 messageFontHeight
= asyncMessFontH
;
1324 if (messageFontHeight
< asyncMessRetFontH
) {
1325 messageFontHeight
= asyncMessRetFontH
;
1327 Metrics
.setMessageFontHeight(messageFontHeight
);
1328 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1330 int width
= (int) ((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1331 int height
= (int) ((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1333 resizeContents(width
, height
);
1335 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1336 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1337 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1338 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1339 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1340 gcim
.setLineWidth(1);
1342 fFrame
.draw(context
);
1343 if (fDragAndDrop
!= null) {
1344 Lifeline node
= fDragAndDrop
;
1345 boolean isSelected
= fDragAndDrop
.isSelected();
1346 boolean hasFocus
= fDragAndDrop
.hasFocus();
1347 node
.setSelected(false);
1348 node
.setFocused(false);
1349 node
.draw(context
, fDragX
, fDragY
);
1350 node
.setSelected(isSelected
);
1351 node
.setFocused(hasFocus
);
1360 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
1363 protected void keyPressedEvent(KeyEvent event
) {
1364 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1365 Control
[] child
= getParent().getChildren();
1366 for (int i
= 0; i
< child
.length
; i
++) {
1367 if ((child
[i
].isFocusControl())&& (!(child
[i
] instanceof ScrollView
))) {
1368 getViewControl().setFocus();
1375 if (event
.keyCode
== SWT
.CTRL
) {
1376 fCtrlSelection
= true;
1378 if (event
.keyCode
== SWT
.SHIFT
) {
1379 fShiftSelection
= true;
1380 fPrevList
= new ArrayList
<GraphNode
>();
1381 fPrevList
.addAll(getSelection());
1384 GraphNode prevNode
= getFocusNode();
1386 if (event
.keyCode
== SWT
.ARROW_RIGHT
) {
1390 if (event
.keyCode
== SWT
.ARROW_LEFT
) {
1394 if (event
.keyCode
== SWT
.ARROW_DOWN
) {
1398 if (event
.keyCode
== SWT
.ARROW_UP
) {
1402 if (event
.keyCode
== SWT
.HOME
) {
1406 if (event
.keyCode
== SWT
.END
) {
1410 if ((!fShiftSelection
) && (!fCtrlSelection
)) {
1411 fListStart
= fCurrentGraphNode
;
1414 if (event
.character
== ' ') {
1415 performSelection(fCurrentGraphNode
);
1416 if (!fShiftSelection
) {
1417 fListStart
= fCurrentGraphNode
;
1421 if ((fShiftSelection
) && (prevNode
!= getFocusNode())) {
1423 addSelection(fPrevList
);
1424 addSelection(fFrame
.getNodeList(fListStart
, getFocusNode()));
1425 if (getFocusNode() instanceof Lifeline
) {
1426 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1428 ensureVisible(getFocusNode());
1430 } else if ((!fCtrlSelection
) && (!fShiftSelection
)) {
1433 if (getFocusNode() != null) {
1434 addSelection(getFocusNode());
1436 if (getFocusNode() instanceof Lifeline
) {
1437 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1439 ensureVisible(getFocusNode());
1444 if (fCurrentGraphNode
!= null) {
1445 fCurrentGraphNode
.setFocused(true);
1449 if ((event
.character
== ' ') && ((fZoomInMode
) || (fZoomOutMode
))) {
1450 int cx
= Math
.round((getContentsX() + getVisibleWidth() / 2) / fZoomValue
);
1451 int cy
= Math
.round((getContentsY() + getVisibleHeight() / 2) / fZoomValue
);
1453 if (fZoomValue
< 64) {
1454 fZoomValue
= fZoomValue
* (float) 1.25;
1457 fZoomValue
= fZoomValue
/ (float) 1.25;
1459 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1460 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1461 setContentsPos(x
, y
);
1462 if (fTimeBar
!= null) {
1463 fTimeBar
.setZoom(fZoomValue
);
1465 // redraw also resize the scrollView content
1472 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
1475 protected void keyReleasedEvent(KeyEvent event
) {
1477 if (event
.keyCode
== SWT
.CTRL
) {
1478 fCtrlSelection
= false;
1480 if (event
.keyCode
== SWT
.SHIFT
) {
1481 fShiftSelection
= false;
1483 super.keyReleasedEvent(event
);
1489 * @see org.eclipse.swt.widgets.Control#isFocusControl()
1492 public boolean isFocusControl() {
1493 Control
[] child
= getChildren();
1494 for (int i
= 0; i
< child
.length
; i
++) {
1495 if (child
[i
].isFocusControl()) {
1498 checkFocusOnChilds(child
[i
]);
1505 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#setContentsPos(int, int)
1508 public boolean setContentsPos(int x
, int y
) {
1518 if (fFrame
== null) {
1521 if (localX
+ getVisibleWidth() > getContentsWidth()) {
1522 localX
= getContentsWidth() - getVisibleWidth();
1524 if (localY
+ getVisibleHeight() > getContentsHeight()) {
1525 localY
= getContentsHeight() - getVisibleHeight();
1527 int x1
= Math
.round(localX
/ fZoomValue
);
1528 int y2
= Math
.round(localY
/ fZoomValue
);
1529 int width
= Math
.round(getVisibleWidth() / fZoomValue
);
1530 int height
= Math
.round(getVisibleHeight() / fZoomValue
);
1531 fFrame
.updateIndex(x1
, y2
, width
, height
);
1533 if (fInsertionCartet
!= null && fInsertionCartet
.isVisible()) {
1534 fInsertionCartet
.setVisible(false);
1537 return super.setContentsPos(localX
, localY
);
1542 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
1545 protected void contentsMouseHover(MouseEvent event
) {
1546 GraphNode graphNode
= null;
1547 if (fFrame
!= null) {
1548 int x
= Math
.round(event
.x
/ fZoomValue
);
1549 int y
= Math
.round(event
.y
/ fZoomValue
);
1550 graphNode
= fFrame
.getNodeAt(x
, y
);
1551 if ((graphNode
!= null) && (SDViewPref
.getInstance().tooltipEnabled())) {
1552 fToolTipNode
= graphNode
;
1553 String postfix
= getPostfixForTooltip(true);
1554 if (graphNode
instanceof Lifeline
) {
1555 Lifeline lifeline
= (Lifeline
) graphNode
;
1556 fToolTip
.showToolTip(lifeline
.getToolTipText() + postfix
);
1559 fToolTip
.showToolTip(graphNode
.getName() + postfix
);
1563 fToolTip
.hideToolTip();
1570 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
1573 protected void contentsMouseMoveEvent(MouseEvent e
) {
1574 fScrollToolTip
.hideToolTip();
1575 fToolTip
.hideToolTip();
1576 // super.contentsMouseMoveEvent(e);
1577 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1578 Control
[] child
= getParent().getChildren();
1579 for (int i
= 0; i
< child
.length
; i
++) {
1580 if ((child
[i
].isFocusControl()) && (!(child
[i
] instanceof ScrollView
))) {
1581 getViewControl().setFocus();
1588 if (((e
.stateMask
& SWT
.BUTTON_MASK
) != 0) && ((fDragAndDrop
!= null) || fIsDragAndDrop
) && (fReorderMode
|| fCollapseProvider
!= null)) {
1589 fIsDragAndDrop
= false;
1590 if (fCurrentGraphNode
instanceof Lifeline
) {
1591 fDragAndDrop
= (Lifeline
) fCurrentGraphNode
;
1593 if (fDragAndDrop
!= null) {
1596 if (e
.x
> getContentsX() + getVisibleWidth()) {
1597 dx
= e
.x
- (getContentsX() + getVisibleWidth());
1598 } else if (e
.x
< getContentsX()) {
1599 dx
= -getContentsX() + e
.x
;
1601 if (e
.y
> getContentsY() + getVisibleHeight()) {
1602 dy
= e
.y
- (getContentsY() + getVisibleHeight());
1603 } else if (e
.y
< getContentsY()) {
1604 dy
= -getContentsY() + e
.y
;
1608 if (dx
!= 0 || dy
!= 0) {
1609 if (fLocalAutoScroll
== null) {
1610 if (fLocalAutoScrollTimer
== null) {
1611 fLocalAutoScrollTimer
= new Timer(true);
1613 fLocalAutoScroll
= new AutoScroll(this, dx
, dy
);
1614 fLocalAutoScrollTimer
.schedule(fLocalAutoScroll
, 0, 75);
1616 fLocalAutoScroll
.fDeltaX
= dx
;
1617 fLocalAutoScroll
.fDeltaY
= dy
;
1619 } else if (fLocalAutoScroll
!= null) {
1620 fLocalAutoScroll
.cancel();
1621 fLocalAutoScroll
= null;
1623 fDragX
= Math
.round(e
.x
/ fZoomValue
);
1624 fDragY
= Math
.round(e
.y
/ fZoomValue
);
1626 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1627 if ((node
!= null) && (node
!= fDragAndDrop
)) {
1630 int height
= Metrics
.getLifelineHeaderFontHeigth() + 2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
;
1631 int hMargin
= Metrics
.LIFELINE_VT_MAGIN
/ 4;
1632 int x
= node
.getX();
1633 int width
= node
.getWidth();
1634 if (fFrame
.getVisibleAreaY() < node
.getY() + node
.getHeight() - height
- hMargin
) {
1635 y
= contentsToViewY(Math
.round((node
.getY() + node
.getHeight()) * fZoomValue
));
1637 y
= Math
.round(height
* fZoomValue
);
1640 if (fFrame
.getVisibleAreaY() < contentsToViewY(node
.getY() - hMargin
)) {
1641 y1
= contentsToViewY(Math
.round((node
.getY() - hMargin
) * fZoomValue
));
1643 y1
= Math
.round(height
* fZoomValue
);
1646 int rx
= Math
.round(x
* fZoomValue
);
1648 fInsertionCartet
.setVisible(true);
1649 if ((fInsertionCartet
.getImage() != null) && (!fInsertionCartet
.getImage().isDisposed())) {
1650 fInsertionCartet
.getImage().dispose();
1652 if (rx
<= e
.x
&& Math
.round(rx
+ (width
* fZoomValue
)) >= e
.x
) {
1653 if (fCollapseProvider
!= null) {
1654 ImageData data
= fCollapaseCaretImg
.getImageData();
1655 data
= data
.scaledTo(Math
.round(fCollapaseCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fCollapaseCaretImg
.getBounds().height
* fZoomValue
));
1656 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1657 fInsertionCartet
.setImage(fCurrentCaretImage
);
1658 fInsertionCartet
.setLocation(contentsToViewX(rx
+ Math
.round((width
/ (float) 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y
);
1660 } else if (fReorderMode
) {
1662 if (node
.getIndex() > 1 && fFrame
.getLifeline(node
.getIndex() - 2) == fDragAndDrop
) {
1665 ImageData data
= fArrowUpCaretImg
.getImageData();
1666 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1667 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1668 fInsertionCartet
.setImage(fCurrentCaretImage
);
1669 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
- Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y1
);
1671 if (node
.getIndex() < fFrame
.lifeLinesCount() && fFrame
.getLifeline(node
.getIndex()) == fDragAndDrop
) {
1674 ImageData data
= fArrowUpCaretImg
.getImageData();
1675 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1676 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1677 fInsertionCartet
.setImage(fCurrentCaretImage
);
1678 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
+ width
+ Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2 + 1, y1
);
1682 fInsertionCartet
.setVisible(false);
1686 super.contentsMouseMoveEvent(e
);
1692 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
1695 protected void contentsMouseUpEvent(MouseEvent event
) {
1696 // Just in case the diagram highlight a time compression region
1697 // this region need to be released when clicking everywhere
1698 fInsertionCartet
.setVisible(false);
1699 if (fDragAndDrop
!= null) {
1700 if ((fOverView
!= null) && (!fOverView
.isDisposed())) {
1701 fOverView
.dispose();
1704 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1706 int rx
= Math
.round(node
.getX() * fZoomValue
);
1707 if (rx
<= event
.x
&& Math
.round(rx
+ (node
.getWidth() * fZoomValue
)) >= event
.x
) {
1708 if ((fCollapseProvider
!= null) && (fDragAndDrop
!= node
)) {
1709 fCollapseProvider
.collapseTwoLifelines(fDragAndDrop
, node
);
1711 } else if (rx
< event
.x
) {
1712 fFrame
.insertLifelineAfter(fDragAndDrop
, node
);
1713 if (node
.getIndex() < fFrame
.lifeLinesCount()) {
1714 Lifeline temp
[] = { fDragAndDrop
, fFrame
.getLifeline(node
.getIndex()) };
1715 fReorderList
.add(temp
);
1717 Lifeline temp
[] = { fDragAndDrop
, null };
1718 fReorderList
.add(temp
);
1721 fFrame
.insertLifelineBefore(fDragAndDrop
, node
);
1722 Lifeline temp
[] = { fDragAndDrop
, node
};
1723 fReorderList
.add(temp
);
1727 fDragAndDrop
= null;
1729 if (fFrame
== null) {
1732 fFrame
.resetTimeCompression();
1734 // reset auto scroll if it's engaged
1735 if (fLocalAutoScroll
!= null) {
1736 fLocalAutoScroll
.cancel();
1737 fLocalAutoScroll
= null;
1739 super.contentsMouseUpEvent(event
);
1744 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseDownEvent(org.eclipse.swt.events.MouseEvent)
1747 protected void contentsMouseDownEvent(MouseEvent event
) {
1748 if (fCurrentGraphNode
!= null) {
1749 fCurrentGraphNode
.setFocused(false);
1752 // Just in case the diagram highlight a time compression region
1753 // this region need to be released when clicking everywhere
1754 if (fFrame
== null) {
1758 fFrame
.resetTimeCompression();
1760 if ((event
.stateMask
& SWT
.CTRL
) != 0) {
1761 fCtrlSelection
= true;
1763 fCtrlSelection
= false;
1766 if (((fZoomInMode
) || (fZoomOutMode
)) && (event
.button
== 1)) {
1767 int cx
= Math
.round(event
.x
/ fZoomValue
);
1768 int cy
= Math
.round(event
.y
/ fZoomValue
);
1770 if (fZoomValue
< 64) {
1771 fZoomValue
= fZoomValue
* (float) 1.25;
1774 fZoomValue
= fZoomValue
/ (float) 1.25;
1776 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1777 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1778 setContentsPos(x
, y
);
1779 if (fTimeBar
!= null) {
1780 fTimeBar
.setZoom(fZoomValue
);
1782 // redraw also resize the scrollView content
1784 } else {// if (event.button ==1)
1785 GraphNode node
= null;
1786 int x
= Math
.round(event
.x
/ fZoomValue
);
1787 int y
= Math
.round(event
.y
/ fZoomValue
);
1788 node
= fFrame
.getNodeAt(x
, y
);
1790 if ((event
.button
== 1) || ((node
!= null) && !node
.isSelected())) {
1791 if (!fShiftSelection
) {
1794 if (fShiftSelection
) {
1796 addSelection(fFrame
.getNodeList(fListStart
, node
));
1798 performSelection(node
);
1800 fCurrentGraphNode
= node
;
1802 node
.setFocused(true);
1807 if (fDragAndDrop
== null) {
1808 super.contentsMouseDownEvent(event
);
1810 fIsDragAndDrop
= (event
.button
== 1);
1815 * TimerTask for auto scroll feature.
1817 protected static class AutoScroll
extends TimerTask
{
1827 * Field sequence diagram reference.
1829 public SDWidget fSdWidget
;
1832 * Constructor for AutoScroll.
1833 * @param sv sequence diagram widget reference
1837 public AutoScroll(SDWidget sv
, int dx
, int dy
) {
1845 * @see java.util.TimerTask#run()
1849 Display
.getDefault().asyncExec(new Runnable() {
1852 if (fSdWidget
.isDisposed()) {
1855 fSdWidget
.fDragX
+= fDeltaX
;
1856 fSdWidget
.fDragY
+= fDeltaY
;
1857 fSdWidget
.scrollBy(fDeltaX
, fDeltaY
);
1865 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
1868 protected void drawContents(GC gc
, int clipx
, int clipy
, int clipw
, int cliph
) {
1869 if (fFrame
== null) {
1870 gc
.setBackground(getDisplay().getSystemColor(SWT
.COLOR_WHITE
));
1871 gc
.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
1875 // Frame.setUserPref(SDViewPref.getInstance());
1876 SDViewPref
.getInstance();
1878 Rectangle area
= getClientArea();
1879 Image dbuffer
= getDrawBuffer();
1880 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1883 gc
.drawImage(dbuffer
, 0, 0, area
.width
, area
.height
, 0, 0, area
.width
, area
.height
);
1884 } catch (Exception e
) {
1885 Activator
.getDefault().logError("Error drawin content", e
); //$NON-NLS-1$
1888 setHScrollBarIncrement(Math
.round(SDViewPref
.getInstance().getLifelineWidth() / (float) 2 * fZoomValue
));
1889 setVScrollBarIncrement(Math
.round(Metrics
.getMessagesSpacing() * fZoomValue
));
1890 if ((fTimeBar
!= null) && (fFrame
.hasTimeInfo())) {
1891 fTimeBar
.resizeContents(9, height
+ getHorizontalBarHeight());
1892 fTimeBar
.setContentsPos(getContentsX(), getContentsY());
1896 float xRatio
= getContentsWidth() / (float) getVisibleWidth();
1897 float yRatio
= getContentsHeight() / (float) getVisibleHeight();
1898 if (yRatio
> xRatio
) {
1899 setOverviewSize((int) (getVisibleHeight() * 0.75));
1901 setOverviewSize((int) (getVisibleWidth() * 0.75));
1907 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
1910 public void widgetDefaultSelected(SelectionEvent event
) {
1915 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
1918 public void widgetSelected(SelectionEvent event
) {
1919 if (event
.widget
== fZoomIn
) {
1920 fZoomValue
= fZoomValue
* 2;
1921 } else if (event
.widget
== fZoomOut
) {
1922 fZoomValue
= fZoomValue
/ 2;
1928 * Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply button
1931 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
1934 public void propertyChange(PropertyChangeEvent e
) {
1935 if (fFrame
!= null && !isDisposed()) {
1936 fFrame
.resetTimeCompression();
1938 if (e
.getProperty().equals("PREFOK")) //$NON-NLS-1$
1940 // Prepare the overview to be reused for the new
1941 // settings (especially the colors)
1942 if (fOverView
!= null) {
1943 fOverView
.dispose();
1952 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
1955 public void widgetDisposed(DisposeEvent e
) {
1956 if (fOverView
!= null) {
1957 fOverView
.dispose();
1959 super.removeDisposeListener(this);
1960 if ((fCurrentCaretImage
!= null) && (!fCurrentCaretImage
.isDisposed())) {
1961 fCurrentCaretImage
.dispose();
1963 if ((fArrowUpCaretImg
!= null) && (!fArrowUpCaretImg
.isDisposed())) {
1964 fArrowUpCaretImg
.dispose();
1966 if ((fCollapaseCaretImg
!= null) && (!fCollapaseCaretImg
.isDisposed())) {
1967 fCollapaseCaretImg
.dispose();
1969 SDViewPref
.getInstance().removePropertyChangeListener(this);
1970 LoadersManager lm
= LoadersManager
.getInstance();
1971 if (fSite
instanceof SDView
) {
1972 ((SDView
) fSite
).resetProviders();
1974 lm
.resetLoader(((SDView
) fSite
).getViewSite().getId());
1981 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawOverview(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle)
1984 protected void drawOverview(GC gc
, Rectangle r
) {
1985 float oldzoom
= fZoomValue
;
1986 if (getContentsWidth() > getContentsHeight()) {
1987 fZoomValue
= (float) r
.width
/ (float) getContentsWidth() * oldzoom
;
1989 fZoomValue
= (float) r
.height
/ (float) getContentsHeight() * oldzoom
;
1991 if ((fOverView
!= null) && ((r
.width
!= fOverView
.getBounds().width
) || (r
.height
!= fOverView
.getBounds().height
))) {
1992 fOverView
.dispose();
1995 if (fOverView
== null) {
1996 int backX
= getContentsX();
1997 int backY
= getContentsY();
1998 setContentsPos(0, 0);
1999 fOverView
= new Image(getDisplay(), r
.width
, r
.height
);
2000 GC gcim
= new GC(fOverView
);
2001 NGC context
= new NGC(this, gcim
);
2002 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
2003 fFrame
.draw(context
);
2004 setContentsPos(backX
, backY
);
2008 if ((fOverView
!= null) && (r
.width
== fOverView
.getBounds().width
) && (r
.height
== fOverView
.getBounds().height
)) {
2009 gc
.drawImage(fOverView
, 0, 0, r
.width
, r
.height
, 0, 0, r
.width
, r
.height
);
2012 fZoomValue
= oldzoom
;
2014 super.drawOverview(gc
, r
);
2019 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ITimeCompressionListener#deltaSelected(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline, int, int, org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor)
2022 public void deltaSelected(Lifeline lifeline
, int startEvent
, int nbEvent
, IColor color
) {
2023 fFrame
.highlightTimeCompression(lifeline
, startEvent
, nbEvent
, color
);
2024 ensureVisible(lifeline
);
2025 int y1
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * startEvent
;
2026 int y2
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * (startEvent
+ nbEvent
);
2027 ensureVisible(lifeline
.getX(), y1
- (Metrics
.getLifelineHeaderFontHeigth() + +2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
), lifeline
.getWidth(), y2
- y1
+ 3, SWT
.CENTER
| SWT
.VERTICAL
, true);
2034 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleWidth()
2037 public int getVisibleWidth() {
2039 return fPrinter
.getClientArea().width
;
2041 return super.getVisibleWidth();
2046 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleHeight()
2049 public int getVisibleHeight() {
2051 return fPrinter
.getClientArea().height
;
2053 return super.getVisibleHeight();
2058 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewX(int)
2061 public int contentsToViewX(int x
) {
2063 int v
= Math
.round(fPrinterX
* fPrinterZoom
);
2066 return x
- getContentsX();
2071 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewY(int)
2074 public int contentsToViewY(int y
) {
2076 int v
= Math
.round(fPrinterY
* fPrinterZoom
);
2079 return y
- getContentsY();
2084 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsX()
2087 public int getContentsX() {
2089 return Math
.round(fPrinterX
* fPrinterZoom
);
2091 return super.getContentsX();
2097 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsY()
2100 public int getContentsY() {
2102 return Math
.round(fPrinterY
* fPrinterZoom
);
2104 return super.getContentsY();
2108 * Traverse Listener implementation.
2110 protected static class LocalTraverseListener
implements TraverseListener
{
2114 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
2117 public void keyTraversed(TraverseEvent e
) {
2118 if ((e
.detail
== SWT
.TRAVERSE_TAB_NEXT
) || (e
.detail
== SWT
.TRAVERSE_TAB_PREVIOUS
)) {