1 /**********************************************************************
2 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
;
15 import java
.text
.MessageFormat
;
16 import java
.util
.ArrayList
;
17 import java
.util
.List
;
18 import java
.util
.Timer
;
19 import java
.util
.TimerTask
;
21 import org
.eclipse
.jface
.contexts
.IContextIds
;
22 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
23 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
24 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
25 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
26 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
27 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
29 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BaseMessage
;
30 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BasicExecutionOccurrence
;
31 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Frame
;
32 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.ITimeRange
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Lifeline
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Metrics
;
36 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialog
;
37 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialogUI
;
38 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IColor
;
39 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDCollapseProvider
;
40 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.LoadersManager
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
44 import org
.eclipse
.swt
.SWT
;
45 import org
.eclipse
.swt
.accessibility
.ACC
;
46 import org
.eclipse
.swt
.accessibility
.Accessible
;
47 import org
.eclipse
.swt
.accessibility
.AccessibleAdapter
;
48 import org
.eclipse
.swt
.accessibility
.AccessibleControlAdapter
;
49 import org
.eclipse
.swt
.accessibility
.AccessibleControlEvent
;
50 import org
.eclipse
.swt
.accessibility
.AccessibleEvent
;
51 import org
.eclipse
.swt
.events
.DisposeEvent
;
52 import org
.eclipse
.swt
.events
.DisposeListener
;
53 import org
.eclipse
.swt
.events
.FocusEvent
;
54 import org
.eclipse
.swt
.events
.FocusListener
;
55 import org
.eclipse
.swt
.events
.KeyEvent
;
56 import org
.eclipse
.swt
.events
.MouseEvent
;
57 import org
.eclipse
.swt
.events
.SelectionEvent
;
58 import org
.eclipse
.swt
.events
.SelectionListener
;
59 import org
.eclipse
.swt
.events
.TraverseEvent
;
60 import org
.eclipse
.swt
.events
.TraverseListener
;
61 import org
.eclipse
.swt
.graphics
.GC
;
62 import org
.eclipse
.swt
.graphics
.Image
;
63 import org
.eclipse
.swt
.graphics
.ImageData
;
64 import org
.eclipse
.swt
.graphics
.Rectangle
;
65 import org
.eclipse
.swt
.printing
.Printer
;
66 import org
.eclipse
.swt
.printing
.PrinterData
;
67 import org
.eclipse
.swt
.widgets
.Canvas
;
68 import org
.eclipse
.swt
.widgets
.Caret
;
69 import org
.eclipse
.swt
.widgets
.Composite
;
70 import org
.eclipse
.swt
.widgets
.Control
;
71 import org
.eclipse
.swt
.widgets
.Display
;
72 import org
.eclipse
.swt
.widgets
.Event
;
73 import org
.eclipse
.swt
.widgets
.Listener
;
74 import org
.eclipse
.swt
.widgets
.MenuItem
;
75 import org
.eclipse
.ui
.contexts
.IContextService
;
76 import org
.eclipse
.ui
.part
.ViewPart
;
80 * This class implements sequence diagram widget used in the sequence diagram view.
86 public class SDWidget
extends ScrollView
implements SelectionListener
,
87 IPropertyChangeListener
, DisposeListener
, ITimeCompressionListener
{
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
94 * The frame to display in the sequence diagram widget.
96 protected Frame fFrame
;
98 * The overview image to display.
100 protected Image fOverView
= null;
102 * The zoom in menu item.
104 protected MenuItem fZoomIn
= null;
106 * The zoom out menu item.
108 protected MenuItem fZoomOut
= null;
110 * The sequence diagram selection provider.
112 protected SDWidgetSelectionProvider fSelProvider
= null;
114 * The current zoom value.
116 public float fZoomValue
= 1;
118 * The current zoomInMode (true for zoom in).
120 protected boolean fZoomInMode
= false;
122 * The current zoomOutMode (true for zoom out).
124 protected boolean fZoomOutMode
= false;
126 * The current list of selected graph nodes.
128 protected List
<GraphNode
> fSelectedNodeList
= null;
130 * Flag whether ctrl button is selected or not.
132 protected boolean fCtrlSelection
= false;
134 * A reference to the view site.
136 protected ViewPart fSite
= null;
138 * The current graph node (the last selected one).
140 public GraphNode fCurrentGraphNode
= null;
142 * The first graph node in list (multiple selection).
144 public GraphNode fListStart
= null;
146 * The previous graph node (multiple selection).
148 public List
<GraphNode
> fPrevList
= null;
150 * The time compression bar.
152 protected TimeCompressionBar fTimeBar
= null;
154 * The current diagram tool tip.
156 protected DiagramToolTip fToolTip
= null;
158 * The accessible object reference of view control.
160 protected Accessible fAccessible
= null;
162 * The current node for the tooltip to display.
164 protected GraphNode fToolTipNode
;
166 * The life line to drag and drop.
168 protected Lifeline fDragAndDrop
= null;
170 * The number of focused widgets.
172 protected int fFocusedWidget
= -1;
176 protected float fPrinterZoom
= 0;
178 * Y coordinate for printer.
180 protected int fPrinterY
= 0;
182 * X coordinate for printer.
184 protected int fPrinterX
= 0;
186 * Flag whether drag and drop is enabled or not.
188 protected boolean fIsDragAndDrop
= false;
190 * The x coordinate for drag.
192 protected int fDragX
= 0;
194 * The y coordinate for drag.
196 protected int fDragY
= 0;
200 protected boolean fReorderMode
= false;
202 * The collapse caret image.
204 protected Image fCollapaseCaretImg
= null;
206 * The arrow up caret image.
208 protected Image fArrowUpCaretImg
= null;
210 * The current caret image.
212 protected Image fCurrentCaretImage
= null;
214 * A sequence diagramm collapse provider (for collapsing graph nodes)
216 protected ISDCollapseProvider fCollapseProvider
= null;
218 * The insertion caret.
220 protected Caret fInsertionCartet
= null;
222 * The reorder list when in reorder mode.
224 protected List
<Lifeline
[]> fReorderList
= null;
226 * Flag to specify whether in printing mode or not.
228 protected boolean fIsPrinting
= false;
230 * A printer reference.
232 protected Printer fPrinter
= null;
234 * Flag whether shift was selected or not.
236 protected boolean fShiftSelection
= false;
238 * The scroll tooltip.
240 protected DiagramToolTip fScrollToolTip
= null;
242 * Timer for auto_scroll feature
244 protected AutoScroll fLocalAutoScroll
= null;
246 * TimerTask for auto_scroll feature !=null when auto scroll is running
248 protected Timer fLocalAutoScrollTimer
= null;
250 // ------------------------------------------------------------------------
252 // ------------------------------------------------------------------------
254 * Constructor for SDWidget.
255 * @param c The parent composite
258 public SDWidget(Composite c
, int s
) {
259 super(c
, s
| SWT
.NO_BACKGROUND
, true);
260 setOverviewEnabled(true);
261 fSelectedNodeList
= new ArrayList
<GraphNode
>();
262 fSelProvider
= new SDWidgetSelectionProvider();
263 SDViewPref
.getInstance().addPropertyChangeListener(this);
264 fToolTip
= new DiagramToolTip(getViewControl());
265 super.addDisposeListener(this);
267 fScrollToolTip
= new DiagramToolTip(c
);
268 getVerticalBar().addListener(SWT
.MouseUp
, new Listener() {
271 public void handleEvent(Event event
) {
272 fScrollToolTip
.hideToolTip();
276 fAccessible
= getViewControl().getAccessible();
278 fAccessible
.addAccessibleListener(new AccessibleAdapter() {
281 * @see org.eclipse.swt.accessibility.AccessibleAdapter#getName(org.eclipse.swt.accessibility.AccessibleEvent)
284 public void getName(AccessibleEvent e
) {
286 if (e
.childID
== 0) {
287 if (fToolTipNode
!= null) {
288 if (fToolTipNode
instanceof Lifeline
) {
289 Lifeline lifeline
= (Lifeline
) fToolTipNode
;
290 e
.result
= lifeline
.getToolTipText();
292 e
.result
= fToolTipNode
.getName() + getPostfixForTooltip(true);
296 if (getFocusNode() != null) {
297 if (getFocusNode() instanceof Lifeline
) {
298 e
.result
= MessageFormat
.format(SDMessages
._1
, new Object
[] { String
.valueOf(getFocusNode().getName()) });
300 if (getFocusNode() instanceof BaseMessage
) {
301 BaseMessage mes
= (BaseMessage
) getFocusNode();
302 if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() != null)) {
303 e
.result
= MessageFormat
.format(
305 new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()), String
.valueOf(mes
.getEndLifeline().getName()),
306 Integer
.valueOf(mes
.getEndOccurrence()) });
307 } else if ((mes
.getStartLifeline() == null) && (mes
.getEndLifeline() != null)) {
308 e
.result
= MessageFormat
.format(SDMessages
._4
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getEndLifeline().getName()), Integer
.valueOf(mes
.getEndOccurrence()) });
309 } else if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() == null)) {
310 e
.result
= MessageFormat
.format(SDMessages
._3
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()) });
312 } else if (getFocusNode() instanceof BasicExecutionOccurrence
) {
313 BasicExecutionOccurrence exec
= (BasicExecutionOccurrence
) getFocusNode();
314 e
.result
= MessageFormat
.format(SDMessages
._5
,
315 new Object
[] { String
.valueOf(exec
.getName()), String
.valueOf(exec
.getLifeline().getName()), Integer
.valueOf(exec
.getStartOccurrence()), Integer
.valueOf(exec
.getEndOccurrence()) });
323 fAccessible
.addAccessibleControlListener(new AccessibleControlAdapter() {
326 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getFocus(org.eclipse.swt.accessibility.AccessibleControlEvent)
329 public void getFocus(AccessibleControlEvent e
) {
330 if (fFocusedWidget
== -1) {
331 e
.childID
= ACC
.CHILDID_SELF
;
333 e
.childID
= fFocusedWidget
;
339 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getRole(org.eclipse.swt.accessibility.AccessibleControlEvent)
342 public void getRole(AccessibleControlEvent e
) {
344 case ACC
.CHILDID_SELF
:
345 e
.detail
= ACC
.ROLE_CLIENT_AREA
;
348 e
.detail
= ACC
.ROLE_TOOLTIP
;
351 e
.detail
= ACC
.ROLE_LABEL
;
360 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getState(org.eclipse.swt.accessibility.AccessibleControlEvent)
363 public void getState(AccessibleControlEvent e
) {
364 e
.detail
= ACC
.STATE_FOCUSABLE
;
365 if (e
.childID
== ACC
.CHILDID_SELF
) {
366 e
.detail
|= ACC
.STATE_FOCUSED
;
368 e
.detail
|= ACC
.STATE_SELECTABLE
;
369 if (e
.childID
== fFocusedWidget
) {
370 e
.detail
|= ACC
.STATE_FOCUSED
| ACC
.STATE_SELECTED
| ACC
.STATE_CHECKED
;
376 fInsertionCartet
= new Caret((Canvas
) getViewControl(), SWT
.NONE
);
377 fInsertionCartet
.setVisible(false);
379 fCollapaseCaretImg
= Activator
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
);
380 fArrowUpCaretImg
= Activator
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
);
382 fReorderList
= new ArrayList
<Lifeline
[]>();
383 getViewControl().addTraverseListener(new LocalTraverseListener());
385 addTraverseListener(new LocalTraverseListener());
387 getViewControl().addFocusListener(new FocusListener() {
391 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
394 public void focusGained(FocusEvent e
) {
395 SDViewPref
.getInstance().setNoFocusSelection(false);
396 fCtrlSelection
= false;
397 fShiftSelection
= false;
403 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
406 public void focusLost(FocusEvent e
) {
407 SDViewPref
.getInstance().setNoFocusSelection(true);
413 // ------------------------------------------------------------------------
415 // ------------------------------------------------------------------------
417 * Sets the time compression bar.
419 * @param bar The time compression bar to set
421 public void setTimeBar(TimeCompressionBar bar
) {
424 fTimeBar
.addTimeCompressionListener(this);
429 * Resize the contents to insure the frame fit into the view
431 * @param frame the frame which will be drawn in the view
433 public void resizeContents(Frame frame
) {
434 int width
= Math
.round((frame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
435 int height
= Math
.round((frame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
436 resizeContents(width
, height
);
440 * The frame to render (the sequence diagram)
442 * @param theFrame the frame to display
443 * @param resetPosition boolean
445 public void setFrame(Frame theFrame
, boolean resetPosition
) {
446 fReorderList
.clear();
447 fSelectedNodeList
.clear();
448 fSelProvider
.setSelection(new StructuredSelection());
451 setContentsPos(0, 0);
452 resizeContents(fFrame
);
455 // prepare the old overview to be reused
456 if (fOverView
!= null) {
460 resizeContents(fFrame
);
464 * Returns the current Frame (the sequence diagram container)
468 public Frame
getFrame() {
473 * Returns the selection provider for the current sequence diagram
475 * @return the selection provider
477 public ISelectionProvider
getSelectionProvider() {
482 * Returns a list of selected graph nodes.
484 * @return a list of selected graph nodes.
486 public List
<GraphNode
> getSelection() {
487 return fSelectedNodeList
;
491 * Adds a graph node to the selected nodes list.
493 * @param node A graph node
495 public void addSelection(GraphNode node
) {
499 fSelectedNodeList
.add(node
);
500 node
.setSelected(true);
501 fCurrentGraphNode
= node
;
502 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
503 fSelProvider
.setSelection(selection
);
507 * Adds a list of node to the selected nodes list.
509 * @param list of graph nodes
511 public void addSelection(List
<GraphNode
> list
) {
512 // selectedNodeList.addAll(list);
513 for (int i
= 0; i
< list
.size(); i
++) {
514 if (!fSelectedNodeList
.contains(list
.get(i
))) {
515 fSelectedNodeList
.add(list
.get(i
));
516 list
.get(i
).setSelected(true);
519 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
520 fSelProvider
.setSelection(selection
);
524 * Removes a node from the selected nodes list.
526 * @param node to remove
528 public void removeSelection(GraphNode node
) {
529 fSelectedNodeList
.remove(node
);
530 node
.setSelected(false);
531 node
.setFocused(false);
532 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
533 fSelProvider
.setSelection(selection
);
537 * Removes a list of graph nodes from the selected nodes list.
539 * @param list of nodes to remove.
541 public void removeSelection(List
<GraphNode
> list
) {
542 fSelectedNodeList
.removeAll(list
);
543 for (int i
= 0; i
< list
.size(); i
++) {
544 list
.get(i
).setSelected(false);
545 list
.get(i
).setFocused(false);
547 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
548 fSelProvider
.setSelection(selection
);
552 * Clear the list of GraphNodes which must be drawn selected.
554 public void clearSelection() {
555 for (int i
= 0; i
< fSelectedNodeList
.size(); i
++) {
556 fSelectedNodeList
.get(i
).setSelected(false);
557 fSelectedNodeList
.get(i
).setFocused(false);
559 fCurrentGraphNode
= null;
560 fSelectedNodeList
.clear();
561 fSelProvider
.setSelection(new StructuredSelection());
567 * @param viewSite The view part to set
569 public void setSite(ViewPart viewSite
) {
571 fSite
.getSite().setSelectionProvider(fSelProvider
);
572 IContextService service
= (IContextService
) fSite
.getSite().getWorkbenchWindow().getService(IContextService
.class);
573 service
.activateContext("org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"); //$NON-NLS-1$
574 service
.activateContext(IContextIds
.CONTEXT_ID_WINDOW
);
578 * Returns the GraphNode overView the mouse if any
580 * @return the current graph node
582 public GraphNode
getMouseOverNode() {
583 return fCurrentGraphNode
;
587 * Sets the zoom in mode.
590 * The mode value to set.
592 public void setZoomInMode(boolean value
) {
594 setZoomOutMode(false);
600 * Sets the zoom out mode.
603 * The mode value to set.
605 public void setZoomOutMode(boolean value
) {
607 setZoomInMode(false);
609 fZoomOutMode
= value
;
613 * Moves the Sequence diagram to ensure the given node is visible and draw it selected
615 * @param node the GraphNode to move to
617 public void moveTo(GraphNode node
) {
627 * Moves the Sequence diagram to ensure the given node is visible
629 * @param node the GraphNode to move to
631 public void ensureVisible(GraphNode node
) {
635 int x
= Math
.round(node
.getX() * fZoomValue
);
636 int y
= Math
.round(node
.getY() * fZoomValue
);
637 int width
= Math
.round(node
.getWidth() * fZoomValue
);
638 int height
= Math
.round(node
.getHeight() * fZoomValue
);
639 if ((node
instanceof BaseMessage
) && (height
== 0)) {
640 int header
= Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
* 2 + Metrics
.getLifelineHeaderFontHeigth();
641 height
= -Math
.round((Metrics
.getMessagesSpacing() + header
) * fZoomValue
);
642 y
= y
+ Math
.round(Metrics
.SYNC_INTERNAL_MESSAGE_HEIGHT
* fZoomValue
);
644 if (node
instanceof BasicExecutionOccurrence
) {
648 if (node
instanceof Lifeline
) {
650 height
= getVisibleHeight();
652 ensureVisible(x
, y
, width
, height
, SWT
.CENTER
, true);
657 * Returns the current zoom factor.
658 * @return the current zoom factor.
660 public float getZoomFactor() {
665 * Returns teh printer reference.
667 * @return the printer reference
669 public Printer
getPrinter() {
674 * Returns whether the widget is used for printing or not.
676 * @return whether the widget is used for printing or not
678 public boolean isPrinting() {
683 * Gets the overview image.
685 * @param rect Rectangle to include overview.
686 * @return the overview image
688 public Image
getOverview(Rectangle rect
) {
689 float oldzoom
= fZoomValue
;
690 if ((fOverView
!= null) && ((rect
.width
!= fOverView
.getBounds().width
) || (rect
.height
!= fOverView
.getBounds().height
))) {
694 if (fOverView
== null) {
695 int backX
= getContentsX();
696 int backY
= getContentsY();
697 setContentsPos(0, 0);
698 fOverView
= new Image(getDisplay(), rect
.width
, rect
.height
);
699 GC gcim
= new GC(fOverView
);
700 NGC context
= new NGC(this, gcim
);
701 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
702 fFrame
.draw(context
);
703 setContentsPos(backX
, backY
);
707 fZoomValue
= oldzoom
;
712 * Resets the zoom factor.
714 public void resetZoomFactor() {
715 int currentX
= Math
.round(getContentsX() / fZoomValue
);
716 int currentY
= Math
.round(getContentsY() / fZoomValue
);
718 if (fTimeBar
!= null && !fTimeBar
.isDisposed()) {
719 fTimeBar
.setZoom(fZoomValue
);
723 setContentsPos(currentX
, currentY
);
727 * Enable or disable the lifeline reodering using Drag and Drop
729 * @param mode - true to enable false otherwise
731 public void setReorderMode(boolean mode
) {
736 * Return the lifelines reorder sequence (using Drag and Drop) if the the reorder mode is turn on. Each ArryList
737 * element is of type Lifeline[2] with Lifeline[0] inserted before Lifeline[1] in the diagram
739 * @return - the re-odered sequence
741 public List
<Lifeline
[]> getLifelineReoderList() {
746 * Sets the focus on given graph node (current node).
749 * The graph node to focus on.
751 public void setFocus(GraphNode node
) {
755 if (fCurrentGraphNode
!= null) {
756 fCurrentGraphNode
.setFocused(false);
758 fCurrentGraphNode
= node
;
759 node
.setFocused(true);
765 * Returns the graph node focused on.
767 * @return the current graph node
769 public GraphNode
getFocusNode() {
770 return fCurrentGraphNode
;
774 * Method to traverse right.
776 public void traverseRight() {
777 Object selectedNode
= getFocusNode();
778 if (selectedNode
== null) {
781 GraphNode node
= null;
782 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
783 node
= fFrame
.getCalledMessage((BaseMessage
) selectedNode
);
785 if (selectedNode
instanceof BasicExecutionOccurrence
) {
786 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
788 if ((node
== null) && (selectedNode
instanceof Lifeline
)) {
789 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
790 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
< fFrame
.lifeLinesCount() - 1)) {
791 node
= fFrame
.getLifeline(i
+ 1);
803 * Method to traverse left.
805 public void traverseLeft() {
806 Object selectedNode
= getFocusNode();
807 GraphNode node
= null;
808 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
809 node
= fFrame
.getCallerMessage((BaseMessage
) selectedNode
);
811 if (selectedNode
instanceof BasicExecutionOccurrence
) {
812 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
815 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
816 selectedNode
= ((BaseMessage
) selectedNode
).getEndLifeline();
818 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
819 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
> 0)) {
820 node
= fFrame
.getLifeline(i
- 1);
824 if ((fFrame
.lifeLinesCount() > 0) && (node
== null)) {
825 node
= fFrame
.getLifeline(0);
835 * Method to traverse up.
837 public void traverseUp() {
838 Object selectedNode
= getFocusNode();
839 if (selectedNode
== null) {
842 GraphNode node
= null;
843 if (selectedNode
instanceof BaseMessage
) {
844 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
845 } else if (selectedNode
instanceof Lifeline
) {
846 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
847 if (!(node
instanceof Lifeline
)) {
850 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
851 node
= fFrame
.getPrevExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
853 node
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
856 if ((node
== null) && (selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
857 node
= ((BaseMessage
) selectedNode
).getStartLifeline();
867 * Method to traverse down.
869 public void traverseDown() {
870 Object selectedNode
= getFocusNode();
871 if (selectedNode
== null) {
875 if (selectedNode
instanceof BaseMessage
) {
876 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
877 } else if (selectedNode
instanceof Lifeline
) {
878 // node = frame.getNextLifelineMessage((Lifeline)selectedNode,null);
879 node
= fFrame
.getFirstExecution((Lifeline
) selectedNode
);
880 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
881 node
= fFrame
.getNextExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
893 * Method to traverse home.
895 public void traverseHome() {
896 Object selectedNode
= getFocusNode();
897 if (selectedNode
== null) {
900 GraphNode node
= null;
902 if (selectedNode
instanceof BaseMessage
) {
903 if (((BaseMessage
) selectedNode
).getStartLifeline() != null) {
904 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
906 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getEndLifeline(), null);
908 } else if (selectedNode
instanceof Lifeline
) {
909 node
= fFrame
.getNextLifelineMessage((Lifeline
) selectedNode
, null);
910 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
911 node
= fFrame
.getFirstExecution(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
913 if (fFrame
.lifeLinesCount() > 0) {
914 Lifeline lifeline
= fFrame
.getLifeline(0);
915 node
= fFrame
.getNextLifelineMessage(lifeline
, null);
926 * Method to traverse to the end.
928 public void traverseEnd() {
929 Object selectedNode
= getFocusNode();
930 if (selectedNode
== null) {
934 if (selectedNode
instanceof BaseMessage
) {
935 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
936 } else if (selectedNode
instanceof Lifeline
) {
937 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
938 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
939 node
= fFrame
.getLastExecOccurrence(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
941 if (fFrame
.lifeLinesCount() > 0) {
942 Lifeline lifeline
= fFrame
.getLifeline(0);
943 node
= fFrame
.getPrevLifelineMessage(lifeline
, null);
956 * Method to print UI.
958 * @param sdPrintDialog the sequence diagram printer dialog.
960 public void printUI(SDPrintDialogUI sdPrintDialog
) {
961 PrinterData data
= sdPrintDialog
.getPrinterData();
963 if ((data
== null) || (fFrame
== null)) {
967 fPrinter
= new Printer(data
);
969 String jobName
= MessageFormat
.format(SDMessages
._116
, new Object
[] { String
.valueOf(fSite
.getContentDescription()), String
.valueOf(fFrame
.getName()) });
970 fPrinter
.startJob(jobName
);
972 GC gc
= new GC(fPrinter
);
973 // Frame.setUserPref(SDViewPref.getInstance());
975 float lastZoom
= fZoomValue
;
977 Rectangle area
= getClientArea();
981 NGC context
= new NGC(this, gcim
);
983 // Set the metrics to use for lifeline text and message text
984 // using the Graphical Context
985 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
986 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
987 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
988 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
989 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
991 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS
));
992 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS_RET
));
993 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS
));
994 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS_RET
));
996 int messageFontHeight
= 0;
997 if (syncMessFontH
> syncMessRetFontH
) {
998 messageFontHeight
= syncMessFontH
;
1000 messageFontHeight
= syncMessRetFontH
;
1002 if (messageFontHeight
< asyncMessFontH
) {
1003 messageFontHeight
= asyncMessFontH
;
1005 if (messageFontHeight
< asyncMessRetFontH
) {
1006 messageFontHeight
= asyncMessRetFontH
;
1008 Metrics
.setMessageFontHeight(messageFontHeight
);
1009 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1011 int width
= Math
.round((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1012 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1013 if (width
< area
.width
) {
1016 if (height
< area
.height
) {
1017 height
= area
.height
;
1019 resizeContents(width
, height
);
1021 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1022 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1023 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1024 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1025 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1026 gcim
.setLineWidth(1);
1028 fPrinter
.startPage();
1029 fZoomValue
= lastZoom
;
1031 int restoreX
= getContentsX();
1032 int restoreY
= getContentsY();
1034 float zh
= sdPrintDialog
.getStepY() * sdPrintDialog
.getZoomFactor();
1035 float zw
= sdPrintDialog
.getStepX() * sdPrintDialog
.getZoomFactor();
1037 float zoomValueH
= fPrinter
.getClientArea().height
/ zh
;
1038 float zoomValueW
= fPrinter
.getClientArea().width
/ zw
;
1039 if (zoomValueH
> zoomValueW
) {
1040 fPrinterZoom
= zoomValueH
;
1042 fPrinterZoom
= zoomValueW
;
1045 if (sdPrintDialog
.printSelection()) {
1046 int[] pagesList
= sdPrintDialog
.getPageList();
1048 for (int pageIndex
= 0; pageIndex
< pagesList
.length
; pageIndex
++) {
1049 printPage(pagesList
[pageIndex
], sdPrintDialog
, context
);
1051 } else if (sdPrintDialog
.printAll()) {
1052 for (int pageIndex
= 1; pageIndex
<= sdPrintDialog
.maxNumOfPages(); pageIndex
++) {
1053 printPage(pageIndex
, sdPrintDialog
, context
);
1055 } else if (sdPrintDialog
.printCurrent()) {
1056 printPage(getContentsX(), getContentsY(), sdPrintDialog
, context
, 1);
1057 } else if (sdPrintDialog
.printRange()) {
1058 for (int pageIndex
= sdPrintDialog
.getFrom(); pageIndex
<= sdPrintDialog
.maxNumOfPages() && pageIndex
<= sdPrintDialog
.getTo(); pageIndex
++) {
1059 printPage(pageIndex
, sdPrintDialog
, context
);
1064 fIsPrinting
= false;
1069 fZoomValue
= lastZoom
;
1071 setContentsPos(restoreX
, restoreY
);
1077 public void print() {
1078 SDPrintDialog sdPrinter
= new SDPrintDialog(this.getShell(), this);
1080 if (sdPrinter
.open() != 0) {
1083 } catch (Exception e
) {
1084 Activator
.getDefault().logError("Error creating image", e
); //$NON-NLS-1$
1087 printUI(sdPrinter
.getDialogUI());
1091 * Method to print a page.
1093 * @param pageNum The page number
1094 * @param pd The sequence diagram print dialog
1095 * @param context The graphical context
1097 public void printPage(int pageNum
, SDPrintDialogUI pd
, NGC context
) {
1098 int j
= pageNum
/ pd
.getNbRow();
1099 int i
= pageNum
% pd
.getNbRow();
1109 i
= (int) (i
* pd
.getStepX());
1110 j
= (int) (j
* pd
.getStepY());
1112 printPage(i
, j
, pd
, context
, pageNum
);
1118 * Method to print page ranges.
1125 * The sequence diagram print dialog
1127 * The graphical context
1131 public void printPage(int i
, int j
, SDPrintDialogUI pd
, NGC context
, int pageNum
) {
1132 fIsPrinting
= false;
1133 int pageNumFontZoom
= fPrinter
.getClientArea().height
/ getVisibleHeight();
1136 setContentsPos(i
, j
);
1139 float lastZoom
= fZoomValue
;
1140 fZoomValue
= fPrinterZoom
* lastZoom
;
1142 fFrame
.draw(context
);
1144 fZoomValue
= pageNumFontZoom
;
1145 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1146 String currentPageNum
= String
.valueOf(pageNum
);
1147 int ii
= context
.textExtent(currentPageNum
);
1148 int jj
= context
.getCurrentFontHeight();
1149 // context.setBackground(ColorImpl.getSystemColor(SWT.COLOR_BLACK));
1150 // context.setForeground(ColorImpl.getSystemColor(SWT.COLOR_WHITE));
1151 fZoomValue
= fPrinterZoom
* lastZoom
;
1152 context
.drawText(currentPageNum
, Math
.round(fPrinterX
+ getVisibleWidth() / fPrinterZoom
- ii
/ fPrinterZoom
), Math
.round(fPrinterY
+ getVisibleHeight() / fPrinterZoom
- jj
/ fPrinterZoom
), false);
1153 fIsPrinting
= false;
1154 fZoomValue
= lastZoom
;
1158 * Sets the collapse provider.
1160 * @param provider The collapse provider to set
1162 protected void setCollapseProvider(ISDCollapseProvider provider
) {
1163 fCollapseProvider
= provider
;
1168 * Checks for focus of children.
1170 * @param children Control to check
1171 * @return true if child is on focus else false
1173 protected boolean checkFocusOnChilds(Control children
) {
1174 if (children
instanceof Composite
) {
1175 Control
[] child
= ((Composite
) children
).getChildren();
1176 for (int i
= 0; i
< child
.length
; i
++) {
1177 if (child
[i
].isFocusControl()) {
1180 checkFocusOnChilds(child
[i
]);
1187 * A post action for a tooltip (before displaying).
1189 * @param accessible true if accessible else false
1190 * @return the tooltip text.
1192 protected String
getPostfixForTooltip(boolean accessible
) {
1193 StringBuffer postfix
= new StringBuffer();
1194 // Determine if the tooltip must show the time difference between the current mouse position and
1195 // the last selected graphNode
1196 if ((fCurrentGraphNode
!= null) &&
1197 (fCurrentGraphNode
instanceof ITimeRange
) &&
1198 (fToolTipNode
instanceof ITimeRange
) &&
1199 (fCurrentGraphNode
!= fToolTipNode
) &&
1200 ((ITimeRange
) fToolTipNode
).hasTimeInfo() &&
1201 ((ITimeRange
) fCurrentGraphNode
).hasTimeInfo()) {
1202 postfix
.append(" -> "); //$NON-NLS-1$
1203 postfix
.append(fCurrentGraphNode
.getName());
1204 postfix
.append("\n"); //$NON-NLS-1$
1205 postfix
.append(SDMessages
._138
);
1206 postfix
.append(" "); //$NON-NLS-1$
1208 //double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
1209 ITmfTimestamp firstTime
= ((ITimeRange
) fCurrentGraphNode
).getEndTime();
1210 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1211 ITmfTimestamp delta
= lastTime
.getDelta(firstTime
);
1212 postfix
.append(delta
.toString());
1215 if ((fToolTipNode
instanceof ITimeRange
) && ((ITimeRange
) fToolTipNode
).hasTimeInfo()) {
1216 postfix
.append("\n"); //$NON-NLS-1$
1217 ITmfTimestamp firstTime
= ((ITimeRange
) fToolTipNode
).getStartTime();
1218 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1220 if (firstTime
!= null) {
1221 if (lastTime
!= null && firstTime
.compareTo(lastTime
, true) != 0) {
1222 postfix
.append("start: "); //$NON-NLS-1$
1223 postfix
.append(firstTime
.toString());
1224 postfix
.append("\n"); //$NON-NLS-1$
1225 postfix
.append("end: "); //$NON-NLS-1$
1226 postfix
.append(lastTime
.toString());
1227 postfix
.append("\n"); //$NON-NLS-1$
1229 postfix
.append(firstTime
.toString());
1232 else if (lastTime
!= null) {
1233 postfix
.append(lastTime
.toString());
1237 return postfix
.toString();
1241 * Sets a new focused widget.
1243 * @param newFocusShape A new focus shape.
1245 protected void setFocus(int newFocusShape
) {
1246 fFocusedWidget
= newFocusShape
;
1247 if (fFocusedWidget
== -1) {
1248 getViewControl().getAccessible().setFocus(ACC
.CHILDID_SELF
);
1250 getViewControl().getAccessible().setFocus(fFocusedWidget
);
1255 * Highlight the given GraphNode<br>
1256 * The GraphNode is then displayed using the system default selection color
1258 * @param node the GraphNode to highlight
1260 protected void performSelection(GraphNode node
) {
1261 if ((fCtrlSelection
) || (fShiftSelection
)) {
1263 if (fSelectedNodeList
.contains(node
)) {
1264 removeSelection(node
);
1280 * Returns a draw buffer image.
1282 * @return a Image containing the draw buffer.
1284 protected Image
getDrawBuffer() {
1287 Rectangle area
= getClientArea();
1288 Image dbuffer
= null;
1292 dbuffer
= new Image(getDisplay(), area
.width
, area
.height
);
1293 } catch (Exception e
) {
1294 Activator
.getDefault().logError("Error creating image", e
); //$NON-NLS-1$
1297 gcim
= new GC(dbuffer
);
1299 NGC context
= new NGC(this, gcim
);
1301 // Set the metrics to use for lifeline text and message text
1302 // using the Graphical Context
1303 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
1304 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
1305 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
1306 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
1307 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
1309 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS
));
1310 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS_RET
));
1311 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS
));
1312 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS_RET
));
1314 int messageFontHeight
= 0;
1315 if (syncMessFontH
> syncMessRetFontH
) {
1316 messageFontHeight
= syncMessFontH
;
1318 messageFontHeight
= syncMessRetFontH
;
1320 if (messageFontHeight
< asyncMessFontH
) {
1321 messageFontHeight
= asyncMessFontH
;
1323 if (messageFontHeight
< asyncMessRetFontH
) {
1324 messageFontHeight
= asyncMessRetFontH
;
1326 Metrics
.setMessageFontHeight(messageFontHeight
);
1327 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1329 int width
= (int) ((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1330 int height
= (int) ((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1332 resizeContents(width
, height
);
1334 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1335 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1336 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1337 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1338 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1339 gcim
.setLineWidth(1);
1341 fFrame
.draw(context
);
1342 if (fDragAndDrop
!= null) {
1343 Lifeline node
= fDragAndDrop
;
1344 boolean isSelected
= fDragAndDrop
.isSelected();
1345 boolean hasFocus
= fDragAndDrop
.hasFocus();
1346 node
.setSelected(false);
1347 node
.setFocused(false);
1348 node
.draw(context
, fDragX
, fDragY
);
1349 node
.setSelected(isSelected
);
1350 node
.setFocused(hasFocus
);
1359 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
1362 protected void keyPressedEvent(KeyEvent event
) {
1363 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1364 Control
[] child
= getParent().getChildren();
1365 for (int i
= 0; i
< child
.length
; i
++) {
1366 if ((child
[i
].isFocusControl())&& (!(child
[i
] instanceof ScrollView
))) {
1367 getViewControl().setFocus();
1374 if (event
.keyCode
== SWT
.CTRL
) {
1375 fCtrlSelection
= true;
1377 if (event
.keyCode
== SWT
.SHIFT
) {
1378 fShiftSelection
= true;
1379 fPrevList
= new ArrayList
<GraphNode
>();
1380 fPrevList
.addAll(getSelection());
1383 GraphNode prevNode
= getFocusNode();
1385 if (event
.keyCode
== SWT
.ARROW_RIGHT
) {
1389 if (event
.keyCode
== SWT
.ARROW_LEFT
) {
1393 if (event
.keyCode
== SWT
.ARROW_DOWN
) {
1397 if (event
.keyCode
== SWT
.ARROW_UP
) {
1401 if (event
.keyCode
== SWT
.HOME
) {
1405 if (event
.keyCode
== SWT
.END
) {
1409 if ((!fShiftSelection
) && (!fCtrlSelection
)) {
1410 fListStart
= fCurrentGraphNode
;
1413 if (event
.character
== ' ') {
1414 performSelection(fCurrentGraphNode
);
1415 if (!fShiftSelection
) {
1416 fListStart
= fCurrentGraphNode
;
1420 if ((fShiftSelection
) && (prevNode
!= getFocusNode())) {
1422 addSelection(fPrevList
);
1423 addSelection(fFrame
.getNodeList(fListStart
, getFocusNode()));
1424 if (getFocusNode() instanceof Lifeline
) {
1425 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1427 ensureVisible(getFocusNode());
1429 } else if ((!fCtrlSelection
) && (!fShiftSelection
)) {
1432 if (getFocusNode() != null) {
1433 addSelection(getFocusNode());
1435 if (getFocusNode() instanceof Lifeline
) {
1436 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1438 ensureVisible(getFocusNode());
1443 if (fCurrentGraphNode
!= null) {
1444 fCurrentGraphNode
.setFocused(true);
1448 if ((event
.character
== ' ') && ((fZoomInMode
) || (fZoomOutMode
))) {
1449 int cx
= Math
.round((getContentsX() + getVisibleWidth() / 2) / fZoomValue
);
1450 int cy
= Math
.round((getContentsY() + getVisibleHeight() / 2) / fZoomValue
);
1452 if (fZoomValue
< 64) {
1453 fZoomValue
= fZoomValue
* (float) 1.25;
1456 fZoomValue
= fZoomValue
/ (float) 1.25;
1458 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1459 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1460 setContentsPos(x
, y
);
1461 if (fTimeBar
!= null) {
1462 fTimeBar
.setZoom(fZoomValue
);
1464 // redraw also resize the scrollView content
1471 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
1474 protected void keyReleasedEvent(KeyEvent event
) {
1476 if (event
.keyCode
== SWT
.CTRL
) {
1477 fCtrlSelection
= false;
1479 if (event
.keyCode
== SWT
.SHIFT
) {
1480 fShiftSelection
= false;
1482 super.keyReleasedEvent(event
);
1488 * @see org.eclipse.swt.widgets.Control#isFocusControl()
1491 public boolean isFocusControl() {
1492 Control
[] child
= getChildren();
1493 for (int i
= 0; i
< child
.length
; i
++) {
1494 if (child
[i
].isFocusControl()) {
1497 checkFocusOnChilds(child
[i
]);
1504 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#setContentsPos(int, int)
1507 public boolean setContentsPos(int x
, int y
) {
1517 if (fFrame
== null) {
1520 if (localX
+ getVisibleWidth() > getContentsWidth()) {
1521 localX
= getContentsWidth() - getVisibleWidth();
1523 if (localY
+ getVisibleHeight() > getContentsHeight()) {
1524 localY
= getContentsHeight() - getVisibleHeight();
1526 int x1
= Math
.round(localX
/ fZoomValue
);
1527 int y2
= Math
.round(localY
/ fZoomValue
);
1528 int width
= Math
.round(getVisibleWidth() / fZoomValue
);
1529 int height
= Math
.round(getVisibleHeight() / fZoomValue
);
1530 fFrame
.updateIndex(x1
, y2
, width
, height
);
1532 if (fInsertionCartet
!= null && fInsertionCartet
.isVisible()) {
1533 fInsertionCartet
.setVisible(false);
1536 return super.setContentsPos(localX
, localY
);
1541 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
1544 protected void contentsMouseHover(MouseEvent event
) {
1545 GraphNode graphNode
= null;
1546 if (fFrame
!= null) {
1547 int x
= Math
.round(event
.x
/ fZoomValue
);
1548 int y
= Math
.round(event
.y
/ fZoomValue
);
1549 graphNode
= fFrame
.getNodeAt(x
, y
);
1550 if ((graphNode
!= null) && (SDViewPref
.getInstance().tooltipEnabled())) {
1551 fToolTipNode
= graphNode
;
1552 String postfix
= getPostfixForTooltip(true);
1553 if (graphNode
instanceof Lifeline
) {
1554 Lifeline lifeline
= (Lifeline
) graphNode
;
1555 fToolTip
.showToolTip(lifeline
.getToolTipText() + postfix
);
1558 fToolTip
.showToolTip(graphNode
.getName() + postfix
);
1562 fToolTip
.hideToolTip();
1569 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
1572 protected void contentsMouseMoveEvent(MouseEvent e
) {
1573 fScrollToolTip
.hideToolTip();
1574 fToolTip
.hideToolTip();
1575 // super.contentsMouseMoveEvent(e);
1576 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1577 Control
[] child
= getParent().getChildren();
1578 for (int i
= 0; i
< child
.length
; i
++) {
1579 if ((child
[i
].isFocusControl()) && (!(child
[i
] instanceof ScrollView
))) {
1580 getViewControl().setFocus();
1587 if (((e
.stateMask
& SWT
.BUTTON_MASK
) != 0) && ((fDragAndDrop
!= null) || fIsDragAndDrop
) && (fReorderMode
|| fCollapseProvider
!= null)) {
1588 fIsDragAndDrop
= false;
1589 if (fCurrentGraphNode
instanceof Lifeline
) {
1590 fDragAndDrop
= (Lifeline
) fCurrentGraphNode
;
1592 if (fDragAndDrop
!= null) {
1595 if (e
.x
> getContentsX() + getVisibleWidth()) {
1596 dx
= e
.x
- (getContentsX() + getVisibleWidth());
1597 } else if (e
.x
< getContentsX()) {
1598 dx
= -getContentsX() + e
.x
;
1600 if (e
.y
> getContentsY() + getVisibleHeight()) {
1601 dy
= e
.y
- (getContentsY() + getVisibleHeight());
1602 } else if (e
.y
< getContentsY()) {
1603 dy
= -getContentsY() + e
.y
;
1607 if (dx
!= 0 || dy
!= 0) {
1608 if (fLocalAutoScroll
== null) {
1609 if (fLocalAutoScrollTimer
== null) {
1610 fLocalAutoScrollTimer
= new Timer(true);
1612 fLocalAutoScroll
= new AutoScroll(this, dx
, dy
);
1613 fLocalAutoScrollTimer
.schedule(fLocalAutoScroll
, 0, 75);
1615 fLocalAutoScroll
.fDeltaX
= dx
;
1616 fLocalAutoScroll
.fDeltaY
= dy
;
1618 } else if (fLocalAutoScroll
!= null) {
1619 fLocalAutoScroll
.cancel();
1620 fLocalAutoScroll
= null;
1622 fDragX
= Math
.round(e
.x
/ fZoomValue
);
1623 fDragY
= Math
.round(e
.y
/ fZoomValue
);
1625 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1626 if ((node
!= null) && (node
!= fDragAndDrop
)) {
1629 int height
= Metrics
.getLifelineHeaderFontHeigth() + 2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
;
1630 int hMargin
= Metrics
.LIFELINE_VT_MAGIN
/ 4;
1631 int x
= node
.getX();
1632 int width
= node
.getWidth();
1633 if (fFrame
.getVisibleAreaY() < node
.getY() + node
.getHeight() - height
- hMargin
) {
1634 y
= contentsToViewY(Math
.round((node
.getY() + node
.getHeight()) * fZoomValue
));
1636 y
= Math
.round(height
* fZoomValue
);
1639 if (fFrame
.getVisibleAreaY() < contentsToViewY(node
.getY() - hMargin
)) {
1640 y1
= contentsToViewY(Math
.round((node
.getY() - hMargin
) * fZoomValue
));
1642 y1
= Math
.round(height
* fZoomValue
);
1645 int rx
= Math
.round(x
* fZoomValue
);
1647 fInsertionCartet
.setVisible(true);
1648 if ((fInsertionCartet
.getImage() != null) && (!fInsertionCartet
.getImage().isDisposed())) {
1649 fInsertionCartet
.getImage().dispose();
1651 if (rx
<= e
.x
&& Math
.round(rx
+ (width
* fZoomValue
)) >= e
.x
) {
1652 if (fCollapseProvider
!= null) {
1653 ImageData data
= fCollapaseCaretImg
.getImageData();
1654 data
= data
.scaledTo(Math
.round(fCollapaseCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fCollapaseCaretImg
.getBounds().height
* fZoomValue
));
1655 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1656 fInsertionCartet
.setImage(fCurrentCaretImage
);
1657 fInsertionCartet
.setLocation(contentsToViewX(rx
+ Math
.round((width
/ (float) 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y
);
1659 } else if (fReorderMode
) {
1661 if (node
.getIndex() > 1 && fFrame
.getLifeline(node
.getIndex() - 2) == fDragAndDrop
) {
1664 ImageData data
= fArrowUpCaretImg
.getImageData();
1665 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1666 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1667 fInsertionCartet
.setImage(fCurrentCaretImage
);
1668 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
- Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y1
);
1670 if (node
.getIndex() < fFrame
.lifeLinesCount() && fFrame
.getLifeline(node
.getIndex()) == fDragAndDrop
) {
1673 ImageData data
= fArrowUpCaretImg
.getImageData();
1674 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1675 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1676 fInsertionCartet
.setImage(fCurrentCaretImage
);
1677 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
+ width
+ Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2 + 1, y1
);
1681 fInsertionCartet
.setVisible(false);
1685 super.contentsMouseMoveEvent(e
);
1691 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
1694 protected void contentsMouseUpEvent(MouseEvent event
) {
1695 // Just in case the diagram highlight a time compression region
1696 // this region need to be released when clicking everywhere
1697 fInsertionCartet
.setVisible(false);
1698 if (fDragAndDrop
!= null) {
1699 if ((fOverView
!= null) && (!fOverView
.isDisposed())) {
1700 fOverView
.dispose();
1703 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1705 int rx
= Math
.round(node
.getX() * fZoomValue
);
1706 if (rx
<= event
.x
&& Math
.round(rx
+ (node
.getWidth() * fZoomValue
)) >= event
.x
) {
1707 if ((fCollapseProvider
!= null) && (fDragAndDrop
!= node
)) {
1708 fCollapseProvider
.collapseTwoLifelines(fDragAndDrop
, node
);
1710 } else if (rx
< event
.x
) {
1711 fFrame
.insertLifelineAfter(fDragAndDrop
, node
);
1712 if (node
.getIndex() < fFrame
.lifeLinesCount()) {
1713 Lifeline temp
[] = { fDragAndDrop
, fFrame
.getLifeline(node
.getIndex()) };
1714 fReorderList
.add(temp
);
1716 Lifeline temp
[] = { fDragAndDrop
, null };
1717 fReorderList
.add(temp
);
1720 fFrame
.insertLifelineBefore(fDragAndDrop
, node
);
1721 Lifeline temp
[] = { fDragAndDrop
, node
};
1722 fReorderList
.add(temp
);
1726 fDragAndDrop
= null;
1728 if (fFrame
== null) {
1731 fFrame
.resetTimeCompression();
1733 // reset auto scroll if it's engaged
1734 if (fLocalAutoScroll
!= null) {
1735 fLocalAutoScroll
.cancel();
1736 fLocalAutoScroll
= null;
1738 super.contentsMouseUpEvent(event
);
1743 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseDownEvent(org.eclipse.swt.events.MouseEvent)
1746 protected void contentsMouseDownEvent(MouseEvent event
) {
1747 if (fCurrentGraphNode
!= null) {
1748 fCurrentGraphNode
.setFocused(false);
1751 // Just in case the diagram highlight a time compression region
1752 // this region need to be released when clicking everywhere
1753 if (fFrame
== null) {
1757 fFrame
.resetTimeCompression();
1759 if ((event
.stateMask
& SWT
.CTRL
) != 0) {
1760 fCtrlSelection
= true;
1762 fCtrlSelection
= false;
1765 if (((fZoomInMode
) || (fZoomOutMode
)) && (event
.button
== 1)) {
1766 int cx
= Math
.round(event
.x
/ fZoomValue
);
1767 int cy
= Math
.round(event
.y
/ fZoomValue
);
1769 if (fZoomValue
< 64) {
1770 fZoomValue
= fZoomValue
* (float) 1.25;
1773 fZoomValue
= fZoomValue
/ (float) 1.25;
1775 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1776 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1777 setContentsPos(x
, y
);
1778 if (fTimeBar
!= null) {
1779 fTimeBar
.setZoom(fZoomValue
);
1781 // redraw also resize the scrollView content
1783 } else {// if (event.button ==1)
1784 GraphNode node
= null;
1785 int x
= Math
.round(event
.x
/ fZoomValue
);
1786 int y
= Math
.round(event
.y
/ fZoomValue
);
1787 node
= fFrame
.getNodeAt(x
, y
);
1789 if ((event
.button
== 1) || ((node
!= null) && !node
.isSelected())) {
1790 if (!fShiftSelection
) {
1793 if (fShiftSelection
) {
1795 addSelection(fFrame
.getNodeList(fListStart
, node
));
1797 performSelection(node
);
1799 fCurrentGraphNode
= node
;
1801 node
.setFocused(true);
1806 if (fDragAndDrop
== null) {
1807 super.contentsMouseDownEvent(event
);
1809 fIsDragAndDrop
= (event
.button
== 1);
1814 * TimerTask for auto scroll feature.
1816 protected static class AutoScroll
extends TimerTask
{
1826 * Field sequence diagram reference.
1828 public SDWidget fSdWidget
;
1831 * Constructor for AutoScroll.
1832 * @param sv sequence diagram widget reference
1836 public AutoScroll(SDWidget sv
, int dx
, int dy
) {
1844 * @see java.util.TimerTask#run()
1848 Display
.getDefault().asyncExec(new Runnable() {
1851 if (fSdWidget
.isDisposed()) {
1854 fSdWidget
.fDragX
+= fDeltaX
;
1855 fSdWidget
.fDragY
+= fDeltaY
;
1856 fSdWidget
.scrollBy(fDeltaX
, fDeltaY
);
1864 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
1867 protected void drawContents(GC gc
, int clipx
, int clipy
, int clipw
, int cliph
) {
1868 if (fFrame
== null) {
1869 gc
.setBackground(getDisplay().getSystemColor(SWT
.COLOR_WHITE
));
1870 gc
.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
1874 // Frame.setUserPref(SDViewPref.getInstance());
1875 SDViewPref
.getInstance();
1877 Rectangle area
= getClientArea();
1878 Image dbuffer
= getDrawBuffer();
1879 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1882 gc
.drawImage(dbuffer
, 0, 0, area
.width
, area
.height
, 0, 0, area
.width
, area
.height
);
1883 } catch (Exception e
) {
1884 Activator
.getDefault().logError("Error drawin content", e
); //$NON-NLS-1$
1887 setHScrollBarIncrement(Math
.round(SDViewPref
.getInstance().getLifelineWidth() / (float) 2 * fZoomValue
));
1888 setVScrollBarIncrement(Math
.round(Metrics
.getMessagesSpacing() * fZoomValue
));
1889 if ((fTimeBar
!= null) && (fFrame
.hasTimeInfo())) {
1890 fTimeBar
.resizeContents(9, height
+ getHorizontalBarHeight());
1891 fTimeBar
.setContentsPos(getContentsX(), getContentsY());
1895 float xRatio
= getContentsWidth() / (float) getVisibleWidth();
1896 float yRatio
= getContentsHeight() / (float) getVisibleHeight();
1897 if (yRatio
> xRatio
) {
1898 setOverviewSize((int) (getVisibleHeight() * 0.75));
1900 setOverviewSize((int) (getVisibleWidth() * 0.75));
1906 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
1909 public void widgetDefaultSelected(SelectionEvent event
) {
1914 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
1917 public void widgetSelected(SelectionEvent event
) {
1918 if (event
.widget
== fZoomIn
) {
1919 fZoomValue
= fZoomValue
* 2;
1920 } else if (event
.widget
== fZoomOut
) {
1921 fZoomValue
= fZoomValue
/ 2;
1927 * Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply button
1930 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
1933 public void propertyChange(PropertyChangeEvent e
) {
1934 if (fFrame
!= null && !isDisposed()) {
1935 fFrame
.resetTimeCompression();
1937 if (e
.getProperty().equals("PREFOK")) //$NON-NLS-1$
1939 // Prepare the overview to be reused for the new
1940 // settings (especially the colors)
1941 if (fOverView
!= null) {
1942 fOverView
.dispose();
1951 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
1954 public void widgetDisposed(DisposeEvent e
) {
1955 if (fOverView
!= null) {
1956 fOverView
.dispose();
1958 super.removeDisposeListener(this);
1959 if ((fCurrentCaretImage
!= null) && (!fCurrentCaretImage
.isDisposed())) {
1960 fCurrentCaretImage
.dispose();
1962 if ((fArrowUpCaretImg
!= null) && (!fArrowUpCaretImg
.isDisposed())) {
1963 fArrowUpCaretImg
.dispose();
1965 if ((fCollapaseCaretImg
!= null) && (!fCollapaseCaretImg
.isDisposed())) {
1966 fCollapaseCaretImg
.dispose();
1968 SDViewPref
.getInstance().removePropertyChangeListener(this);
1969 LoadersManager lm
= LoadersManager
.getInstance();
1970 if (fSite
instanceof SDView
) {
1971 ((SDView
) fSite
).resetProviders();
1973 lm
.resetLoader(((SDView
) fSite
).getViewSite().getId());
1980 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawOverview(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle)
1983 protected void drawOverview(GC gc
, Rectangle r
) {
1984 float oldzoom
= fZoomValue
;
1985 if (getContentsWidth() > getContentsHeight()) {
1986 fZoomValue
= (float) r
.width
/ (float) getContentsWidth() * oldzoom
;
1988 fZoomValue
= (float) r
.height
/ (float) getContentsHeight() * oldzoom
;
1990 if ((fOverView
!= null) && ((r
.width
!= fOverView
.getBounds().width
) || (r
.height
!= fOverView
.getBounds().height
))) {
1991 fOverView
.dispose();
1994 if (fOverView
== null) {
1995 int backX
= getContentsX();
1996 int backY
= getContentsY();
1997 setContentsPos(0, 0);
1998 fOverView
= new Image(getDisplay(), r
.width
, r
.height
);
1999 GC gcim
= new GC(fOverView
);
2000 NGC context
= new NGC(this, gcim
);
2001 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
2002 fFrame
.draw(context
);
2003 setContentsPos(backX
, backY
);
2007 if ((fOverView
!= null) && (r
.width
== fOverView
.getBounds().width
) && (r
.height
== fOverView
.getBounds().height
)) {
2008 gc
.drawImage(fOverView
, 0, 0, r
.width
, r
.height
, 0, 0, r
.width
, r
.height
);
2011 fZoomValue
= oldzoom
;
2013 super.drawOverview(gc
, r
);
2018 * @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)
2021 public void deltaSelected(Lifeline lifeline
, int startEvent
, int nbEvent
, IColor color
) {
2022 fFrame
.highlightTimeCompression(lifeline
, startEvent
, nbEvent
, color
);
2023 ensureVisible(lifeline
);
2024 int y1
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * startEvent
;
2025 int y2
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * (startEvent
+ nbEvent
);
2026 ensureVisible(lifeline
.getX(), y1
- (Metrics
.getLifelineHeaderFontHeigth() + +2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
), lifeline
.getWidth(), y2
- y1
+ 3, SWT
.CENTER
| SWT
.VERTICAL
, true);
2033 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleWidth()
2036 public int getVisibleWidth() {
2038 return fPrinter
.getClientArea().width
;
2040 return super.getVisibleWidth();
2045 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleHeight()
2048 public int getVisibleHeight() {
2050 return fPrinter
.getClientArea().height
;
2052 return super.getVisibleHeight();
2057 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewX(int)
2060 public int contentsToViewX(int x
) {
2062 int v
= Math
.round(fPrinterX
* fPrinterZoom
);
2065 return x
- getContentsX();
2070 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewY(int)
2073 public int contentsToViewY(int y
) {
2075 int v
= Math
.round(fPrinterY
* fPrinterZoom
);
2078 return y
- getContentsY();
2083 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsX()
2086 public int getContentsX() {
2088 return Math
.round(fPrinterX
* fPrinterZoom
);
2090 return super.getContentsX();
2096 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsY()
2099 public int getContentsY() {
2101 return Math
.round(fPrinterY
* fPrinterZoom
);
2103 return super.getContentsY();
2107 * Traverse Listener implementation.
2109 protected static class LocalTraverseListener
implements TraverseListener
{
2113 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
2116 public void keyTraversed(TraverseEvent e
) {
2117 if ((e
.detail
== SWT
.TRAVERSE_TAB_NEXT
) || (e
.detail
== SWT
.TRAVERSE_TAB_PREVIOUS
)) {