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 ((GraphNode
) 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 ((GraphNode
) list
.get(i
)).setSelected(false);
547 ((GraphNode
) 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 ((GraphNode
) fSelectedNodeList
.get(i
)).setSelected(false);
559 ((GraphNode
) 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(SDViewPref
.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(SDViewPref
.PREF_LIFELINE
)));
988 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(SDViewPref
.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(SDViewPref
.PREF_SYNC_MESS
));
994 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_SYNC_MESS_RET
));
995 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_ASYNC_MESS
));
996 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.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(SDViewPref
.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(SDViewPref
.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
]);
1190 * A post action for a tooltip (before displaying).
1192 * @param accessible true if accessible else false
1193 * @return the tooltip text.
1195 protected String
getPostfixForTooltip(boolean accessible
) {
1196 StringBuffer postfix
= new StringBuffer();
1197 // String postfix = "";//$NON-NLS-1$
1198 // Determine if the tooltip must show the time difference between the current mouse position and
1199 // the last selected graphNode
1200 if ((fCurrentGraphNode
!= null) &&
1201 (fCurrentGraphNode
instanceof ITimeRange
) &&
1202 (fToolTipNode
instanceof ITimeRange
) &&
1203 (fCurrentGraphNode
!= fToolTipNode
) &&
1204 ((ITimeRange
) fToolTipNode
).hasTimeInfo() &&
1205 ((ITimeRange
) fCurrentGraphNode
).hasTimeInfo()) {
1206 postfix
.append(" -> "); //$NON-NLS-1$
1207 postfix
.append(fCurrentGraphNode
.getName());
1208 postfix
.append("\n"); //$NON-NLS-1$
1209 postfix
.append(SDMessages
._138
);
1210 postfix
.append(" "); //$NON-NLS-1$
1212 // postfix = " -> " + fCurrentGraphNode.getName() + "\n" + SDMessages._138 + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1214 //double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
1215 ITmfTimestamp firstTime
= ((ITimeRange
) fCurrentGraphNode
).getEndTime();
1216 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1217 TmfTimestamp delta
= (TmfTimestamp
) lastTime
.getDelta(firstTime
);
1218 postfix
.append(delta
.toString());
1220 // postfix += delta.toString();
1222 if ((fToolTipNode
instanceof ITimeRange
) && ((ITimeRange
) fToolTipNode
).hasTimeInfo()) {
1223 postfix
.append("\n"); //$NON-NLS-1$
1224 // postfix = "\n";//$NON-NLS-1$
1225 ITmfTimestamp firstTime
= ((ITimeRange
) fToolTipNode
).getStartTime();
1226 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1228 if (firstTime
!= null) {
1229 if (lastTime
!= null && firstTime
.compareTo(lastTime
, true) != 0) {
1230 postfix
.append("start: "); //$NON-NLS-1$
1231 postfix
.append(firstTime
.toString());
1232 postfix
.append("\n"); //$NON-NLS-1$
1233 postfix
.append("end: "); //$NON-NLS-1$
1234 postfix
.append(lastTime
.toString());
1235 postfix
.append("\n"); //$NON-NLS-1$
1236 // postfix += "start: " + firstTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
1237 // postfix += "end: " + lastTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
1239 postfix
.append(firstTime
.toString());
1240 // postfix += firstTime.toString();
1243 else if (lastTime
!= null) {
1244 postfix
.append(lastTime
.toString());
1245 // postfix += lastTime.toString();
1249 return postfix
.toString();
1253 * Sets a new focused widget.
1255 * @param newFocusShape A new focus shape.
1257 protected void setFocus(int newFocusShape
) {
1258 fFocusedWidget
= newFocusShape
;
1259 if (fFocusedWidget
== -1) {
1260 getViewControl().getAccessible().setFocus(ACC
.CHILDID_SELF
);
1262 getViewControl().getAccessible().setFocus(fFocusedWidget
);
1267 * Highlight the given GraphNode<br>
1268 * The GraphNode is then displayed using the system default selection color
1270 * @param node the GraphNode to highlight
1272 protected void performSelection(GraphNode node
) {
1273 if ((fCtrlSelection
) || (fShiftSelection
)) {
1275 if (fSelectedNodeList
.contains(node
)) {
1276 removeSelection(node
);
1292 * Returns a draw buffer image.
1294 * @return a Image containing the draw buffer.
1296 protected Image
getDrawBuffer() {
1299 Rectangle area
= getClientArea();
1300 Image dbuffer
= null;
1304 dbuffer
= new Image(getDisplay(), area
.width
, area
.height
);
1305 } catch (Exception e
) {
1306 Activator
.getDefault().logError("Error creating image", e
); //$NON-NLS-1$
1309 gcim
= new GC(dbuffer
);
1311 NGC context
= new NGC(this, gcim
);
1313 // Set the metrics to use for lifeline text and message text
1314 // using the Graphical Context
1315 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
)));
1316 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
)));
1317 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
1318 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
1319 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
1321 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_SYNC_MESS
));
1322 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_SYNC_MESS_RET
));
1323 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_ASYNC_MESS
));
1324 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_ASYNC_MESS_RET
));
1326 int messageFontHeight
= 0;
1327 if (syncMessFontH
> syncMessRetFontH
) {
1328 messageFontHeight
= syncMessFontH
;
1330 messageFontHeight
= syncMessRetFontH
;
1332 if (messageFontHeight
< asyncMessFontH
) {
1333 messageFontHeight
= asyncMessFontH
;
1335 if (messageFontHeight
< asyncMessRetFontH
) {
1336 messageFontHeight
= asyncMessRetFontH
;
1338 Metrics
.setMessageFontHeight(messageFontHeight
);
1339 context
.setFont(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
));
1341 int width
= (int) ((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1342 int height
= (int) ((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1344 resizeContents(width
, height
);
1346 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1347 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1348 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1349 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1350 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1351 gcim
.setLineWidth(1);
1353 fFrame
.draw(context
);
1354 if (fDragAndDrop
!= null) {
1355 Lifeline node
= (Lifeline
) fDragAndDrop
;
1356 boolean isSelected
= fDragAndDrop
.isSelected();
1357 boolean hasFocus
= fDragAndDrop
.hasFocus();
1358 node
.setSelected(false);
1359 node
.setFocused(false);
1360 node
.draw(context
, fDragX
, fDragY
);
1361 node
.setSelected(isSelected
);
1362 node
.setFocused(hasFocus
);
1371 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
1374 protected void keyPressedEvent(KeyEvent event
) {
1375 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1376 Control
[] child
= getParent().getChildren();
1377 for (int i
= 0; i
< child
.length
; i
++) {
1378 if ((child
[i
].isFocusControl())&& (!(child
[i
] instanceof ScrollView
))) {
1379 getViewControl().setFocus();
1386 if (event
.keyCode
== SWT
.CTRL
) {
1387 fCtrlSelection
= true;
1389 if (event
.keyCode
== SWT
.SHIFT
) {
1390 fShiftSelection
= true;
1391 fPrevList
= new ArrayList
<GraphNode
>();
1392 fPrevList
.addAll(getSelection());
1395 GraphNode prevNode
= getFocusNode();
1397 if (event
.keyCode
== SWT
.ARROW_RIGHT
) {
1401 if (event
.keyCode
== SWT
.ARROW_LEFT
) {
1405 if (event
.keyCode
== SWT
.ARROW_DOWN
) {
1409 if (event
.keyCode
== SWT
.ARROW_UP
) {
1413 if (event
.keyCode
== SWT
.HOME
) {
1417 if (event
.keyCode
== SWT
.END
) {
1421 if ((!fShiftSelection
) && (!fCtrlSelection
)) {
1422 fListStart
= fCurrentGraphNode
;
1425 if (event
.character
== ' ') {
1426 performSelection(fCurrentGraphNode
);
1427 if (!fShiftSelection
) {
1428 fListStart
= fCurrentGraphNode
;
1432 if ((fShiftSelection
) && (prevNode
!= getFocusNode())) {
1434 addSelection(fPrevList
);
1435 addSelection(fFrame
.getNodeList(fListStart
, getFocusNode()));
1436 if (getFocusNode() instanceof Lifeline
) {
1437 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1439 ensureVisible(getFocusNode());
1441 } else if ((!fCtrlSelection
) && (!fShiftSelection
)) {
1444 if (getFocusNode() != null) {
1445 addSelection(getFocusNode());
1447 if (getFocusNode() instanceof Lifeline
) {
1448 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1450 ensureVisible(getFocusNode());
1455 if (fCurrentGraphNode
!= null) {
1456 fCurrentGraphNode
.setFocused(true);
1460 if ((event
.character
== ' ') && ((fZoomInMode
) || (fZoomOutMode
))) {
1461 int cx
= Math
.round((getContentsX() + getVisibleWidth() / 2) / fZoomValue
);
1462 int cy
= Math
.round((getContentsY() + getVisibleHeight() / 2) / fZoomValue
);
1464 if (fZoomValue
< 64) {
1465 fZoomValue
= fZoomValue
* (float) 1.25;
1468 fZoomValue
= fZoomValue
/ (float) 1.25;
1470 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1471 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1472 setContentsPos(x
, y
);
1473 if (fTimeBar
!= null) {
1474 fTimeBar
.setZoom(fZoomValue
);
1476 // redraw also resize the scrollView content
1483 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
1486 protected void keyReleasedEvent(KeyEvent event
) {
1488 if (event
.keyCode
== SWT
.CTRL
) {
1489 fCtrlSelection
= false;
1491 if (event
.keyCode
== SWT
.SHIFT
) {
1492 fShiftSelection
= false;
1494 super.keyReleasedEvent(event
);
1500 * @see org.eclipse.swt.widgets.Control#isFocusControl()
1503 public boolean isFocusControl() {
1504 Control
[] child
= getChildren();
1505 for (int i
= 0; i
< child
.length
; i
++) {
1506 if (child
[i
].isFocusControl()) {
1509 checkFocusOnChilds(child
[i
]);
1517 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#setContentsPos(int, int)
1520 public boolean setContentsPos(int x
, int y
) {
1530 if (fFrame
== null) {
1533 if (localX
+ getVisibleWidth() > getContentsWidth()) {
1534 localX
= getContentsWidth() - getVisibleWidth();
1536 if (localY
+ getVisibleHeight() > getContentsHeight()) {
1537 localY
= getContentsHeight() - getVisibleHeight();
1539 int x1
= Math
.round(localX
/ fZoomValue
);
1540 int y2
= Math
.round(localY
/ fZoomValue
);
1541 int width
= Math
.round(getVisibleWidth() / fZoomValue
);
1542 int height
= Math
.round(getVisibleHeight() / fZoomValue
);
1543 fFrame
.updateIndex(x1
, y2
, width
, height
);
1545 if (fInsertionCartet
!= null && fInsertionCartet
.isVisible()) {
1546 fInsertionCartet
.setVisible(false);
1549 return super.setContentsPos(localX
, localY
);
1554 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
1557 protected void contentsMouseHover(MouseEvent event
) {
1558 GraphNode graphNode
= null;
1559 if (fFrame
!= null) {
1560 int x
= Math
.round(event
.x
/ fZoomValue
);
1561 int y
= Math
.round(event
.y
/ fZoomValue
);
1562 graphNode
= fFrame
.getNodeAt(x
, y
);
1563 if ((graphNode
!= null) && (SDViewPref
.getInstance().tooltipEnabled())) {
1564 fToolTipNode
= graphNode
;
1565 String postfix
= getPostfixForTooltip(true);
1566 if (graphNode
instanceof Lifeline
) {
1567 Lifeline lifeline
= (Lifeline
) graphNode
;
1568 fToolTip
.showToolTip(lifeline
.getToolTipText() + postfix
);
1571 fToolTip
.showToolTip(graphNode
.getName() + postfix
);
1575 fToolTip
.hideToolTip();
1582 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
1585 protected void contentsMouseMoveEvent(MouseEvent e
) {
1586 fScrollToolTip
.hideToolTip();
1587 fToolTip
.hideToolTip();
1588 // super.contentsMouseMoveEvent(e);
1589 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1590 Control
[] child
= getParent().getChildren();
1591 for (int i
= 0; i
< child
.length
; i
++) {
1592 if ((child
[i
].isFocusControl()) && (!(child
[i
] instanceof ScrollView
))) {
1593 getViewControl().setFocus();
1600 if (((e
.stateMask
& SWT
.BUTTON_MASK
) != 0) && ((fDragAndDrop
!= null) || fIsDragAndDrop
) && (fReorderMode
|| fCollapseProvider
!= null)) {
1601 fIsDragAndDrop
= false;
1602 if (fCurrentGraphNode
instanceof Lifeline
) {
1603 fDragAndDrop
= (Lifeline
) fCurrentGraphNode
;
1605 if (fDragAndDrop
!= null) {
1608 if (e
.x
> getContentsX() + getVisibleWidth()) {
1609 dx
= e
.x
- (getContentsX() + getVisibleWidth());
1610 } else if (e
.x
< getContentsX()) {
1611 dx
= -getContentsX() + e
.x
;
1613 if (e
.y
> getContentsY() + getVisibleHeight()) {
1614 dy
= e
.y
- (getContentsY() + getVisibleHeight());
1615 } else if (e
.y
< getContentsY()) {
1616 dy
= -getContentsY() + e
.y
;
1620 if (dx
!= 0 || dy
!= 0) {
1621 if (fLocalAutoScroll
== null) {
1622 if (fLocalAutoScrollTimer
== null) {
1623 fLocalAutoScrollTimer
= new Timer(true);
1625 fLocalAutoScroll
= new AutoScroll(this, dx
, dy
);
1626 fLocalAutoScrollTimer
.schedule(fLocalAutoScroll
, 0, 75);
1628 fLocalAutoScroll
.fDeltaX
= dx
;
1629 fLocalAutoScroll
.fDeltaY
= dy
;
1631 } else if (fLocalAutoScroll
!= null) {
1632 fLocalAutoScroll
.cancel();
1633 fLocalAutoScroll
= null;
1635 fDragX
= Math
.round(e
.x
/ fZoomValue
);
1636 fDragY
= Math
.round(e
.y
/ fZoomValue
);
1638 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1639 if ((node
!= null) && (node
!= fDragAndDrop
)) {
1642 int height
= Metrics
.getLifelineHeaderFontHeigth() + 2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
;
1643 int hMargin
= Metrics
.LIFELINE_VT_MAGIN
/ 4;
1644 int x
= node
.getX();
1645 int width
= node
.getWidth();
1646 if (fFrame
.getVisibleAreaY() < node
.getY() + node
.getHeight() - height
- hMargin
) {
1647 y
= contentsToViewY(Math
.round((node
.getY() + node
.getHeight()) * fZoomValue
));
1649 y
= Math
.round(height
* fZoomValue
);
1652 if (fFrame
.getVisibleAreaY() < contentsToViewY(node
.getY() - hMargin
)) {
1653 y1
= contentsToViewY(Math
.round((node
.getY() - hMargin
) * fZoomValue
));
1655 y1
= Math
.round(height
* fZoomValue
);
1658 int rx
= Math
.round(x
* fZoomValue
);
1660 fInsertionCartet
.setVisible(true);
1661 if ((fInsertionCartet
.getImage() != null) && (!fInsertionCartet
.getImage().isDisposed())) {
1662 fInsertionCartet
.getImage().dispose();
1664 if (rx
<= e
.x
&& Math
.round(rx
+ (width
* fZoomValue
)) >= e
.x
) {
1665 if (fCollapseProvider
!= null) {
1666 ImageData data
= fCollapaseCaretImg
.getImageData();
1667 data
= data
.scaledTo(Math
.round(fCollapaseCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fCollapaseCaretImg
.getBounds().height
* fZoomValue
));
1668 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1669 fInsertionCartet
.setImage(fCurrentCaretImage
);
1670 fInsertionCartet
.setLocation(contentsToViewX(rx
+ Math
.round((width
/ (float) 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y
);
1672 } else if (fReorderMode
) {
1674 if (node
.getIndex() > 1 && fFrame
.getLifeline(node
.getIndex() - 2) == fDragAndDrop
) {
1677 ImageData data
= fArrowUpCaretImg
.getImageData();
1678 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1679 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1680 fInsertionCartet
.setImage(fCurrentCaretImage
);
1681 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
- Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y1
);
1683 if (node
.getIndex() < fFrame
.lifeLinesCount() && fFrame
.getLifeline(node
.getIndex()) == fDragAndDrop
) {
1686 ImageData data
= fArrowUpCaretImg
.getImageData();
1687 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1688 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1689 fInsertionCartet
.setImage(fCurrentCaretImage
);
1690 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
+ width
+ Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2 + 1, y1
);
1694 fInsertionCartet
.setVisible(false);
1698 super.contentsMouseMoveEvent(e
);
1704 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
1707 protected void contentsMouseUpEvent(MouseEvent event
) {
1708 // Just in case the diagram highlight a time compression region
1709 // this region need to be released when clicking everywhere
1710 fInsertionCartet
.setVisible(false);
1711 if (fDragAndDrop
!= null) {
1712 if ((fOverView
!= null) && (!fOverView
.isDisposed())) {
1713 fOverView
.dispose();
1716 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1718 int rx
= Math
.round(node
.getX() * fZoomValue
);
1719 if (rx
<= event
.x
&& Math
.round(rx
+ (node
.getWidth() * fZoomValue
)) >= event
.x
) {
1720 if ((fCollapseProvider
!= null) && (fDragAndDrop
!= node
)) {
1721 fCollapseProvider
.collapseTwoLifelines((Lifeline
) fDragAndDrop
, node
);
1723 } else if (rx
< event
.x
) {
1724 fFrame
.insertLifelineAfter((Lifeline
) fDragAndDrop
, node
);
1725 if (node
.getIndex() < fFrame
.lifeLinesCount()) {
1726 Lifeline temp
[] = { (Lifeline
) fDragAndDrop
, fFrame
.getLifeline(node
.getIndex()) };
1727 fReorderList
.add(temp
);
1729 Lifeline temp
[] = { (Lifeline
) fDragAndDrop
, null };
1730 fReorderList
.add(temp
);
1733 fFrame
.insertLifelineBefore((Lifeline
) fDragAndDrop
, node
);
1734 Lifeline temp
[] = { (Lifeline
) fDragAndDrop
, node
};
1735 fReorderList
.add(temp
);
1739 fDragAndDrop
= null;
1741 if (fFrame
== null) {
1744 fFrame
.resetTimeCompression();
1746 // reset auto scroll if it's engaged
1747 if (fLocalAutoScroll
!= null) {
1748 fLocalAutoScroll
.cancel();
1749 fLocalAutoScroll
= null;
1751 super.contentsMouseUpEvent(event
);
1756 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseDownEvent(org.eclipse.swt.events.MouseEvent)
1759 protected void contentsMouseDownEvent(MouseEvent event
) {
1760 if (fCurrentGraphNode
!= null) {
1761 fCurrentGraphNode
.setFocused(false);
1764 // Just in case the diagram highlight a time compression region
1765 // this region need to be released when clicking everywhere
1766 if (fFrame
== null) {
1770 fFrame
.resetTimeCompression();
1772 if ((event
.stateMask
& SWT
.CTRL
) != 0) {
1773 fCtrlSelection
= true;
1775 fCtrlSelection
= false;
1778 if (((fZoomInMode
) || (fZoomOutMode
)) && (event
.button
== 1)) {
1779 int cx
= Math
.round(event
.x
/ fZoomValue
);
1780 int cy
= Math
.round(event
.y
/ fZoomValue
);
1782 if (fZoomValue
< 64) {
1783 fZoomValue
= fZoomValue
* (float) 1.25;
1786 fZoomValue
= fZoomValue
/ (float) 1.25;
1788 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1789 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1790 setContentsPos(x
, y
);
1791 if (fTimeBar
!= null) {
1792 fTimeBar
.setZoom(fZoomValue
);
1794 // redraw also resize the scrollView content
1796 } else {// if (event.button ==1)
1797 GraphNode node
= null;
1798 int x
= Math
.round(event
.x
/ fZoomValue
);
1799 int y
= Math
.round(event
.y
/ fZoomValue
);
1800 node
= fFrame
.getNodeAt(x
, y
);
1802 if ((event
.button
== 1) || ((node
!= null) && !node
.isSelected())) {
1803 if (!fShiftSelection
) {
1806 if (fShiftSelection
) {
1808 addSelection(fFrame
.getNodeList(fListStart
, node
));
1810 performSelection(node
);
1812 fCurrentGraphNode
= node
;
1814 node
.setFocused(true);
1819 if (fDragAndDrop
== null) {
1820 super.contentsMouseDownEvent(event
);
1822 fIsDragAndDrop
= (event
.button
== 1);
1827 * TimerTask for auto scroll feature.
1829 protected static class AutoScroll
extends TimerTask
{
1839 * Field sequence diagram reference.
1841 public SDWidget fSdWidget
;
1844 * Constructor for AutoScroll.
1845 * @param sv sequence diagram widget reference
1849 public AutoScroll(SDWidget sv
, int dx
, int dy
) {
1857 * @see java.util.TimerTask#run()
1861 Display
.getDefault().asyncExec(new Runnable() {
1864 if (fSdWidget
.isDisposed()) {
1867 fSdWidget
.fDragX
+= fDeltaX
;
1868 fSdWidget
.fDragY
+= fDeltaY
;
1869 fSdWidget
.scrollBy(fDeltaX
, fDeltaY
);
1877 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
1880 protected void drawContents(GC gc
, int clipx
, int clipy
, int clipw
, int cliph
) {
1881 if (fFrame
== null) {
1882 gc
.setBackground(getDisplay().getSystemColor(SWT
.COLOR_WHITE
));
1883 gc
.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
1887 // Frame.setUserPref(SDViewPref.getInstance());
1888 SDViewPref
.getInstance();
1891 Rectangle area
= getClientArea();
1892 Image dbuffer
= getDrawBuffer();
1893 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1896 gc
.drawImage(dbuffer
, 0, 0, area
.width
, area
.height
, 0, 0, area
.width
, area
.height
);
1897 } catch (Exception e
) {
1898 Activator
.getDefault().logError("Error drawin content", e
); //$NON-NLS-1$
1901 setHScrollBarIncrement(Math
.round(SDViewPref
.getInstance().getLifelineWidth() / (float) 2 * fZoomValue
));
1902 setVScrollBarIncrement(Math
.round(Metrics
.getMessagesSpacing() * fZoomValue
));
1903 if ((fTimeBar
!= null) && (fFrame
.hasTimeInfo())) {
1904 fTimeBar
.resizeContents(9, height
+ getHorizontalBarHeight());
1905 fTimeBar
.setContentsPos(getContentsX(), getContentsY());
1909 float xRatio
= getContentsWidth() / (float) getVisibleWidth();
1910 float yRatio
= getContentsHeight() / (float) getVisibleHeight();
1911 if (yRatio
> xRatio
) {
1912 setOverviewSize((int) (getVisibleHeight() * 0.75));
1914 setOverviewSize((int) (getVisibleWidth() * 0.75));
1920 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
1923 public void widgetDefaultSelected(SelectionEvent event
) {
1928 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
1931 public void widgetSelected(SelectionEvent event
) {
1932 if (event
.widget
== fZoomIn
) {
1933 fZoomValue
= fZoomValue
* 2;
1934 } else if (event
.widget
== fZoomOut
) {
1935 fZoomValue
= fZoomValue
/ 2;
1941 * Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply button
1944 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
1947 public void propertyChange(PropertyChangeEvent e
) {
1948 if (fFrame
!= null && !isDisposed()) {
1949 fFrame
.resetTimeCompression();
1951 if (e
.getProperty().equals("PREFOK")) //$NON-NLS-1$
1953 // Prepare the overview to be reused for the new
1954 // settings (especially the colors)
1955 if (fOverView
!= null) {
1956 fOverView
.dispose();
1965 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
1968 public void widgetDisposed(DisposeEvent e
) {
1969 if (fOverView
!= null) {
1970 fOverView
.dispose();
1972 super.removeDisposeListener(this);
1973 if ((fCurrentCaretImage
!= null) && (!fCurrentCaretImage
.isDisposed())) {
1974 fCurrentCaretImage
.dispose();
1976 if ((fArrowUpCaretImg
!= null) && (!fArrowUpCaretImg
.isDisposed())) {
1977 fArrowUpCaretImg
.dispose();
1979 if ((fCollapaseCaretImg
!= null) && (!fCollapaseCaretImg
.isDisposed())) {
1980 fCollapaseCaretImg
.dispose();
1982 SDViewPref
.getInstance().removePropertyChangeListener(this);
1983 LoadersManager lm
= LoadersManager
.getInstance();
1984 if (fSite
instanceof SDView
) {
1985 ((SDView
) fSite
).resetProviders();
1987 lm
.resetLoader(((SDView
) fSite
).getViewSite().getId());
1994 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawOverview(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle)
1997 protected void drawOverview(GC gc
, Rectangle r
) {
1998 float oldzoom
= fZoomValue
;
1999 if (getContentsWidth() > getContentsHeight()) {
2000 fZoomValue
= (float) r
.width
/ (float) getContentsWidth() * oldzoom
;
2002 fZoomValue
= (float) r
.height
/ (float) getContentsHeight() * oldzoom
;
2004 if ((fOverView
!= null) && ((r
.width
!= fOverView
.getBounds().width
) || (r
.height
!= fOverView
.getBounds().height
))) {
2005 fOverView
.dispose();
2008 if (fOverView
== null) {
2009 int backX
= getContentsX();
2010 int backY
= getContentsY();
2011 setContentsPos(0, 0);
2012 fOverView
= new Image(getDisplay(), r
.width
, r
.height
);
2013 GC gcim
= new GC(fOverView
);
2014 NGC context
= new NGC(this, gcim
);
2015 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(SDViewPref
.PREF_FRAME
));
2016 fFrame
.draw(context
);
2017 setContentsPos(backX
, backY
);
2021 if ((fOverView
!= null) && (r
.width
== fOverView
.getBounds().width
) && (r
.height
== fOverView
.getBounds().height
)) {
2022 gc
.drawImage(fOverView
, 0, 0, r
.width
, r
.height
, 0, 0, r
.width
, r
.height
);
2025 fZoomValue
= oldzoom
;
2027 super.drawOverview(gc
, r
);
2032 * @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)
2035 public void deltaSelected(Lifeline lifeline
, int startEvent
, int nbEvent
, IColor color
) {
2036 fFrame
.highlightTimeCompression(lifeline
, startEvent
, nbEvent
, color
);
2037 ensureVisible(lifeline
);
2038 int y1
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * startEvent
;
2039 int y2
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * (startEvent
+ nbEvent
);
2040 ensureVisible(lifeline
.getX(), y1
- (Metrics
.getLifelineHeaderFontHeigth() + +2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
), lifeline
.getWidth(), y2
- y1
+ 3, SWT
.CENTER
| SWT
.VERTICAL
, true);
2047 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleWidth()
2050 public int getVisibleWidth() {
2052 return fPrinter
.getClientArea().width
;
2054 return super.getVisibleWidth();
2059 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleHeight()
2062 public int getVisibleHeight() {
2064 return fPrinter
.getClientArea().height
;
2066 return super.getVisibleHeight();
2071 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewX(int)
2074 public int contentsToViewX(int x
) {
2076 int v
= Math
.round(fPrinterX
* fPrinterZoom
);
2079 return x
- getContentsX();
2084 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewY(int)
2087 public int contentsToViewY(int y
) {
2089 int v
= Math
.round(fPrinterY
* fPrinterZoom
);
2092 return y
- getContentsY();
2097 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsX()
2100 public int getContentsX() {
2102 return Math
.round(fPrinterX
* fPrinterZoom
);
2104 return super.getContentsX();
2110 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsY()
2113 public int getContentsY() {
2115 return Math
.round(fPrinterY
* fPrinterZoom
);
2117 return super.getContentsY();
2121 * Traverse Listener implementation.
2123 protected static class LocalTraverseListener
implements TraverseListener
{
2127 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
2130 public void keyTraversed(TraverseEvent e
) {
2131 if ((e
.detail
== SWT
.TRAVERSE_TAB_NEXT
) || (e
.detail
== SWT
.TRAVERSE_TAB_PREVIOUS
)) {