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
.core
.event
.TmfTimestamp
;
31 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BaseMessage
;
32 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BasicExecutionOccurrence
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Frame
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.ITimeRange
;
36 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Lifeline
;
37 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Metrics
;
38 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialog
;
39 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialogUI
;
40 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IColor
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDCollapseProvider
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.LoadersManager
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
44 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
45 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
46 import org
.eclipse
.swt
.SWT
;
47 import org
.eclipse
.swt
.accessibility
.ACC
;
48 import org
.eclipse
.swt
.accessibility
.Accessible
;
49 import org
.eclipse
.swt
.accessibility
.AccessibleAdapter
;
50 import org
.eclipse
.swt
.accessibility
.AccessibleControlAdapter
;
51 import org
.eclipse
.swt
.accessibility
.AccessibleControlEvent
;
52 import org
.eclipse
.swt
.accessibility
.AccessibleEvent
;
53 import org
.eclipse
.swt
.events
.DisposeEvent
;
54 import org
.eclipse
.swt
.events
.DisposeListener
;
55 import org
.eclipse
.swt
.events
.FocusEvent
;
56 import org
.eclipse
.swt
.events
.FocusListener
;
57 import org
.eclipse
.swt
.events
.KeyEvent
;
58 import org
.eclipse
.swt
.events
.MouseEvent
;
59 import org
.eclipse
.swt
.events
.SelectionEvent
;
60 import org
.eclipse
.swt
.events
.SelectionListener
;
61 import org
.eclipse
.swt
.events
.TraverseEvent
;
62 import org
.eclipse
.swt
.events
.TraverseListener
;
63 import org
.eclipse
.swt
.graphics
.GC
;
64 import org
.eclipse
.swt
.graphics
.Image
;
65 import org
.eclipse
.swt
.graphics
.ImageData
;
66 import org
.eclipse
.swt
.graphics
.Rectangle
;
67 import org
.eclipse
.swt
.printing
.Printer
;
68 import org
.eclipse
.swt
.printing
.PrinterData
;
69 import org
.eclipse
.swt
.widgets
.Canvas
;
70 import org
.eclipse
.swt
.widgets
.Caret
;
71 import org
.eclipse
.swt
.widgets
.Composite
;
72 import org
.eclipse
.swt
.widgets
.Control
;
73 import org
.eclipse
.swt
.widgets
.Display
;
74 import org
.eclipse
.swt
.widgets
.Event
;
75 import org
.eclipse
.swt
.widgets
.Listener
;
76 import org
.eclipse
.swt
.widgets
.MenuItem
;
77 import org
.eclipse
.ui
.contexts
.IContextService
;
78 import org
.eclipse
.ui
.part
.ViewPart
;
82 * This class implements sequence diagram widget used in the sequence diagram view.
88 public class SDWidget
extends ScrollView
implements SelectionListener
,
89 IPropertyChangeListener
, DisposeListener
, ITimeCompressionListener
{
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
96 * The frame to display in the sequence diagram widget.
98 protected Frame fFrame
;
100 * The overview image to display.
102 protected Image fOverView
= null;
104 * The zoom in menu item.
106 protected MenuItem fZoomIn
= null;
108 * The zoom out menu item.
110 protected MenuItem fZoomOut
= null;
112 * The sequence diagram selection provider.
114 protected SDWidgetSelectionProvider fSelProvider
= null;
116 * The current zoom value.
118 public float fZoomValue
= 1;
120 * The current zoomInMode (true for zoom in).
122 protected boolean fZoomInMode
= false;
124 * The current zoomOutMode (true for zoom out).
126 protected boolean fZoomOutMode
= false;
128 * The current list of selected graph nodes.
130 protected List
<GraphNode
> fSelectedNodeList
= null;
132 * Flag whether ctrl button is selected or not.
134 protected boolean fCtrlSelection
= false;
136 * A reference to the view site.
138 protected ViewPart fSite
= null;
140 * The current graph node (the last selected one).
142 public GraphNode fCurrentGraphNode
= null;
144 * The first graph node in list (multiple selection).
146 public GraphNode fListStart
= null;
148 * The previous graph node (multiple selection).
150 public List
<GraphNode
> fPrevList
= null;
152 * The time compression bar.
154 protected TimeCompressionBar fTimeBar
= null;
156 * The current diagram tool tip.
158 protected DiagramToolTip fToolTip
= null;
160 * The accessible object reference of view control.
162 protected Accessible fAccessible
= null;
164 * The current node for the tooltip to display.
166 protected GraphNode fToolTipNode
;
168 * The life line to drag and drop.
170 protected Lifeline fDragAndDrop
= null;
172 * The number of focused widgets.
174 protected int fFocusedWidget
= -1;
178 protected float fPrinterZoom
= 0;
180 * Y coordinate for printer.
182 protected int fPrinterY
= 0;
184 * X coordinate for printer.
186 protected int fPrinterX
= 0;
188 * Flag whether drag and drop is enabled or not.
190 protected boolean fIsDragAndDrop
= false;
192 * The x coordinate for drag.
194 protected int fDragX
= 0;
196 * The y coordinate for drag.
198 protected int fDragY
= 0;
202 protected boolean fReorderMode
= false;
204 * The collapse caret image.
206 protected Image fCollapaseCaretImg
= null;
208 * The arrow up caret image.
210 protected Image fArrowUpCaretImg
= null;
212 * The current caret image.
214 protected Image fCurrentCaretImage
= null;
216 * A sequence diagramm collapse provider (for collapsing graph nodes)
218 protected ISDCollapseProvider fCollapseProvider
= null;
220 * The insertion caret.
222 protected Caret fInsertionCartet
= null;
224 * The reorder list when in reorder mode.
226 protected List
<Lifeline
[]> fReorderList
= null;
228 * Flag to specify whether in printing mode or not.
230 protected boolean fIsPrinting
= false;
232 * A printer reference.
234 protected Printer fPrinter
= null;
236 * Flag whether shift was selected or not.
238 protected boolean fShiftSelection
= false;
240 * The scroll tooltip.
242 protected DiagramToolTip fScrollToolTip
= null;
244 * Timer for auto_scroll feature
246 protected AutoScroll fLocalAutoScroll
= null;
248 * TimerTask for auto_scroll feature !=null when auto scroll is running
250 protected Timer fLocalAutoScrollTimer
= null;
252 // ------------------------------------------------------------------------
254 // ------------------------------------------------------------------------
256 * Constructor for SDWidget.
257 * @param c The parent composite
260 public SDWidget(Composite c
, int s
) {
261 super(c
, s
| SWT
.NO_BACKGROUND
, true);
262 setOverviewEnabled(true);
263 fSelectedNodeList
= new ArrayList
<GraphNode
>();
264 fSelProvider
= new SDWidgetSelectionProvider();
265 SDViewPref
.getInstance().addPropertyChangeListener(this);
266 fToolTip
= new DiagramToolTip(getViewControl());
267 super.addDisposeListener(this);
269 fScrollToolTip
= new DiagramToolTip(c
);
270 getVerticalBar().addListener(SWT
.MouseUp
, new Listener() {
273 public void handleEvent(Event event
) {
274 fScrollToolTip
.hideToolTip();
278 fAccessible
= getViewControl().getAccessible();
280 fAccessible
.addAccessibleListener(new AccessibleAdapter() {
283 * @see org.eclipse.swt.accessibility.AccessibleAdapter#getName(org.eclipse.swt.accessibility.AccessibleEvent)
286 public void getName(AccessibleEvent e
) {
288 if (e
.childID
== 0) {
289 if (fToolTipNode
!= null) {
290 if (fToolTipNode
instanceof Lifeline
) {
291 Lifeline lifeline
= (Lifeline
) fToolTipNode
;
292 e
.result
= lifeline
.getToolTipText();
294 e
.result
= fToolTipNode
.getName() + getPostfixForTooltip(true);
298 if (getFocusNode() != null) {
299 if (getFocusNode() instanceof Lifeline
) {
300 e
.result
= MessageFormat
.format(SDMessages
._1
, new Object
[] { String
.valueOf(getFocusNode().getName()) });
302 if (getFocusNode() instanceof BaseMessage
) {
303 BaseMessage mes
= (BaseMessage
) getFocusNode();
304 if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() != null)) {
305 e
.result
= MessageFormat
.format(
307 new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()), String
.valueOf(mes
.getEndLifeline().getName()),
308 Integer
.valueOf(mes
.getEndOccurrence()) });
309 } else if ((mes
.getStartLifeline() == null) && (mes
.getEndLifeline() != null)) {
310 e
.result
= MessageFormat
.format(SDMessages
._4
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getEndLifeline().getName()), Integer
.valueOf(mes
.getEndOccurrence()) });
311 } else if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() == null)) {
312 e
.result
= MessageFormat
.format(SDMessages
._3
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()) });
314 } else if (getFocusNode() instanceof BasicExecutionOccurrence
) {
315 BasicExecutionOccurrence exec
= (BasicExecutionOccurrence
) getFocusNode();
316 e
.result
= MessageFormat
.format(SDMessages
._5
,
317 new Object
[] { String
.valueOf(exec
.getName()), String
.valueOf(exec
.getLifeline().getName()), Integer
.valueOf(exec
.getStartOccurrence()), Integer
.valueOf(exec
.getEndOccurrence()) });
325 fAccessible
.addAccessibleControlListener(new AccessibleControlAdapter() {
328 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getFocus(org.eclipse.swt.accessibility.AccessibleControlEvent)
331 public void getFocus(AccessibleControlEvent e
) {
332 if (fFocusedWidget
== -1) {
333 e
.childID
= ACC
.CHILDID_SELF
;
335 e
.childID
= fFocusedWidget
;
341 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getRole(org.eclipse.swt.accessibility.AccessibleControlEvent)
344 public void getRole(AccessibleControlEvent e
) {
346 case ACC
.CHILDID_SELF
:
347 e
.detail
= ACC
.ROLE_CLIENT_AREA
;
350 e
.detail
= ACC
.ROLE_TOOLTIP
;
353 e
.detail
= ACC
.ROLE_LABEL
;
362 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getState(org.eclipse.swt.accessibility.AccessibleControlEvent)
365 public void getState(AccessibleControlEvent e
) {
366 e
.detail
= ACC
.STATE_FOCUSABLE
;
367 if (e
.childID
== ACC
.CHILDID_SELF
) {
368 e
.detail
|= ACC
.STATE_FOCUSED
;
370 e
.detail
|= ACC
.STATE_SELECTABLE
;
371 if (e
.childID
== fFocusedWidget
) {
372 e
.detail
|= ACC
.STATE_FOCUSED
| ACC
.STATE_SELECTED
| ACC
.STATE_CHECKED
;
378 fInsertionCartet
= new Caret((Canvas
) getViewControl(), SWT
.NONE
);
379 fInsertionCartet
.setVisible(false);
381 fCollapaseCaretImg
= Activator
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
);
382 fArrowUpCaretImg
= Activator
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
);
384 fReorderList
= new ArrayList
<Lifeline
[]>();
385 getViewControl().addTraverseListener(new LocalTraverseListener());
387 addTraverseListener(new LocalTraverseListener());
389 getViewControl().addFocusListener(new FocusListener() {
393 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
396 public void focusGained(FocusEvent e
) {
397 SDViewPref
.getInstance().setNoFocusSelection(false);
398 fCtrlSelection
= false;
399 fShiftSelection
= false;
405 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
408 public void focusLost(FocusEvent e
) {
409 SDViewPref
.getInstance().setNoFocusSelection(true);
415 // ------------------------------------------------------------------------
417 // ------------------------------------------------------------------------
419 * Sets the time compression bar.
421 * @param bar The time compression bar to set
423 public void setTimeBar(TimeCompressionBar bar
) {
426 fTimeBar
.addTimeCompressionListener(this);
431 * Resize the contents to insure the frame fit into the view
433 * @param frame the frame which will be drawn in the view
435 public void resizeContents(Frame frame
) {
436 int width
= Math
.round((frame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
437 int height
= Math
.round((frame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
438 resizeContents(width
, height
);
442 * The frame to render (the sequence diagram)
444 * @param theFrame the frame to display
445 * @param resetPosition boolean
447 public void setFrame(Frame theFrame
, boolean resetPosition
) {
448 fReorderList
.clear();
449 fSelectedNodeList
.clear();
450 fSelProvider
.setSelection(new StructuredSelection());
453 setContentsPos(0, 0);
454 resizeContents(fFrame
);
457 // prepare the old overview to be reused
458 if (fOverView
!= null) {
462 resizeContents(fFrame
);
466 * Returns the current Frame (the sequence diagram container)
470 public Frame
getFrame() {
475 * Returns the selection provider for the current sequence diagram
477 * @return the selection provider
479 public ISelectionProvider
getSelectionProvider() {
484 * Returns a list of selected graph nodes.
486 * @return a list of selected graph nodes.
488 public List
<GraphNode
> getSelection() {
489 return fSelectedNodeList
;
493 * Adds a graph node to the selected nodes list.
495 * @param node A graph node
497 public void addSelection(GraphNode node
) {
501 fSelectedNodeList
.add(node
);
502 node
.setSelected(true);
503 fCurrentGraphNode
= node
;
504 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
505 fSelProvider
.setSelection(selection
);
509 * Adds a list of node to the selected nodes list.
511 * @param list of graph nodes
513 public void addSelection(List
<GraphNode
> list
) {
514 // selectedNodeList.addAll(list);
515 for (int i
= 0; i
< list
.size(); i
++) {
516 if (!fSelectedNodeList
.contains(list
.get(i
))) {
517 fSelectedNodeList
.add(list
.get(i
));
518 list
.get(i
).setSelected(true);
521 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
522 fSelProvider
.setSelection(selection
);
526 * Removes a node from the selected nodes list.
528 * @param node to remove
530 public void removeSelection(GraphNode node
) {
531 fSelectedNodeList
.remove(node
);
532 node
.setSelected(false);
533 node
.setFocused(false);
534 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
535 fSelProvider
.setSelection(selection
);
539 * Removes a list of graph nodes from the selected nodes list.
541 * @param list of nodes to remove.
543 public void removeSelection(List
<GraphNode
> list
) {
544 fSelectedNodeList
.removeAll(list
);
545 for (int i
= 0; i
< list
.size(); i
++) {
546 list
.get(i
).setSelected(false);
547 list
.get(i
).setFocused(false);
549 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
550 fSelProvider
.setSelection(selection
);
554 * Clear the list of GraphNodes which must be drawn selected.
556 public void clearSelection() {
557 for (int i
= 0; i
< fSelectedNodeList
.size(); i
++) {
558 fSelectedNodeList
.get(i
).setSelected(false);
559 fSelectedNodeList
.get(i
).setFocused(false);
561 fCurrentGraphNode
= null;
562 fSelectedNodeList
.clear();
563 fSelProvider
.setSelection(new StructuredSelection());
569 * @param viewSite The view part to set
571 public void setSite(ViewPart viewSite
) {
573 fSite
.getSite().setSelectionProvider(fSelProvider
);
574 IContextService service
= (IContextService
) fSite
.getSite().getWorkbenchWindow().getService(IContextService
.class);
575 service
.activateContext("org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"); //$NON-NLS-1$
576 service
.activateContext(IContextIds
.CONTEXT_ID_WINDOW
);
580 * Returns the GraphNode overView the mouse if any
582 * @return the current graph node
584 public GraphNode
getMouseOverNode() {
585 return fCurrentGraphNode
;
589 * Sets the zoom in mode.
592 * The mode value to set.
594 public void setZoomInMode(boolean value
) {
596 setZoomOutMode(false);
602 * Sets the zoom out mode.
605 * The mode value to set.
607 public void setZoomOutMode(boolean value
) {
609 setZoomInMode(false);
611 fZoomOutMode
= value
;
615 * Moves the Sequence diagram to ensure the given node is visible and draw it selected
617 * @param node the GraphNode to move to
619 public void moveTo(GraphNode node
) {
629 * Moves the Sequence diagram to ensure the given node is visible
631 * @param node the GraphNode to move to
633 public void ensureVisible(GraphNode node
) {
637 int x
= Math
.round(node
.getX() * fZoomValue
);
638 int y
= Math
.round(node
.getY() * fZoomValue
);
639 int width
= Math
.round(node
.getWidth() * fZoomValue
);
640 int height
= Math
.round(node
.getHeight() * fZoomValue
);
641 if ((node
instanceof BaseMessage
) && (height
== 0)) {
642 int header
= Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
* 2 + Metrics
.getLifelineHeaderFontHeigth();
643 height
= -Math
.round((Metrics
.getMessagesSpacing() + header
) * fZoomValue
);
644 y
= y
+ Math
.round(Metrics
.SYNC_INTERNAL_MESSAGE_HEIGHT
* fZoomValue
);
646 if (node
instanceof BasicExecutionOccurrence
) {
650 if (node
instanceof Lifeline
) {
652 height
= getVisibleHeight();
654 ensureVisible(x
, y
, width
, height
, SWT
.CENTER
, true);
659 * Returns the current zoom factor.
660 * @return the current zoom factor.
662 public float getZoomFactor() {
667 * Returns teh printer reference.
669 * @return the printer reference
671 public Printer
getPrinter() {
676 * Returns whether the widget is used for printing or not.
678 * @return whether the widget is used for printing or not
680 public boolean isPrinting() {
685 * Gets the overview image.
687 * @param rect Rectangle to include overview.
688 * @return the overview image
690 public Image
getOverview(Rectangle rect
) {
691 float oldzoom
= fZoomValue
;
692 if ((fOverView
!= null) && ((rect
.width
!= fOverView
.getBounds().width
) || (rect
.height
!= fOverView
.getBounds().height
))) {
696 if (fOverView
== null) {
697 int backX
= getContentsX();
698 int backY
= getContentsY();
699 setContentsPos(0, 0);
700 fOverView
= new Image(getDisplay(), rect
.width
, rect
.height
);
701 GC gcim
= new GC(fOverView
);
702 NGC context
= new NGC(this, gcim
);
703 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
704 fFrame
.draw(context
);
705 setContentsPos(backX
, backY
);
709 fZoomValue
= oldzoom
;
714 * Resets the zoom factor.
716 public void resetZoomFactor() {
717 int currentX
= Math
.round(getContentsX() / fZoomValue
);
718 int currentY
= Math
.round(getContentsY() / fZoomValue
);
720 if (fTimeBar
!= null && !fTimeBar
.isDisposed()) {
721 fTimeBar
.setZoom(fZoomValue
);
725 setContentsPos(currentX
, currentY
);
729 * Enable or disable the lifeline reodering using Drag and Drop
731 * @param mode - true to enable false otherwise
733 public void setReorderMode(boolean mode
) {
738 * Return the lifelines reorder sequence (using Drag and Drop) if the the reorder mode is turn on. Each ArryList
739 * element is of type Lifeline[2] with Lifeline[0] inserted before Lifeline[1] in the diagram
741 * @return - the re-odered sequence
743 public List
<Lifeline
[]> getLifelineReoderList() {
748 * Sets the focus on given graph node (current node).
751 * The graph node to focus on.
753 public void setFocus(GraphNode node
) {
757 if (fCurrentGraphNode
!= null) {
758 fCurrentGraphNode
.setFocused(false);
760 fCurrentGraphNode
= node
;
761 node
.setFocused(true);
767 * Returns the graph node focused on.
769 * @return the current graph node
771 public GraphNode
getFocusNode() {
772 return fCurrentGraphNode
;
776 * Method to traverse right.
778 public void traverseRight() {
779 Object selectedNode
= getFocusNode();
780 if (selectedNode
== null) {
783 GraphNode node
= null;
784 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
785 node
= fFrame
.getCalledMessage((BaseMessage
) selectedNode
);
787 if (selectedNode
instanceof BasicExecutionOccurrence
) {
788 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
790 if ((node
== null) && (selectedNode
instanceof Lifeline
)) {
791 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
792 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
< fFrame
.lifeLinesCount() - 1)) {
793 node
= fFrame
.getLifeline(i
+ 1);
805 * Method to traverse left.
807 public void traverseLeft() {
808 Object selectedNode
= getFocusNode();
809 GraphNode node
= null;
810 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
811 node
= fFrame
.getCallerMessage((BaseMessage
) selectedNode
);
813 if (selectedNode
instanceof BasicExecutionOccurrence
) {
814 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
817 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
818 selectedNode
= ((BaseMessage
) selectedNode
).getEndLifeline();
820 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
821 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
> 0)) {
822 node
= fFrame
.getLifeline(i
- 1);
826 if ((fFrame
.lifeLinesCount() > 0) && (node
== null)) {
827 node
= fFrame
.getLifeline(0);
837 * Method to traverse up.
839 public void traverseUp() {
840 Object selectedNode
= getFocusNode();
841 if (selectedNode
== null) {
844 GraphNode node
= null;
845 if (selectedNode
instanceof BaseMessage
) {
846 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
847 } else if (selectedNode
instanceof Lifeline
) {
848 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
849 if (!(node
instanceof Lifeline
)) {
852 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
853 node
= fFrame
.getPrevExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
855 node
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
858 if ((node
== null) && (selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
859 node
= ((BaseMessage
) selectedNode
).getStartLifeline();
869 * Method to traverse down.
871 public void traverseDown() {
872 Object selectedNode
= getFocusNode();
873 if (selectedNode
== null) {
877 if (selectedNode
instanceof BaseMessage
) {
878 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
879 } else if (selectedNode
instanceof Lifeline
) {
880 // node = frame.getNextLifelineMessage((Lifeline)selectedNode,null);
881 node
= fFrame
.getFirstExecution((Lifeline
) selectedNode
);
882 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
883 node
= fFrame
.getNextExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
895 * Method to traverse home.
897 public void traverseHome() {
898 Object selectedNode
= getFocusNode();
899 if (selectedNode
== null) {
902 GraphNode node
= null;
904 if (selectedNode
instanceof BaseMessage
) {
905 if (((BaseMessage
) selectedNode
).getStartLifeline() != null) {
906 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
908 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getEndLifeline(), null);
910 } else if (selectedNode
instanceof Lifeline
) {
911 node
= fFrame
.getNextLifelineMessage((Lifeline
) selectedNode
, null);
912 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
913 node
= fFrame
.getFirstExecution(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
915 if (fFrame
.lifeLinesCount() > 0) {
916 Lifeline lifeline
= fFrame
.getLifeline(0);
917 node
= fFrame
.getNextLifelineMessage(lifeline
, null);
928 * Method to traverse to the end.
930 public void traverseEnd() {
931 Object selectedNode
= getFocusNode();
932 if (selectedNode
== null) {
936 if (selectedNode
instanceof BaseMessage
) {
937 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
938 } else if (selectedNode
instanceof Lifeline
) {
939 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
940 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
941 node
= fFrame
.getLastExecOccurrence(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
943 if (fFrame
.lifeLinesCount() > 0) {
944 Lifeline lifeline
= fFrame
.getLifeline(0);
945 node
= fFrame
.getPrevLifelineMessage(lifeline
, null);
958 * Method to print UI.
960 * @param sdPrintDialog the sequence diagram printer dialog.
962 public void printUI(SDPrintDialogUI sdPrintDialog
) {
963 PrinterData data
= sdPrintDialog
.getPrinterData();
965 if ((data
== null) || (fFrame
== null)) {
969 fPrinter
= new Printer(data
);
971 String jobName
= MessageFormat
.format(SDMessages
._116
, new Object
[] { String
.valueOf(fSite
.getContentDescription()), String
.valueOf(fFrame
.getName()) });
972 fPrinter
.startJob(jobName
);
974 GC gc
= new GC(fPrinter
);
975 // Frame.setUserPref(SDViewPref.getInstance());
977 float lastZoom
= fZoomValue
;
979 Rectangle area
= getClientArea();
983 NGC context
= new NGC(this, gcim
);
985 // Set the metrics to use for lifeline text and message text
986 // using the Graphical Context
987 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
988 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
989 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
990 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
991 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
993 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS
));
994 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS_RET
));
995 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS
));
996 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS_RET
));
998 int messageFontHeight
= 0;
999 if (syncMessFontH
> syncMessRetFontH
) {
1000 messageFontHeight
= syncMessFontH
;
1002 messageFontHeight
= syncMessRetFontH
;
1004 if (messageFontHeight
< asyncMessFontH
) {
1005 messageFontHeight
= asyncMessFontH
;
1007 if (messageFontHeight
< asyncMessRetFontH
) {
1008 messageFontHeight
= asyncMessRetFontH
;
1010 Metrics
.setMessageFontHeight(messageFontHeight
);
1011 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1013 int width
= Math
.round((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1014 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1015 if (width
< area
.width
) {
1018 if (height
< area
.height
) {
1019 height
= area
.height
;
1021 resizeContents(width
, height
);
1023 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1024 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1025 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1026 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1027 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1028 gcim
.setLineWidth(1);
1030 fPrinter
.startPage();
1031 fZoomValue
= lastZoom
;
1033 int restoreX
= getContentsX();
1034 int restoreY
= getContentsY();
1036 float zh
= sdPrintDialog
.getStepY() * sdPrintDialog
.getZoomFactor();
1037 float zw
= sdPrintDialog
.getStepX() * sdPrintDialog
.getZoomFactor();
1039 float zoomValueH
= fPrinter
.getClientArea().height
/ zh
;
1040 float zoomValueW
= fPrinter
.getClientArea().width
/ zw
;
1041 if (zoomValueH
> zoomValueW
) {
1042 fPrinterZoom
= zoomValueH
;
1044 fPrinterZoom
= zoomValueW
;
1047 if (sdPrintDialog
.printSelection()) {
1048 int[] pagesList
= sdPrintDialog
.getPageList();
1050 for (int pageIndex
= 0; pageIndex
< pagesList
.length
; pageIndex
++) {
1051 printPage(pagesList
[pageIndex
], sdPrintDialog
, context
);
1053 } else if (sdPrintDialog
.printAll()) {
1054 for (int pageIndex
= 1; pageIndex
<= sdPrintDialog
.maxNumOfPages(); pageIndex
++) {
1055 printPage(pageIndex
, sdPrintDialog
, context
);
1057 } else if (sdPrintDialog
.printCurrent()) {
1058 printPage(getContentsX(), getContentsY(), sdPrintDialog
, context
, 1);
1059 } else if (sdPrintDialog
.printRange()) {
1060 for (int pageIndex
= sdPrintDialog
.getFrom(); pageIndex
<= sdPrintDialog
.maxNumOfPages() && pageIndex
<= sdPrintDialog
.getTo(); pageIndex
++) {
1061 printPage(pageIndex
, sdPrintDialog
, context
);
1066 fIsPrinting
= false;
1071 fZoomValue
= lastZoom
;
1073 setContentsPos(restoreX
, restoreY
);
1079 public void print() {
1080 SDPrintDialog sdPrinter
= new SDPrintDialog(this.getShell(), this);
1082 if (sdPrinter
.open() != 0) {
1085 } catch (Exception e
) {
1086 Activator
.getDefault().logError("Error creating image", e
); //$NON-NLS-1$
1089 printUI(sdPrinter
.getDialogUI());
1093 * Method to print a page.
1095 * @param pageNum The page number
1096 * @param pd The sequence diagram print dialog
1097 * @param context The graphical context
1099 public void printPage(int pageNum
, SDPrintDialogUI pd
, NGC context
) {
1100 int j
= pageNum
/ pd
.getNbRow();
1101 int i
= pageNum
% pd
.getNbRow();
1111 i
= (int) (i
* pd
.getStepX());
1112 j
= (int) (j
* pd
.getStepY());
1114 printPage(i
, j
, pd
, context
, pageNum
);
1120 * Method to print page ranges.
1127 * The sequence diagram print dialog
1129 * The graphical context
1133 public void printPage(int i
, int j
, SDPrintDialogUI pd
, NGC context
, int pageNum
) {
1134 fIsPrinting
= false;
1135 int pageNumFontZoom
= fPrinter
.getClientArea().height
/ getVisibleHeight();
1138 setContentsPos(i
, j
);
1141 float lastZoom
= fZoomValue
;
1142 fZoomValue
= fPrinterZoom
* lastZoom
;
1144 fFrame
.draw(context
);
1146 fZoomValue
= pageNumFontZoom
;
1147 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1148 String currentPageNum
= String
.valueOf(pageNum
);
1149 int ii
= context
.textExtent(currentPageNum
);
1150 int jj
= context
.getCurrentFontHeight();
1151 // context.setBackground(ColorImpl.getSystemColor(SWT.COLOR_BLACK));
1152 // context.setForeground(ColorImpl.getSystemColor(SWT.COLOR_WHITE));
1153 fZoomValue
= fPrinterZoom
* lastZoom
;
1154 context
.drawText(currentPageNum
, Math
.round(fPrinterX
+ getVisibleWidth() / fPrinterZoom
- ii
/ fPrinterZoom
), Math
.round(fPrinterY
+ getVisibleHeight() / fPrinterZoom
- jj
/ fPrinterZoom
), false);
1155 fIsPrinting
= false;
1156 fZoomValue
= lastZoom
;
1160 * Sets the collapse provider.
1162 * @param provider The collapse provider to set
1164 protected void setCollapseProvider(ISDCollapseProvider provider
) {
1165 fCollapseProvider
= provider
;
1170 * Checks for focus of children.
1172 * @param children Control to check
1173 * @return true if child is on focus else false
1175 protected boolean checkFocusOnChilds(Control children
) {
1176 if (children
instanceof Composite
) {
1177 Control
[] child
= ((Composite
) children
).getChildren();
1178 for (int i
= 0; i
< child
.length
; i
++) {
1179 if (child
[i
].isFocusControl()) {
1182 checkFocusOnChilds(child
[i
]);
1189 * A post action for a tooltip (before displaying).
1191 * @param accessible true if accessible else false
1192 * @return the tooltip text.
1194 protected String
getPostfixForTooltip(boolean accessible
) {
1195 StringBuffer postfix
= new StringBuffer();
1196 // String postfix = "";//$NON-NLS-1$
1197 // Determine if the tooltip must show the time difference between the current mouse position and
1198 // the last selected graphNode
1199 if ((fCurrentGraphNode
!= null) &&
1200 (fCurrentGraphNode
instanceof ITimeRange
) &&
1201 (fToolTipNode
instanceof ITimeRange
) &&
1202 (fCurrentGraphNode
!= fToolTipNode
) &&
1203 ((ITimeRange
) fToolTipNode
).hasTimeInfo() &&
1204 ((ITimeRange
) fCurrentGraphNode
).hasTimeInfo()) {
1205 postfix
.append(" -> "); //$NON-NLS-1$
1206 postfix
.append(fCurrentGraphNode
.getName());
1207 postfix
.append("\n"); //$NON-NLS-1$
1208 postfix
.append(SDMessages
._138
);
1209 postfix
.append(" "); //$NON-NLS-1$
1211 // postfix = " -> " + fCurrentGraphNode.getName() + "\n" + SDMessages._138 + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1213 //double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
1214 ITmfTimestamp firstTime
= ((ITimeRange
) fCurrentGraphNode
).getEndTime();
1215 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1216 TmfTimestamp delta
= (TmfTimestamp
) lastTime
.getDelta(firstTime
);
1217 postfix
.append(delta
.toString());
1219 // postfix += delta.toString();
1221 if ((fToolTipNode
instanceof ITimeRange
) && ((ITimeRange
) fToolTipNode
).hasTimeInfo()) {
1222 postfix
.append("\n"); //$NON-NLS-1$
1223 // postfix = "\n";//$NON-NLS-1$
1224 ITmfTimestamp firstTime
= ((ITimeRange
) fToolTipNode
).getStartTime();
1225 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1227 if (firstTime
!= null) {
1228 if (lastTime
!= null && firstTime
.compareTo(lastTime
, true) != 0) {
1229 postfix
.append("start: "); //$NON-NLS-1$
1230 postfix
.append(firstTime
.toString());
1231 postfix
.append("\n"); //$NON-NLS-1$
1232 postfix
.append("end: "); //$NON-NLS-1$
1233 postfix
.append(lastTime
.toString());
1234 postfix
.append("\n"); //$NON-NLS-1$
1235 // postfix += "start: " + firstTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
1236 // postfix += "end: " + lastTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
1238 postfix
.append(firstTime
.toString());
1239 // postfix += firstTime.toString();
1242 else if (lastTime
!= null) {
1243 postfix
.append(lastTime
.toString());
1244 // postfix += lastTime.toString();
1248 return postfix
.toString();
1252 * Sets a new focused widget.
1254 * @param newFocusShape A new focus shape.
1256 protected void setFocus(int newFocusShape
) {
1257 fFocusedWidget
= newFocusShape
;
1258 if (fFocusedWidget
== -1) {
1259 getViewControl().getAccessible().setFocus(ACC
.CHILDID_SELF
);
1261 getViewControl().getAccessible().setFocus(fFocusedWidget
);
1266 * Highlight the given GraphNode<br>
1267 * The GraphNode is then displayed using the system default selection color
1269 * @param node the GraphNode to highlight
1271 protected void performSelection(GraphNode node
) {
1272 if ((fCtrlSelection
) || (fShiftSelection
)) {
1274 if (fSelectedNodeList
.contains(node
)) {
1275 removeSelection(node
);
1291 * Returns a draw buffer image.
1293 * @return a Image containing the draw buffer.
1295 protected Image
getDrawBuffer() {
1298 Rectangle area
= getClientArea();
1299 Image dbuffer
= null;
1303 dbuffer
= new Image(getDisplay(), area
.width
, area
.height
);
1304 } catch (Exception e
) {
1305 Activator
.getDefault().logError("Error creating image", e
); //$NON-NLS-1$
1308 gcim
= new GC(dbuffer
);
1310 NGC context
= new NGC(this, gcim
);
1312 // Set the metrics to use for lifeline text and message text
1313 // using the Graphical Context
1314 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
1315 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
)));
1316 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
1317 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
1318 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
1320 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS
));
1321 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_SYNC_MESS_RET
));
1322 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS
));
1323 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_ASYNC_MESS_RET
));
1325 int messageFontHeight
= 0;
1326 if (syncMessFontH
> syncMessRetFontH
) {
1327 messageFontHeight
= syncMessFontH
;
1329 messageFontHeight
= syncMessRetFontH
;
1331 if (messageFontHeight
< asyncMessFontH
) {
1332 messageFontHeight
= asyncMessFontH
;
1334 if (messageFontHeight
< asyncMessRetFontH
) {
1335 messageFontHeight
= asyncMessRetFontH
;
1337 Metrics
.setMessageFontHeight(messageFontHeight
);
1338 context
.setFont(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE
));
1340 int width
= (int) ((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1341 int height
= (int) ((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1343 resizeContents(width
, height
);
1345 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1346 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1347 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1348 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1349 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1350 gcim
.setLineWidth(1);
1352 fFrame
.draw(context
);
1353 if (fDragAndDrop
!= null) {
1354 Lifeline node
= fDragAndDrop
;
1355 boolean isSelected
= fDragAndDrop
.isSelected();
1356 boolean hasFocus
= fDragAndDrop
.hasFocus();
1357 node
.setSelected(false);
1358 node
.setFocused(false);
1359 node
.draw(context
, fDragX
, fDragY
);
1360 node
.setSelected(isSelected
);
1361 node
.setFocused(hasFocus
);
1370 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
1373 protected void keyPressedEvent(KeyEvent event
) {
1374 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1375 Control
[] child
= getParent().getChildren();
1376 for (int i
= 0; i
< child
.length
; i
++) {
1377 if ((child
[i
].isFocusControl())&& (!(child
[i
] instanceof ScrollView
))) {
1378 getViewControl().setFocus();
1385 if (event
.keyCode
== SWT
.CTRL
) {
1386 fCtrlSelection
= true;
1388 if (event
.keyCode
== SWT
.SHIFT
) {
1389 fShiftSelection
= true;
1390 fPrevList
= new ArrayList
<GraphNode
>();
1391 fPrevList
.addAll(getSelection());
1394 GraphNode prevNode
= getFocusNode();
1396 if (event
.keyCode
== SWT
.ARROW_RIGHT
) {
1400 if (event
.keyCode
== SWT
.ARROW_LEFT
) {
1404 if (event
.keyCode
== SWT
.ARROW_DOWN
) {
1408 if (event
.keyCode
== SWT
.ARROW_UP
) {
1412 if (event
.keyCode
== SWT
.HOME
) {
1416 if (event
.keyCode
== SWT
.END
) {
1420 if ((!fShiftSelection
) && (!fCtrlSelection
)) {
1421 fListStart
= fCurrentGraphNode
;
1424 if (event
.character
== ' ') {
1425 performSelection(fCurrentGraphNode
);
1426 if (!fShiftSelection
) {
1427 fListStart
= fCurrentGraphNode
;
1431 if ((fShiftSelection
) && (prevNode
!= getFocusNode())) {
1433 addSelection(fPrevList
);
1434 addSelection(fFrame
.getNodeList(fListStart
, getFocusNode()));
1435 if (getFocusNode() instanceof Lifeline
) {
1436 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1438 ensureVisible(getFocusNode());
1440 } else if ((!fCtrlSelection
) && (!fShiftSelection
)) {
1443 if (getFocusNode() != null) {
1444 addSelection(getFocusNode());
1446 if (getFocusNode() instanceof Lifeline
) {
1447 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1449 ensureVisible(getFocusNode());
1454 if (fCurrentGraphNode
!= null) {
1455 fCurrentGraphNode
.setFocused(true);
1459 if ((event
.character
== ' ') && ((fZoomInMode
) || (fZoomOutMode
))) {
1460 int cx
= Math
.round((getContentsX() + getVisibleWidth() / 2) / fZoomValue
);
1461 int cy
= Math
.round((getContentsY() + getVisibleHeight() / 2) / fZoomValue
);
1463 if (fZoomValue
< 64) {
1464 fZoomValue
= fZoomValue
* (float) 1.25;
1467 fZoomValue
= fZoomValue
/ (float) 1.25;
1469 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1470 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1471 setContentsPos(x
, y
);
1472 if (fTimeBar
!= null) {
1473 fTimeBar
.setZoom(fZoomValue
);
1475 // redraw also resize the scrollView content
1482 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
1485 protected void keyReleasedEvent(KeyEvent event
) {
1487 if (event
.keyCode
== SWT
.CTRL
) {
1488 fCtrlSelection
= false;
1490 if (event
.keyCode
== SWT
.SHIFT
) {
1491 fShiftSelection
= false;
1493 super.keyReleasedEvent(event
);
1499 * @see org.eclipse.swt.widgets.Control#isFocusControl()
1502 public boolean isFocusControl() {
1503 Control
[] child
= getChildren();
1504 for (int i
= 0; i
< child
.length
; i
++) {
1505 if (child
[i
].isFocusControl()) {
1508 checkFocusOnChilds(child
[i
]);
1515 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#setContentsPos(int, int)
1518 public boolean setContentsPos(int x
, int y
) {
1528 if (fFrame
== null) {
1531 if (localX
+ getVisibleWidth() > getContentsWidth()) {
1532 localX
= getContentsWidth() - getVisibleWidth();
1534 if (localY
+ getVisibleHeight() > getContentsHeight()) {
1535 localY
= getContentsHeight() - getVisibleHeight();
1537 int x1
= Math
.round(localX
/ fZoomValue
);
1538 int y2
= Math
.round(localY
/ fZoomValue
);
1539 int width
= Math
.round(getVisibleWidth() / fZoomValue
);
1540 int height
= Math
.round(getVisibleHeight() / fZoomValue
);
1541 fFrame
.updateIndex(x1
, y2
, width
, height
);
1543 if (fInsertionCartet
!= null && fInsertionCartet
.isVisible()) {
1544 fInsertionCartet
.setVisible(false);
1547 return super.setContentsPos(localX
, localY
);
1552 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
1555 protected void contentsMouseHover(MouseEvent event
) {
1556 GraphNode graphNode
= null;
1557 if (fFrame
!= null) {
1558 int x
= Math
.round(event
.x
/ fZoomValue
);
1559 int y
= Math
.round(event
.y
/ fZoomValue
);
1560 graphNode
= fFrame
.getNodeAt(x
, y
);
1561 if ((graphNode
!= null) && (SDViewPref
.getInstance().tooltipEnabled())) {
1562 fToolTipNode
= graphNode
;
1563 String postfix
= getPostfixForTooltip(true);
1564 if (graphNode
instanceof Lifeline
) {
1565 Lifeline lifeline
= (Lifeline
) graphNode
;
1566 fToolTip
.showToolTip(lifeline
.getToolTipText() + postfix
);
1569 fToolTip
.showToolTip(graphNode
.getName() + postfix
);
1573 fToolTip
.hideToolTip();
1580 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
1583 protected void contentsMouseMoveEvent(MouseEvent e
) {
1584 fScrollToolTip
.hideToolTip();
1585 fToolTip
.hideToolTip();
1586 // super.contentsMouseMoveEvent(e);
1587 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1588 Control
[] child
= getParent().getChildren();
1589 for (int i
= 0; i
< child
.length
; i
++) {
1590 if ((child
[i
].isFocusControl()) && (!(child
[i
] instanceof ScrollView
))) {
1591 getViewControl().setFocus();
1598 if (((e
.stateMask
& SWT
.BUTTON_MASK
) != 0) && ((fDragAndDrop
!= null) || fIsDragAndDrop
) && (fReorderMode
|| fCollapseProvider
!= null)) {
1599 fIsDragAndDrop
= false;
1600 if (fCurrentGraphNode
instanceof Lifeline
) {
1601 fDragAndDrop
= (Lifeline
) fCurrentGraphNode
;
1603 if (fDragAndDrop
!= null) {
1606 if (e
.x
> getContentsX() + getVisibleWidth()) {
1607 dx
= e
.x
- (getContentsX() + getVisibleWidth());
1608 } else if (e
.x
< getContentsX()) {
1609 dx
= -getContentsX() + e
.x
;
1611 if (e
.y
> getContentsY() + getVisibleHeight()) {
1612 dy
= e
.y
- (getContentsY() + getVisibleHeight());
1613 } else if (e
.y
< getContentsY()) {
1614 dy
= -getContentsY() + e
.y
;
1618 if (dx
!= 0 || dy
!= 0) {
1619 if (fLocalAutoScroll
== null) {
1620 if (fLocalAutoScrollTimer
== null) {
1621 fLocalAutoScrollTimer
= new Timer(true);
1623 fLocalAutoScroll
= new AutoScroll(this, dx
, dy
);
1624 fLocalAutoScrollTimer
.schedule(fLocalAutoScroll
, 0, 75);
1626 fLocalAutoScroll
.fDeltaX
= dx
;
1627 fLocalAutoScroll
.fDeltaY
= dy
;
1629 } else if (fLocalAutoScroll
!= null) {
1630 fLocalAutoScroll
.cancel();
1631 fLocalAutoScroll
= null;
1633 fDragX
= Math
.round(e
.x
/ fZoomValue
);
1634 fDragY
= Math
.round(e
.y
/ fZoomValue
);
1636 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1637 if ((node
!= null) && (node
!= fDragAndDrop
)) {
1640 int height
= Metrics
.getLifelineHeaderFontHeigth() + 2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
;
1641 int hMargin
= Metrics
.LIFELINE_VT_MAGIN
/ 4;
1642 int x
= node
.getX();
1643 int width
= node
.getWidth();
1644 if (fFrame
.getVisibleAreaY() < node
.getY() + node
.getHeight() - height
- hMargin
) {
1645 y
= contentsToViewY(Math
.round((node
.getY() + node
.getHeight()) * fZoomValue
));
1647 y
= Math
.round(height
* fZoomValue
);
1650 if (fFrame
.getVisibleAreaY() < contentsToViewY(node
.getY() - hMargin
)) {
1651 y1
= contentsToViewY(Math
.round((node
.getY() - hMargin
) * fZoomValue
));
1653 y1
= Math
.round(height
* fZoomValue
);
1656 int rx
= Math
.round(x
* fZoomValue
);
1658 fInsertionCartet
.setVisible(true);
1659 if ((fInsertionCartet
.getImage() != null) && (!fInsertionCartet
.getImage().isDisposed())) {
1660 fInsertionCartet
.getImage().dispose();
1662 if (rx
<= e
.x
&& Math
.round(rx
+ (width
* fZoomValue
)) >= e
.x
) {
1663 if (fCollapseProvider
!= null) {
1664 ImageData data
= fCollapaseCaretImg
.getImageData();
1665 data
= data
.scaledTo(Math
.round(fCollapaseCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fCollapaseCaretImg
.getBounds().height
* fZoomValue
));
1666 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1667 fInsertionCartet
.setImage(fCurrentCaretImage
);
1668 fInsertionCartet
.setLocation(contentsToViewX(rx
+ Math
.round((width
/ (float) 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y
);
1670 } else if (fReorderMode
) {
1672 if (node
.getIndex() > 1 && fFrame
.getLifeline(node
.getIndex() - 2) == fDragAndDrop
) {
1675 ImageData data
= fArrowUpCaretImg
.getImageData();
1676 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1677 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1678 fInsertionCartet
.setImage(fCurrentCaretImage
);
1679 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
- Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y1
);
1681 if (node
.getIndex() < fFrame
.lifeLinesCount() && fFrame
.getLifeline(node
.getIndex()) == fDragAndDrop
) {
1684 ImageData data
= fArrowUpCaretImg
.getImageData();
1685 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1686 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1687 fInsertionCartet
.setImage(fCurrentCaretImage
);
1688 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
+ width
+ Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2 + 1, y1
);
1692 fInsertionCartet
.setVisible(false);
1696 super.contentsMouseMoveEvent(e
);
1702 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
1705 protected void contentsMouseUpEvent(MouseEvent event
) {
1706 // Just in case the diagram highlight a time compression region
1707 // this region need to be released when clicking everywhere
1708 fInsertionCartet
.setVisible(false);
1709 if (fDragAndDrop
!= null) {
1710 if ((fOverView
!= null) && (!fOverView
.isDisposed())) {
1711 fOverView
.dispose();
1714 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1716 int rx
= Math
.round(node
.getX() * fZoomValue
);
1717 if (rx
<= event
.x
&& Math
.round(rx
+ (node
.getWidth() * fZoomValue
)) >= event
.x
) {
1718 if ((fCollapseProvider
!= null) && (fDragAndDrop
!= node
)) {
1719 fCollapseProvider
.collapseTwoLifelines(fDragAndDrop
, node
);
1721 } else if (rx
< event
.x
) {
1722 fFrame
.insertLifelineAfter(fDragAndDrop
, node
);
1723 if (node
.getIndex() < fFrame
.lifeLinesCount()) {
1724 Lifeline temp
[] = { fDragAndDrop
, fFrame
.getLifeline(node
.getIndex()) };
1725 fReorderList
.add(temp
);
1727 Lifeline temp
[] = { fDragAndDrop
, null };
1728 fReorderList
.add(temp
);
1731 fFrame
.insertLifelineBefore(fDragAndDrop
, node
);
1732 Lifeline temp
[] = { fDragAndDrop
, node
};
1733 fReorderList
.add(temp
);
1737 fDragAndDrop
= null;
1739 if (fFrame
== null) {
1742 fFrame
.resetTimeCompression();
1744 // reset auto scroll if it's engaged
1745 if (fLocalAutoScroll
!= null) {
1746 fLocalAutoScroll
.cancel();
1747 fLocalAutoScroll
= null;
1749 super.contentsMouseUpEvent(event
);
1754 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseDownEvent(org.eclipse.swt.events.MouseEvent)
1757 protected void contentsMouseDownEvent(MouseEvent event
) {
1758 if (fCurrentGraphNode
!= null) {
1759 fCurrentGraphNode
.setFocused(false);
1762 // Just in case the diagram highlight a time compression region
1763 // this region need to be released when clicking everywhere
1764 if (fFrame
== null) {
1768 fFrame
.resetTimeCompression();
1770 if ((event
.stateMask
& SWT
.CTRL
) != 0) {
1771 fCtrlSelection
= true;
1773 fCtrlSelection
= false;
1776 if (((fZoomInMode
) || (fZoomOutMode
)) && (event
.button
== 1)) {
1777 int cx
= Math
.round(event
.x
/ fZoomValue
);
1778 int cy
= Math
.round(event
.y
/ fZoomValue
);
1780 if (fZoomValue
< 64) {
1781 fZoomValue
= fZoomValue
* (float) 1.25;
1784 fZoomValue
= fZoomValue
/ (float) 1.25;
1786 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1787 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1788 setContentsPos(x
, y
);
1789 if (fTimeBar
!= null) {
1790 fTimeBar
.setZoom(fZoomValue
);
1792 // redraw also resize the scrollView content
1794 } else {// if (event.button ==1)
1795 GraphNode node
= null;
1796 int x
= Math
.round(event
.x
/ fZoomValue
);
1797 int y
= Math
.round(event
.y
/ fZoomValue
);
1798 node
= fFrame
.getNodeAt(x
, y
);
1800 if ((event
.button
== 1) || ((node
!= null) && !node
.isSelected())) {
1801 if (!fShiftSelection
) {
1804 if (fShiftSelection
) {
1806 addSelection(fFrame
.getNodeList(fListStart
, node
));
1808 performSelection(node
);
1810 fCurrentGraphNode
= node
;
1812 node
.setFocused(true);
1817 if (fDragAndDrop
== null) {
1818 super.contentsMouseDownEvent(event
);
1820 fIsDragAndDrop
= (event
.button
== 1);
1825 * TimerTask for auto scroll feature.
1827 protected static class AutoScroll
extends TimerTask
{
1837 * Field sequence diagram reference.
1839 public SDWidget fSdWidget
;
1842 * Constructor for AutoScroll.
1843 * @param sv sequence diagram widget reference
1847 public AutoScroll(SDWidget sv
, int dx
, int dy
) {
1855 * @see java.util.TimerTask#run()
1859 Display
.getDefault().asyncExec(new Runnable() {
1862 if (fSdWidget
.isDisposed()) {
1865 fSdWidget
.fDragX
+= fDeltaX
;
1866 fSdWidget
.fDragY
+= fDeltaY
;
1867 fSdWidget
.scrollBy(fDeltaX
, fDeltaY
);
1875 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
1878 protected void drawContents(GC gc
, int clipx
, int clipy
, int clipw
, int cliph
) {
1879 if (fFrame
== null) {
1880 gc
.setBackground(getDisplay().getSystemColor(SWT
.COLOR_WHITE
));
1881 gc
.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
1885 // Frame.setUserPref(SDViewPref.getInstance());
1886 SDViewPref
.getInstance();
1888 Rectangle area
= getClientArea();
1889 Image dbuffer
= getDrawBuffer();
1890 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1893 gc
.drawImage(dbuffer
, 0, 0, area
.width
, area
.height
, 0, 0, area
.width
, area
.height
);
1894 } catch (Exception e
) {
1895 Activator
.getDefault().logError("Error drawin content", e
); //$NON-NLS-1$
1898 setHScrollBarIncrement(Math
.round(SDViewPref
.getInstance().getLifelineWidth() / (float) 2 * fZoomValue
));
1899 setVScrollBarIncrement(Math
.round(Metrics
.getMessagesSpacing() * fZoomValue
));
1900 if ((fTimeBar
!= null) && (fFrame
.hasTimeInfo())) {
1901 fTimeBar
.resizeContents(9, height
+ getHorizontalBarHeight());
1902 fTimeBar
.setContentsPos(getContentsX(), getContentsY());
1906 float xRatio
= getContentsWidth() / (float) getVisibleWidth();
1907 float yRatio
= getContentsHeight() / (float) getVisibleHeight();
1908 if (yRatio
> xRatio
) {
1909 setOverviewSize((int) (getVisibleHeight() * 0.75));
1911 setOverviewSize((int) (getVisibleWidth() * 0.75));
1917 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
1920 public void widgetDefaultSelected(SelectionEvent event
) {
1925 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
1928 public void widgetSelected(SelectionEvent event
) {
1929 if (event
.widget
== fZoomIn
) {
1930 fZoomValue
= fZoomValue
* 2;
1931 } else if (event
.widget
== fZoomOut
) {
1932 fZoomValue
= fZoomValue
/ 2;
1938 * Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply button
1941 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
1944 public void propertyChange(PropertyChangeEvent e
) {
1945 if (fFrame
!= null && !isDisposed()) {
1946 fFrame
.resetTimeCompression();
1948 if (e
.getProperty().equals("PREFOK")) //$NON-NLS-1$
1950 // Prepare the overview to be reused for the new
1951 // settings (especially the colors)
1952 if (fOverView
!= null) {
1953 fOverView
.dispose();
1962 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
1965 public void widgetDisposed(DisposeEvent e
) {
1966 if (fOverView
!= null) {
1967 fOverView
.dispose();
1969 super.removeDisposeListener(this);
1970 if ((fCurrentCaretImage
!= null) && (!fCurrentCaretImage
.isDisposed())) {
1971 fCurrentCaretImage
.dispose();
1973 if ((fArrowUpCaretImg
!= null) && (!fArrowUpCaretImg
.isDisposed())) {
1974 fArrowUpCaretImg
.dispose();
1976 if ((fCollapaseCaretImg
!= null) && (!fCollapaseCaretImg
.isDisposed())) {
1977 fCollapaseCaretImg
.dispose();
1979 SDViewPref
.getInstance().removePropertyChangeListener(this);
1980 LoadersManager lm
= LoadersManager
.getInstance();
1981 if (fSite
instanceof SDView
) {
1982 ((SDView
) fSite
).resetProviders();
1984 lm
.resetLoader(((SDView
) fSite
).getViewSite().getId());
1991 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawOverview(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle)
1994 protected void drawOverview(GC gc
, Rectangle r
) {
1995 float oldzoom
= fZoomValue
;
1996 if (getContentsWidth() > getContentsHeight()) {
1997 fZoomValue
= (float) r
.width
/ (float) getContentsWidth() * oldzoom
;
1999 fZoomValue
= (float) r
.height
/ (float) getContentsHeight() * oldzoom
;
2001 if ((fOverView
!= null) && ((r
.width
!= fOverView
.getBounds().width
) || (r
.height
!= fOverView
.getBounds().height
))) {
2002 fOverView
.dispose();
2005 if (fOverView
== null) {
2006 int backX
= getContentsX();
2007 int backY
= getContentsY();
2008 setContentsPos(0, 0);
2009 fOverView
= new Image(getDisplay(), r
.width
, r
.height
);
2010 GC gcim
= new GC(fOverView
);
2011 NGC context
= new NGC(this, gcim
);
2012 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
2013 fFrame
.draw(context
);
2014 setContentsPos(backX
, backY
);
2018 if ((fOverView
!= null) && (r
.width
== fOverView
.getBounds().width
) && (r
.height
== fOverView
.getBounds().height
)) {
2019 gc
.drawImage(fOverView
, 0, 0, r
.width
, r
.height
, 0, 0, r
.width
, r
.height
);
2022 fZoomValue
= oldzoom
;
2024 super.drawOverview(gc
, r
);
2029 * @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)
2032 public void deltaSelected(Lifeline lifeline
, int startEvent
, int nbEvent
, IColor color
) {
2033 fFrame
.highlightTimeCompression(lifeline
, startEvent
, nbEvent
, color
);
2034 ensureVisible(lifeline
);
2035 int y1
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * startEvent
;
2036 int y2
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * (startEvent
+ nbEvent
);
2037 ensureVisible(lifeline
.getX(), y1
- (Metrics
.getLifelineHeaderFontHeigth() + +2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
), lifeline
.getWidth(), y2
- y1
+ 3, SWT
.CENTER
| SWT
.VERTICAL
, true);
2044 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleWidth()
2047 public int getVisibleWidth() {
2049 return fPrinter
.getClientArea().width
;
2051 return super.getVisibleWidth();
2056 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleHeight()
2059 public int getVisibleHeight() {
2061 return fPrinter
.getClientArea().height
;
2063 return super.getVisibleHeight();
2068 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewX(int)
2071 public int contentsToViewX(int x
) {
2073 int v
= Math
.round(fPrinterX
* fPrinterZoom
);
2076 return x
- getContentsX();
2081 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewY(int)
2084 public int contentsToViewY(int y
) {
2086 int v
= Math
.round(fPrinterY
* fPrinterZoom
);
2089 return y
- getContentsY();
2094 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsX()
2097 public int getContentsX() {
2099 return Math
.round(fPrinterX
* fPrinterZoom
);
2101 return super.getContentsX();
2107 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsY()
2110 public int getContentsY() {
2112 return Math
.round(fPrinterY
* fPrinterZoom
);
2114 return super.getContentsY();
2118 * Traverse Listener implementation.
2120 protected static class LocalTraverseListener
implements TraverseListener
{
2124 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
2127 public void keyTraversed(TraverseEvent e
) {
2128 if ((e
.detail
== SWT
.TRAVERSE_TAB_NEXT
) || (e
.detail
== SWT
.TRAVERSE_TAB_PREVIOUS
)) {