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
.core
.runtime
.IStatus
;
23 import org
.eclipse
.core
.runtime
.Status
;
24 import org
.eclipse
.jface
.contexts
.IContextIds
;
25 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
26 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
27 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
28 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
29 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
30 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.TmfUiPlugin
;
31 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfTimestamp
;
32 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BaseMessage
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BasicExecutionOccurrence
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Frame
;
36 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
37 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.ITimeRange
;
38 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Lifeline
;
39 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Metrics
;
40 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialog
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
.SDPrintDialogUI
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IColor
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDCollapseProvider
;
44 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.LoadersManager
;
45 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
46 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
47 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
48 import org
.eclipse
.swt
.SWT
;
49 import org
.eclipse
.swt
.accessibility
.ACC
;
50 import org
.eclipse
.swt
.accessibility
.Accessible
;
51 import org
.eclipse
.swt
.accessibility
.AccessibleAdapter
;
52 import org
.eclipse
.swt
.accessibility
.AccessibleControlAdapter
;
53 import org
.eclipse
.swt
.accessibility
.AccessibleControlEvent
;
54 import org
.eclipse
.swt
.accessibility
.AccessibleEvent
;
55 import org
.eclipse
.swt
.events
.DisposeEvent
;
56 import org
.eclipse
.swt
.events
.DisposeListener
;
57 import org
.eclipse
.swt
.events
.FocusEvent
;
58 import org
.eclipse
.swt
.events
.FocusListener
;
59 import org
.eclipse
.swt
.events
.KeyEvent
;
60 import org
.eclipse
.swt
.events
.MouseEvent
;
61 import org
.eclipse
.swt
.events
.SelectionEvent
;
62 import org
.eclipse
.swt
.events
.SelectionListener
;
63 import org
.eclipse
.swt
.events
.TraverseEvent
;
64 import org
.eclipse
.swt
.events
.TraverseListener
;
65 import org
.eclipse
.swt
.graphics
.GC
;
66 import org
.eclipse
.swt
.graphics
.Image
;
67 import org
.eclipse
.swt
.graphics
.ImageData
;
68 import org
.eclipse
.swt
.graphics
.Rectangle
;
69 import org
.eclipse
.swt
.printing
.Printer
;
70 import org
.eclipse
.swt
.printing
.PrinterData
;
71 import org
.eclipse
.swt
.widgets
.Canvas
;
72 import org
.eclipse
.swt
.widgets
.Caret
;
73 import org
.eclipse
.swt
.widgets
.Composite
;
74 import org
.eclipse
.swt
.widgets
.Control
;
75 import org
.eclipse
.swt
.widgets
.Display
;
76 import org
.eclipse
.swt
.widgets
.Event
;
77 import org
.eclipse
.swt
.widgets
.Listener
;
78 import org
.eclipse
.swt
.widgets
.MenuItem
;
79 import org
.eclipse
.ui
.contexts
.IContextService
;
80 import org
.eclipse
.ui
.part
.ViewPart
;
84 * This class implements sequence diagram widget used in the sequence diagram view.
91 public class SDWidget
extends ScrollView
implements SelectionListener
, IPropertyChangeListener
, DisposeListener
, ITimeCompressionListener
{
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
98 * The frame to display in the sequence diagram widget.
100 protected Frame fFrame
;
102 * The overview image to display.
104 protected Image fOverView
= null;
106 * The zoom in menu item.
108 protected MenuItem fZoomIn
= null;
110 * The zoom out menu item.
112 protected MenuItem fZoomOut
= null;
114 * The sequence diagram selection provider.
116 protected SDWidgetSelectionProvider fSelProvider
= null;
118 * The current zoom value.
120 public float fZoomValue
= 1;
122 * The current zoomInMode (true for zoom in).
124 protected boolean fZoomInMode
= false;
126 * The current zoomOutMode (true for zoom out).
128 protected boolean fZoomOutMode
= false;
130 * The current list of selected graph nodes.
132 protected List
<GraphNode
> fSelectedNodeList
= null;
134 * Flag whether ctrl button is selected or not.
136 protected boolean fCtrlSelection
= false;
138 * A reference to the view site.
140 protected ViewPart fSite
= null;
142 * The current graph node (the last selected one).
144 public GraphNode fCurrentGraphNode
= null;
146 * The first graph node in list (multiple selection).
148 public GraphNode fListStart
= null;
150 * The previous graph node (multiple selection).
152 public List
<GraphNode
> fPrevList
= null;
154 * The time compression bar.
156 protected TimeCompressionBar fTimeBar
= null;
158 * The current diagram tool tip.
160 protected DiagramToolTip fToolTip
= null;
162 * The accessible object reference of view control.
164 protected Accessible fAccessible
= null;
166 * The current node for the tooltip to display.
168 protected GraphNode fToolTipNode
;
170 * The life line to drag and drop.
172 protected Lifeline fDragAndDrop
= null;
174 * The number of focused widgets.
176 protected int fFocusedWidget
= -1;
180 protected float fPrinterZoom
= 0;
182 * Y coordinate for printer.
184 protected int fPrinterY
= 0;
186 * X coordinate for printer.
188 protected int fPrinterX
= 0;
190 * Flag whether drag and drop is enabled or not.
192 protected boolean fIsDragAndDrop
= false;
194 * The x coordinate for drag.
196 protected int fDragX
= 0;
198 * The y coordinate for drag.
200 protected int fDragY
= 0;
204 protected boolean fReorderMode
= false;
206 * The collapse caret image.
208 protected Image fCollapaseCaretImg
= null;
210 * The arrow up caret image.
212 protected Image fArrowUpCaretImg
= null;
214 * The current caret image.
216 protected Image fCurrentCaretImage
= null;
218 * A sequence diagramm collapse provider (for collapsing graph nodes)
220 protected ISDCollapseProvider fCollapseProvider
= null;
222 * The insertion caret.
224 protected Caret fInsertionCartet
= null;
226 * The reorder list when in reorder mode.
228 protected List
<Lifeline
[]> fReorderList
= null;
230 * Flag to specify whether in printing mode or not.
232 protected boolean fIsPrinting
= false;
234 * A printer reference.
236 protected Printer fPrinter
= null;
238 * Flag whether shift was selected or not.
240 protected boolean fShiftSelection
= false;
242 * The scroll tooltip.
244 protected DiagramToolTip fScrollToolTip
= null;
246 * Timer for auto_scroll feature
248 protected AutoScroll fLocalAutoScroll
= null;
250 * TimerTask for auto_scroll feature !=null when auto scroll is running
252 protected Timer fLocalAutoScrollTimer
= null;
254 // ------------------------------------------------------------------------
256 // ------------------------------------------------------------------------
258 * Constructor for SDWidget.
259 * @param c The parent composite
262 public SDWidget(Composite c
, int s
) {
263 super(c
, s
| SWT
.NO_BACKGROUND
, true);
264 setOverviewEnabled(true);
265 fSelectedNodeList
= new ArrayList
<GraphNode
>();
266 fSelProvider
= new SDWidgetSelectionProvider();
267 SDViewPref
.getInstance().addPropertyChangeListener(this);
268 fToolTip
= new DiagramToolTip(getViewControl());
269 super.addDisposeListener(this);
271 fScrollToolTip
= new DiagramToolTip(c
);
272 getVerticalBar().addListener(SWT
.MouseUp
, new Listener() {
275 public void handleEvent(Event event
) {
276 fScrollToolTip
.hideToolTip();
280 fAccessible
= getViewControl().getAccessible();
282 fAccessible
.addAccessibleListener(new AccessibleAdapter() {
285 * @see org.eclipse.swt.accessibility.AccessibleAdapter#getName(org.eclipse.swt.accessibility.AccessibleEvent)
288 public void getName(AccessibleEvent e
) {
290 if (e
.childID
== 0) {
291 if (fToolTipNode
!= null) {
292 if (fToolTipNode
instanceof Lifeline
) {
293 Lifeline lifeline
= (Lifeline
) fToolTipNode
;
294 e
.result
= lifeline
.getToolTipText();
296 e
.result
= fToolTipNode
.getName() + getPostfixForTooltip(true);
300 if (getFocusNode() != null) {
301 if (getFocusNode() instanceof Lifeline
) {
302 e
.result
= MessageFormat
.format(SDMessages
._1
, new Object
[] { String
.valueOf(getFocusNode().getName()) });
304 if (getFocusNode() instanceof BaseMessage
) {
305 BaseMessage mes
= (BaseMessage
) getFocusNode();
306 if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() != null)) {
307 e
.result
= MessageFormat
.format(
309 new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()), String
.valueOf(mes
.getEndLifeline().getName()),
310 Integer
.valueOf(mes
.getEndOccurrence()) });
311 } else if ((mes
.getStartLifeline() == null) && (mes
.getEndLifeline() != null)) {
312 e
.result
= MessageFormat
.format(SDMessages
._4
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getEndLifeline().getName()), Integer
.valueOf(mes
.getEndOccurrence()) });
313 } else if ((mes
.getStartLifeline() != null) && (mes
.getEndLifeline() == null)) {
314 e
.result
= MessageFormat
.format(SDMessages
._3
, new Object
[] { String
.valueOf(mes
.getName()), String
.valueOf(mes
.getStartLifeline().getName()), Integer
.valueOf(mes
.getStartOccurrence()) });
316 } else if (getFocusNode() instanceof BasicExecutionOccurrence
) {
317 BasicExecutionOccurrence exec
= (BasicExecutionOccurrence
) getFocusNode();
318 e
.result
= MessageFormat
.format(SDMessages
._5
,
319 new Object
[] { String
.valueOf(exec
.getName()), String
.valueOf(exec
.getLifeline().getName()), Integer
.valueOf(exec
.getStartOccurrence()), Integer
.valueOf(exec
.getEndOccurrence()) });
327 fAccessible
.addAccessibleControlListener(new AccessibleControlAdapter() {
330 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getFocus(org.eclipse.swt.accessibility.AccessibleControlEvent)
333 public void getFocus(AccessibleControlEvent e
) {
334 if (fFocusedWidget
== -1) {
335 e
.childID
= ACC
.CHILDID_SELF
;
337 e
.childID
= fFocusedWidget
;
343 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getRole(org.eclipse.swt.accessibility.AccessibleControlEvent)
346 public void getRole(AccessibleControlEvent e
) {
348 case ACC
.CHILDID_SELF
:
349 e
.detail
= ACC
.ROLE_CLIENT_AREA
;
352 e
.detail
= ACC
.ROLE_TOOLTIP
;
355 e
.detail
= ACC
.ROLE_LABEL
;
364 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getState(org.eclipse.swt.accessibility.AccessibleControlEvent)
367 public void getState(AccessibleControlEvent e
) {
368 e
.detail
= ACC
.STATE_FOCUSABLE
;
369 if (e
.childID
== ACC
.CHILDID_SELF
) {
370 e
.detail
|= ACC
.STATE_FOCUSED
;
372 e
.detail
|= ACC
.STATE_SELECTABLE
;
373 if (e
.childID
== fFocusedWidget
)
374 e
.detail
|= ACC
.STATE_FOCUSED
| ACC
.STATE_SELECTED
| ACC
.STATE_CHECKED
;
379 fInsertionCartet
= new Caret((Canvas
) getViewControl(), SWT
.NONE
);
380 fInsertionCartet
.setVisible(false);
382 fCollapaseCaretImg
= TmfUiPlugin
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_COLLAPSE_OBJ
);
383 fArrowUpCaretImg
= TmfUiPlugin
.getDefault().getImageFromPath(ITmfImageConstants
.IMG_UI_ARROW_UP_OBJ
);
385 fReorderList
= new ArrayList
<Lifeline
[]>();
386 getViewControl().addTraverseListener(new LocalTraverseListener());
388 addTraverseListener(new LocalTraverseListener());
390 getViewControl().addFocusListener(new FocusListener() {
394 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
397 public void focusGained(FocusEvent e
) {
398 SDViewPref
.getInstance().setNoFocusSelection(false);
399 fCtrlSelection
= false;
400 fShiftSelection
= false;
406 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
409 public void focusLost(FocusEvent e
) {
410 SDViewPref
.getInstance().setNoFocusSelection(true);
416 // ------------------------------------------------------------------------
418 // ------------------------------------------------------------------------
420 * Sets the time compression bar.
422 * @param bar The time compression bar to set
424 public void setTimeBar(TimeCompressionBar bar
) {
427 fTimeBar
.addTimeCompressionListener(this);
432 * Resize the contents to insure the frame fit into the view
434 * @param frame the frame which will be drawn in the view
436 public void resizeContents(Frame frame
) {
437 int width
= Math
.round((frame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
438 int height
= Math
.round((frame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
439 resizeContents(width
, height
);
443 * The frame to render (the sequence diagram)
445 * @param theFrame the frame to display
446 * @param resetPosition boolean
448 public void setFrame(Frame theFrame
, boolean resetPosition
) {
449 fReorderList
.clear();
450 fSelectedNodeList
.clear();
451 fSelProvider
.setSelection(new StructuredSelection());
454 setContentsPos(0, 0);
455 resizeContents(fFrame
);
458 // prepare the old overview to be reused
459 if (fOverView
!= null) {
463 resizeContents(fFrame
);
467 * Returns the current Frame (the sequence diagram container)
471 public Frame
getFrame() {
476 * Returns the selection provider for the current sequence diagram
478 * @return the selection provider
480 public ISelectionProvider
getSelectionProvider() {
485 * Returns a list of selected graph nodes.
487 * @return a list of selected graph nodes.
489 public List
<GraphNode
> getSelection() {
490 return fSelectedNodeList
;
494 * Adds a graph node to the selected nodes list.
496 * @param node A graph node
498 public void addSelection(GraphNode node
) {
502 fSelectedNodeList
.add(node
);
503 node
.setSelected(true);
504 fCurrentGraphNode
= node
;
505 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
506 fSelProvider
.setSelection(selection
);
510 * Adds a list of node to the selected nodes list.
512 * @param list of graph nodes
514 public void addSelection(List
<GraphNode
> list
) {
515 // selectedNodeList.addAll(list);
516 for (int i
= 0; i
< list
.size(); i
++) {
517 if (!fSelectedNodeList
.contains(list
.get(i
))) {
518 fSelectedNodeList
.add(list
.get(i
));
519 ((GraphNode
) list
.get(i
)).setSelected(true);
522 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
523 fSelProvider
.setSelection(selection
);
527 * Removes a node from the selected nodes list.
529 * @param node to remove
531 public void removeSelection(GraphNode node
) {
532 fSelectedNodeList
.remove(node
);
533 node
.setSelected(false);
534 node
.setFocused(false);
535 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
536 fSelProvider
.setSelection(selection
);
540 * Removes a list of graph nodes from the selected nodes list.
542 * @param list of nodes to remove.
544 public void removeSelection(List
<GraphNode
> list
) {
545 fSelectedNodeList
.removeAll(list
);
546 for (int i
= 0; i
< list
.size(); i
++) {
547 ((GraphNode
) list
.get(i
)).setSelected(false);
548 ((GraphNode
) list
.get(i
)).setFocused(false);
550 StructuredSelection selection
= new StructuredSelection(fSelectedNodeList
);
551 fSelProvider
.setSelection(selection
);
555 * Clear the list of GraphNodes which must be drawn selected.
557 public void clearSelection() {
558 for (int i
= 0; i
< fSelectedNodeList
.size(); i
++) {
559 ((GraphNode
) fSelectedNodeList
.get(i
)).setSelected(false);
560 ((GraphNode
) fSelectedNodeList
.get(i
)).setFocused(false);
562 fCurrentGraphNode
= null;
563 fSelectedNodeList
.clear();
564 fSelProvider
.setSelection(new StructuredSelection());
570 * @param viewSite The view part to set
572 public void setSite(ViewPart viewSite
) {
574 fSite
.getSite().setSelectionProvider(fSelProvider
);
575 IContextService service
= (IContextService
) fSite
.getSite().getWorkbenchWindow().getService(IContextService
.class);
576 service
.activateContext("org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"); //$NON-NLS-1$
577 service
.activateContext(IContextIds
.CONTEXT_ID_WINDOW
);
581 * Returns the GraphNode overView the mouse if any
583 * @return the current graph node
585 public GraphNode
getMouseOverNode() {
586 return fCurrentGraphNode
;
590 * Sets the zoom in mode.
592 * @param The mode value to set.
594 public void setZoomInMode(boolean value
) {
596 setZoomOutMode(false);
602 * Sets the zoom out mode.
604 * @param The mode value to set.
606 public void setZoomOutMode(boolean value
) {
608 setZoomInMode(false);
610 fZoomOutMode
= value
;
614 * Moves the Sequence diagram to ensure the given node is visible and draw it selected
616 * @param node the GraphNode to move to
618 public void moveTo(GraphNode node
) {
628 * Moves the Sequence diagram to ensure the given node is visible
630 * @param node the GraphNode to move to
632 public void ensureVisible(GraphNode node
) {
636 int x
= Math
.round(node
.getX() * fZoomValue
);
637 int y
= Math
.round(node
.getY() * fZoomValue
);
638 int width
= Math
.round(node
.getWidth() * fZoomValue
);
639 int height
= Math
.round(node
.getHeight() * fZoomValue
);
640 if ((node
instanceof BaseMessage
) && (height
== 0)) {
641 int header
= Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
* 2 + Metrics
.getLifelineHeaderFontHeigth();
642 height
= -Math
.round((Metrics
.getMessagesSpacing() + header
) * fZoomValue
);
643 y
= y
+ Math
.round(Metrics
.SYNC_INTERNAL_MESSAGE_HEIGHT
* fZoomValue
);
645 if (node
instanceof BasicExecutionOccurrence
) {
649 if (node
instanceof Lifeline
) {
651 height
= getVisibleHeight();
653 ensureVisible(x
, y
, width
, height
, SWT
.CENTER
, true);
658 * Returns the current zoom factor.
659 * @return the current zoom factor.
661 public float getZoomFactor() {
666 * Returns teh printer reference.
668 * @return the printer reference
670 public Printer
getPrinter() {
675 * Returns whether the widget is used for printing or not.
677 * @return whether the widget is used for printing or not
679 public boolean isPrinting() {
684 * Gets the overview image.
686 * @param rect Rectangle to include overview.
687 * @return the overview image
689 public Image
getOverview(Rectangle rect
) {
690 float oldzoom
= fZoomValue
;
691 if ((fOverView
!= null) && ((rect
.width
!= fOverView
.getBounds().width
) || (rect
.height
!= fOverView
.getBounds().height
))) {
695 if (fOverView
== null) {
696 int backX
= getContentsX();
697 int backY
= getContentsY();
698 setContentsPos(0, 0);
699 fOverView
= new Image(getDisplay(), rect
.width
, rect
.height
);
700 GC gcim
= new GC(fOverView
);
701 NGC context
= new NGC(this, gcim
);
702 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(SDViewPref
.PREF_FRAME
));
703 fFrame
.draw(context
);
704 setContentsPos(backX
, backY
);
708 fZoomValue
= oldzoom
;
713 * Resets the zoom factor.
715 public void resetZoomFactor() {
716 int currentX
= Math
.round(getContentsX() / fZoomValue
);
717 int currentY
= Math
.round(getContentsY() / fZoomValue
);
719 if (fTimeBar
!= null && !fTimeBar
.isDisposed()) {
720 fTimeBar
.setZoom(fZoomValue
);
724 setContentsPos(currentX
, currentY
);
728 * Enable or disable the lifeline reodering using Drag and Drop
730 * @param mode - true to enable false otherwise
732 public void setReorderMode(boolean mode
) {
737 * Return the lifelines reorder sequence (using Drag and Drop) if the the reorder mode is turn on. Each ArryList
738 * element is of type Lifeline[2] with Lifeline[0] inserted before Lifeline[1] in the diagram
740 * @return - the re-odered sequence
742 public List
<Lifeline
[]> getLifelineReoderList() {
747 * Sets the focus on given graph node (current node).
749 * @param the graph node to focus on.
751 public void setFocus(GraphNode node
) {
755 if (fCurrentGraphNode
!= null) {
756 fCurrentGraphNode
.setFocused(false);
758 fCurrentGraphNode
= node
;
759 node
.setFocused(true);
765 * Returns the graph node focused on.
767 * @return the current graph node
769 public GraphNode
getFocusNode() {
770 return fCurrentGraphNode
;
774 * Method to traverse right.
776 public void traverseRight() {
777 Object selectedNode
= getFocusNode();
778 if (selectedNode
== null) {
781 GraphNode node
= null;
782 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
783 node
= fFrame
.getCalledMessage((BaseMessage
) selectedNode
);
785 if (selectedNode
instanceof BasicExecutionOccurrence
) {
786 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
788 if ((node
== null) && (selectedNode
instanceof Lifeline
)) {
789 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
790 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
< fFrame
.lifeLinesCount() - 1)) {
791 node
= fFrame
.getLifeline(i
+ 1);
803 * Method to traverse left.
805 public void traverseLeft() {
806 Object selectedNode
= getFocusNode();
807 GraphNode node
= null;
808 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
809 node
= fFrame
.getCallerMessage((BaseMessage
) selectedNode
);
811 if (selectedNode
instanceof BasicExecutionOccurrence
) {
812 selectedNode
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
815 if ((selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getEndLifeline() != null)) {
816 selectedNode
= ((BaseMessage
) selectedNode
).getEndLifeline();
818 for (int i
= 0; i
< fFrame
.lifeLinesCount(); i
++) {
819 if ((selectedNode
== fFrame
.getLifeline(i
)) && (i
> 0)) {
820 node
= fFrame
.getLifeline(i
- 1);
824 if ((fFrame
.lifeLinesCount() > 0) && (node
== null)) {
825 node
= fFrame
.getLifeline(0);
835 * Method to traverse up.
837 public void traverseUp() {
838 Object selectedNode
= getFocusNode();
839 if (selectedNode
== null) {
842 GraphNode node
= null;
843 if (selectedNode
instanceof BaseMessage
) {
844 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
845 } else if (selectedNode
instanceof Lifeline
) {
846 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
847 if (!(node
instanceof Lifeline
)) {
850 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
851 node
= fFrame
.getPrevExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
853 node
= ((BasicExecutionOccurrence
) selectedNode
).getLifeline();
856 if ((node
== null) && (selectedNode
instanceof BaseMessage
) && (((BaseMessage
) selectedNode
).getStartLifeline() != null)) {
857 node
= ((BaseMessage
) selectedNode
).getStartLifeline();
867 * Method to traverse down.
869 public void traverseDown() {
870 Object selectedNode
= getFocusNode();
871 if (selectedNode
== null) {
875 if (selectedNode
instanceof BaseMessage
) {
876 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), (BaseMessage
) selectedNode
);
877 } else if (selectedNode
instanceof Lifeline
) {
878 // node = frame.getNextLifelineMessage((Lifeline)selectedNode,null);
879 node
= fFrame
.getFirstExecution((Lifeline
) selectedNode
);
880 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
881 node
= fFrame
.getNextExecOccurrence((BasicExecutionOccurrence
) selectedNode
);
893 * Method to traverse home.
895 public void traverseHome() {
896 Object selectedNode
= getFocusNode();
897 if (selectedNode
== null) {
900 GraphNode node
= null;
902 if (selectedNode
instanceof BaseMessage
) {
903 if (((BaseMessage
) selectedNode
).getStartLifeline() != null) {
904 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
906 node
= fFrame
.getNextLifelineMessage(((BaseMessage
) selectedNode
).getEndLifeline(), null);
908 } else if (selectedNode
instanceof Lifeline
) {
909 node
= fFrame
.getNextLifelineMessage((Lifeline
) selectedNode
, null);
910 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
911 node
= fFrame
.getFirstExecution(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
913 if (fFrame
.lifeLinesCount() > 0) {
914 Lifeline lifeline
= fFrame
.getLifeline(0);
915 node
= fFrame
.getNextLifelineMessage(lifeline
, null);
926 * Method to traverse to the end.
928 public void traverseEnd() {
929 Object selectedNode
= getFocusNode();
930 if (selectedNode
== null) {
934 if (selectedNode
instanceof BaseMessage
) {
935 node
= fFrame
.getPrevLifelineMessage(((BaseMessage
) selectedNode
).getStartLifeline(), null);
936 } else if (selectedNode
instanceof Lifeline
) {
937 node
= fFrame
.getPrevLifelineMessage((Lifeline
) selectedNode
, null);
938 } else if (selectedNode
instanceof BasicExecutionOccurrence
) {
939 node
= fFrame
.getLastExecOccurrence(((BasicExecutionOccurrence
) selectedNode
).getLifeline());
941 if (fFrame
.lifeLinesCount() > 0) {
942 Lifeline lifeline
= fFrame
.getLifeline(0);
943 node
= fFrame
.getPrevLifelineMessage(lifeline
, null);
956 * Method to print UI.
958 * @param sdPrintDialog the sequence diagram printer dialog.
960 public void printUI(SDPrintDialogUI sdPrintDialog
) {
961 PrinterData data
= sdPrintDialog
.getPrinterData();
963 if ((data
== null) || (fFrame
== null)) {
967 fPrinter
= new Printer(data
);
969 String jobName
= MessageFormat
.format(SDMessages
._116
, new Object
[] { String
.valueOf(fSite
.getContentDescription()), String
.valueOf(fFrame
.getName()) });
970 fPrinter
.startJob(jobName
);
972 GC gc
= new GC(fPrinter
);
973 // Frame.setUserPref(SDViewPref.getInstance());
975 float lastZoom
= fZoomValue
;
977 Rectangle area
= getClientArea();
981 NGC context
= new NGC(this, gcim
);
983 // Set the metrics to use for lifeline text and message text
984 // using the Graphical Context
985 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
)));
986 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
)));
987 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
988 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
989 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
991 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_SYNC_MESS
));
992 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_SYNC_MESS_RET
));
993 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_ASYNC_MESS
));
994 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_ASYNC_MESS_RET
));
996 int messageFontHeight
= 0;
997 if (syncMessFontH
> syncMessRetFontH
) {
998 messageFontHeight
= syncMessFontH
;
1000 messageFontHeight
= syncMessRetFontH
;
1002 if (messageFontHeight
< asyncMessFontH
) {
1003 messageFontHeight
= asyncMessFontH
;
1005 if (messageFontHeight
< asyncMessRetFontH
) {
1006 messageFontHeight
= asyncMessRetFontH
;
1008 Metrics
.setMessageFontHeight(messageFontHeight
);
1009 context
.setFont(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
));
1011 int width
= Math
.round((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1012 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1013 if (width
< area
.width
) {
1016 if (height
< area
.height
) {
1017 height
= area
.height
;
1019 resizeContents(width
, height
);
1021 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1022 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1023 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1024 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1025 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1026 gcim
.setLineWidth(1);
1028 fPrinter
.startPage();
1029 fZoomValue
= lastZoom
;
1031 int restoreX
= getContentsX();
1032 int restoreY
= getContentsY();
1034 float zh
= sdPrintDialog
.getStepY() * sdPrintDialog
.getZoomFactor();
1035 float zw
= sdPrintDialog
.getStepX() * sdPrintDialog
.getZoomFactor();
1037 float zoomValueH
= fPrinter
.getClientArea().height
/ zh
;
1038 float zoomValueW
= fPrinter
.getClientArea().width
/ zw
;
1039 if (zoomValueH
> zoomValueW
) {
1040 fPrinterZoom
= zoomValueH
;
1042 fPrinterZoom
= zoomValueW
;
1045 if (sdPrintDialog
.printSelection()) {
1046 int[] pagesList
= sdPrintDialog
.getPageList();
1048 for (int pageIndex
= 0; pageIndex
< pagesList
.length
; pageIndex
++) {
1049 printPage(pagesList
[pageIndex
], sdPrintDialog
, context
);
1051 } else if (sdPrintDialog
.printAll()) {
1052 for (int pageIndex
= 1; pageIndex
<= sdPrintDialog
.maxNumOfPages(); pageIndex
++) {
1053 printPage(pageIndex
, sdPrintDialog
, context
);
1055 } else if (sdPrintDialog
.printCurrent()) {
1056 printPage(getContentsX(), getContentsY(), sdPrintDialog
, context
, 1);
1057 } else if (sdPrintDialog
.printRange()) {
1058 for (int pageIndex
= sdPrintDialog
.getFrom(); pageIndex
<= sdPrintDialog
.maxNumOfPages() && pageIndex
<= sdPrintDialog
.getTo(); pageIndex
++) {
1059 printPage(pageIndex
, sdPrintDialog
, context
);
1064 fIsPrinting
= false;
1069 fZoomValue
= lastZoom
;
1071 setContentsPos(restoreX
, restoreY
);
1077 public void print() {
1078 SDPrintDialog sdPrinter
= new SDPrintDialog(this.getShell(), this);
1080 if (sdPrinter
.open() != 0) {
1083 } catch (Exception e
) {
1084 TmfUiPlugin
.getDefault().getLog().log(new Status(IStatus
.ERROR
,TmfUiPlugin
.PLUGIN_ID
, "Error creating image", e
)); //$NON-NLS-1$
1087 printUI(sdPrinter
.getDialogUI());
1091 * Method to print a page.
1093 * @param pageNum The page number
1094 * @param pd The sequence diagram print dialog
1095 * @param context The graphical context
1097 public void printPage(int pageNum
, SDPrintDialogUI pd
, NGC context
) {
1098 int j
= pageNum
/ pd
.getNbRow();
1099 int i
= pageNum
% pd
.getNbRow();
1109 i
= (int) (i
* pd
.getStepX());
1110 j
= (int) (j
* pd
.getStepY());
1112 printPage(i
, j
, pd
, context
, pageNum
);
1118 * Method to print page ranges.
1120 * @param i The start page
1121 * @param j The end page
1122 * @param pd The sequence diagram print dialog
1123 * @param context The graphical context
1124 * @param pageNum int the current page
1126 public void printPage(int i
, int j
, SDPrintDialogUI pd
, NGC context
, int pageNum
) {
1127 fIsPrinting
= false;
1128 int pageNumFontZoom
= fPrinter
.getClientArea().height
/ getVisibleHeight();
1131 setContentsPos(i
, j
);
1134 float lastZoom
= fZoomValue
;
1135 fZoomValue
= fPrinterZoom
* lastZoom
;
1137 fFrame
.draw(context
);
1139 fZoomValue
= pageNumFontZoom
;
1140 context
.setFont(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
));
1141 String currentPageNum
= String
.valueOf(pageNum
);
1142 int ii
= context
.textExtent(currentPageNum
);
1143 int jj
= context
.getCurrentFontHeight();
1144 // context.setBackground(ColorImpl.getSystemColor(SWT.COLOR_BLACK));
1145 // context.setForeground(ColorImpl.getSystemColor(SWT.COLOR_WHITE));
1146 fZoomValue
= fPrinterZoom
* lastZoom
;
1147 context
.drawText(currentPageNum
, Math
.round(fPrinterX
+ getVisibleWidth() / fPrinterZoom
- ii
/ fPrinterZoom
), Math
.round(fPrinterY
+ getVisibleHeight() / fPrinterZoom
- jj
/ fPrinterZoom
), false);
1148 fIsPrinting
= false;
1149 fZoomValue
= lastZoom
;
1153 * Sets the collapse provider.
1155 * @param provider The collapse provider to set
1157 protected void setCollapseProvider(ISDCollapseProvider provider
) {
1158 fCollapseProvider
= provider
;
1163 * Checks for focus of children.
1165 * @param children Control to check
1166 * @return true if child is on focus else false
1168 protected boolean checkFocusOnChilds(Control children
) {
1169 if (children
instanceof Composite
) {
1170 Control
[] child
= ((Composite
) children
).getChildren();
1171 for (int i
= 0; i
< child
.length
; i
++) {
1172 if (child
[i
].isFocusControl()) {
1175 checkFocusOnChilds(child
[i
]);
1183 * A post action for a tooltip (before displaying).
1185 * @param accessible true if accessible else false
1186 * @return the tooltip text.
1188 protected String
getPostfixForTooltip(boolean accessible
) {
1189 StringBuffer postfix
= new StringBuffer();
1190 // String postfix = "";//$NON-NLS-1$
1191 // Determine if the tooltip must show the time difference between the current mouse position and
1192 // the last selected graphNode
1193 if ((fCurrentGraphNode
!= null) &&
1194 (fCurrentGraphNode
instanceof ITimeRange
) &&
1195 (fToolTipNode
instanceof ITimeRange
) &&
1196 (fCurrentGraphNode
!= fToolTipNode
) &&
1197 ((ITimeRange
) fToolTipNode
).hasTimeInfo() &&
1198 ((ITimeRange
) fCurrentGraphNode
).hasTimeInfo()) {
1199 postfix
.append(" -> "); //$NON-NLS-1$
1200 postfix
.append(fCurrentGraphNode
.getName());
1201 postfix
.append("\n"); //$NON-NLS-1$
1202 postfix
.append(SDMessages
._138
);
1203 postfix
.append(" "); //$NON-NLS-1$
1205 // postfix = " -> " + fCurrentGraphNode.getName() + "\n" + SDMessages._138 + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1207 //double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
1208 ITmfTimestamp firstTime
= ((ITimeRange
) fCurrentGraphNode
).getEndTime();
1209 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1210 TmfTimestamp delta
= (TmfTimestamp
) lastTime
.getDelta(firstTime
);
1211 postfix
.append(delta
.toString());
1213 // postfix += delta.toString();
1215 if ((fToolTipNode
instanceof ITimeRange
) && ((ITimeRange
) fToolTipNode
).hasTimeInfo()) {
1216 postfix
.append("\n"); //$NON-NLS-1$
1217 // postfix = "\n";//$NON-NLS-1$
1218 ITmfTimestamp firstTime
= ((ITimeRange
) fToolTipNode
).getStartTime();
1219 ITmfTimestamp lastTime
= ((ITimeRange
) fToolTipNode
).getEndTime();
1221 if (firstTime
!= null) {
1222 if (lastTime
!= null && firstTime
.compareTo(lastTime
, true) != 0) {
1223 postfix
.append("start: "); //$NON-NLS-1$
1224 postfix
.append(firstTime
.toString());
1225 postfix
.append("\n"); //$NON-NLS-1$
1226 postfix
.append("end: "); //$NON-NLS-1$
1227 postfix
.append(lastTime
.toString());
1228 postfix
.append("\n"); //$NON-NLS-1$
1229 // postfix += "start: " + firstTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
1230 // postfix += "end: " + lastTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
1232 postfix
.append(firstTime
.toString());
1233 // postfix += firstTime.toString();
1236 else if (lastTime
!= null) {
1237 postfix
.append(lastTime
.toString());
1238 // postfix += lastTime.toString();
1242 return postfix
.toString();
1246 * Sets a new focused widget.
1248 * @param newFocusShape A new focus shape.
1250 protected void setFocus(int newFocusShape
) {
1251 fFocusedWidget
= newFocusShape
;
1252 if (fFocusedWidget
== -1) {
1253 getViewControl().getAccessible().setFocus(ACC
.CHILDID_SELF
);
1255 getViewControl().getAccessible().setFocus(fFocusedWidget
);
1260 * Highlight the given GraphNode<br>
1261 * The GraphNode is then displayed using the system default selection color
1263 * @param node the GraphNode to highlight
1265 protected void performSelection(GraphNode node
) {
1266 if ((fCtrlSelection
) || (fShiftSelection
)) {
1268 if (fSelectedNodeList
.contains(node
)) {
1269 removeSelection(node
);
1285 * Returns a draw buffer image.
1287 * @return a Image containing the draw buffer.
1289 protected Image
getDrawBuffer() {
1292 Rectangle area
= getClientArea();
1293 Image dbuffer
= null;
1297 dbuffer
= new Image(getDisplay(), area
.width
, area
.height
);
1298 } catch (Exception e
) {
1299 TmfUiPlugin
.getDefault().getLog().log(new Status(IStatus
.ERROR
,TmfUiPlugin
.PLUGIN_ID
, "Error creating image", e
)); //$NON-NLS-1$
1302 gcim
= new GC(dbuffer
);
1304 NGC context
= new NGC(this, gcim
);
1306 // Set the metrics to use for lifeline text and message text
1307 // using the Graphical Context
1308 Metrics
.setLifelineFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
)));
1309 Metrics
.setLifelineFontWidth(context
.getFontWidth(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
)));
1310 Metrics
.setLifelineWidth(SDViewPref
.getInstance().getLifelineWidth());
1311 Metrics
.setFrameFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_FRAME_NAME
)));
1312 Metrics
.setLifelineHeaderFontHeight(context
.getFontHeight(SDViewPref
.getInstance().getFont(ISDPreferences
.PREF_LIFELINE_HEADER
)));
1314 int syncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_SYNC_MESS
));
1315 int syncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_SYNC_MESS_RET
));
1316 int asyncMessFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_ASYNC_MESS
));
1317 int asyncMessRetFontH
= context
.getFontHeight(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_ASYNC_MESS_RET
));
1319 int messageFontHeight
= 0;
1320 if (syncMessFontH
> syncMessRetFontH
) {
1321 messageFontHeight
= syncMessFontH
;
1323 messageFontHeight
= syncMessRetFontH
;
1325 if (messageFontHeight
< asyncMessFontH
) {
1326 messageFontHeight
= asyncMessFontH
;
1328 if (messageFontHeight
< asyncMessRetFontH
) {
1329 messageFontHeight
= asyncMessRetFontH
;
1331 Metrics
.setMessageFontHeight(messageFontHeight
);
1332 context
.setFont(SDViewPref
.getInstance().getFont(SDViewPref
.PREF_LIFELINE
));
1334 int width
= (int) ((fFrame
.getWidth() + 2 * Metrics
.FRAME_H_MARGIN
) * fZoomValue
);
1335 int height
= (int) ((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1337 resizeContents(width
, height
);
1339 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(ISDPreferences
.PREF_FRAME
));
1340 context
.fillRectangle(0, 0, getContentsWidth(), Metrics
.FRAME_V_MARGIN
);
1341 context
.fillRectangle(0, 0, fFrame
.getX(), getContentsHeight());
1342 context
.fillRectangle(fFrame
.getX() + fFrame
.getWidth() + 1, 0, getContentsWidth() - (fFrame
.getX() + fFrame
.getWidth() + 1), getContentsHeight());
1343 context
.fillRectangle(0, fFrame
.getY() + fFrame
.getHeight() + 1, getContentsWidth(), getContentsHeight() - (fFrame
.getY() + fFrame
.getHeight() + 1));
1344 gcim
.setLineWidth(1);
1346 fFrame
.draw(context
);
1347 if (fDragAndDrop
!= null) {
1348 Lifeline node
= (Lifeline
) fDragAndDrop
;
1349 boolean isSelected
= fDragAndDrop
.isSelected();
1350 boolean hasFocus
= fDragAndDrop
.hasFocus();
1351 node
.setSelected(false);
1352 node
.setFocused(false);
1353 node
.draw(context
, fDragX
, fDragY
);
1354 node
.setSelected(isSelected
);
1355 node
.setFocused(hasFocus
);
1364 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
1367 protected void keyPressedEvent(KeyEvent event
) {
1368 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1369 Control
[] child
= getParent().getChildren();
1370 for (int i
= 0; i
< child
.length
; i
++) {
1371 if ((child
[i
].isFocusControl())&& (!(child
[i
] instanceof ScrollView
))) {
1372 getViewControl().setFocus();
1379 if (event
.keyCode
== SWT
.CTRL
) {
1380 fCtrlSelection
= true;
1382 if (event
.keyCode
== SWT
.SHIFT
) {
1383 fShiftSelection
= true;
1384 fPrevList
= new ArrayList
<GraphNode
>();
1385 fPrevList
.addAll(getSelection());
1388 GraphNode prevNode
= getFocusNode();
1390 if (event
.keyCode
== SWT
.ARROW_RIGHT
) {
1394 if (event
.keyCode
== SWT
.ARROW_LEFT
) {
1398 if (event
.keyCode
== SWT
.ARROW_DOWN
) {
1402 if (event
.keyCode
== SWT
.ARROW_UP
) {
1406 if (event
.keyCode
== SWT
.HOME
) {
1410 if (event
.keyCode
== SWT
.END
) {
1414 if ((!fShiftSelection
) && (!fCtrlSelection
)) {
1415 fListStart
= fCurrentGraphNode
;
1418 if (event
.character
== ' ') {
1419 performSelection(fCurrentGraphNode
);
1420 if (!fShiftSelection
)
1421 fListStart
= fCurrentGraphNode
;
1424 if ((fShiftSelection
) && (prevNode
!= getFocusNode())) {
1426 addSelection(fPrevList
);
1427 addSelection(fFrame
.getNodeList(fListStart
, getFocusNode()));
1428 if (getFocusNode() instanceof Lifeline
) {
1429 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1431 ensureVisible(getFocusNode());
1433 } else if ((!fCtrlSelection
) && (!fShiftSelection
)) {
1436 if (getFocusNode() != null) {
1437 addSelection(getFocusNode());
1439 if (getFocusNode() instanceof Lifeline
) {
1440 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT
.CENTER
| SWT
.VERTICAL
, true);
1442 ensureVisible(getFocusNode());
1447 if (fCurrentGraphNode
!= null) {
1448 fCurrentGraphNode
.setFocused(true);
1452 if ((event
.character
== ' ') && ((fZoomInMode
) || (fZoomOutMode
))) {
1453 int cx
= Math
.round((getContentsX() + getVisibleWidth() / 2) / fZoomValue
);
1454 int cy
= Math
.round((getContentsY() + getVisibleHeight() / 2) / fZoomValue
);
1456 if (fZoomValue
< 64) {
1457 fZoomValue
= fZoomValue
* (float) 1.25;
1460 fZoomValue
= fZoomValue
/ (float) 1.25;
1462 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1463 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1464 setContentsPos(x
, y
);
1465 if (fTimeBar
!= null) {
1466 fTimeBar
.setZoom(fZoomValue
);
1468 // redraw also resize the scrollView content
1475 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
1478 protected void keyReleasedEvent(KeyEvent event
) {
1480 if (event
.keyCode
== SWT
.CTRL
)
1481 fCtrlSelection
= false;
1482 if (event
.keyCode
== SWT
.SHIFT
)
1483 fShiftSelection
= false;
1484 super.keyReleasedEvent(event
);
1490 * @see org.eclipse.swt.widgets.Control#isFocusControl()
1493 public boolean isFocusControl() {
1494 Control
[] child
= getChildren();
1495 for (int i
= 0; i
< child
.length
; i
++) {
1496 if (child
[i
].isFocusControl()) {
1499 checkFocusOnChilds(child
[i
]);
1507 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#setContentsPos(int, int)
1510 public boolean setContentsPos(int x
, int y
) {
1520 if (fFrame
== null) {
1523 if (localX
+ getVisibleWidth() > getContentsWidth()) {
1524 localX
= getContentsWidth() - getVisibleWidth();
1526 if (localY
+ getVisibleHeight() > getContentsHeight()) {
1527 localY
= getContentsHeight() - getVisibleHeight();
1529 int x1
= Math
.round(localX
/ fZoomValue
);
1530 int y2
= Math
.round(localY
/ fZoomValue
);
1531 int width
= Math
.round(getVisibleWidth() / fZoomValue
);
1532 int height
= Math
.round(getVisibleHeight() / fZoomValue
);
1533 fFrame
.updateIndex(x1
, y2
, width
, height
);
1535 if (fInsertionCartet
!= null && fInsertionCartet
.isVisible()) {
1536 fInsertionCartet
.setVisible(false);
1539 return super.setContentsPos(localX
, localY
);
1544 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
1547 protected void contentsMouseHover(MouseEvent event
) {
1548 GraphNode graphNode
= null;
1549 if (fFrame
!= null) {
1550 int x
= Math
.round(event
.x
/ fZoomValue
);
1551 int y
= Math
.round(event
.y
/ fZoomValue
);
1552 graphNode
= fFrame
.getNodeAt(x
, y
);
1553 if ((graphNode
!= null) && (SDViewPref
.getInstance().tooltipEnabled())) {
1554 fToolTipNode
= graphNode
;
1555 String postfix
= getPostfixForTooltip(true);
1556 if (graphNode
instanceof Lifeline
) {
1557 Lifeline lifeline
= (Lifeline
) graphNode
;
1558 fToolTip
.showToolTip(lifeline
.getToolTipText() + postfix
);
1561 fToolTip
.showToolTip(graphNode
.getName() + postfix
);
1565 fToolTip
.hideToolTip();
1572 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
1575 protected void contentsMouseMoveEvent(MouseEvent e
) {
1576 fScrollToolTip
.hideToolTip();
1577 fToolTip
.hideToolTip();
1578 // super.contentsMouseMoveEvent(e);
1579 if (!(isFocusControl() || getViewControl().isFocusControl())) {
1580 Control
[] child
= getParent().getChildren();
1581 for (int i
= 0; i
< child
.length
; i
++) {
1582 if ((child
[i
].isFocusControl()) && (!(child
[i
] instanceof ScrollView
))) {
1583 getViewControl().setFocus();
1590 if (((e
.stateMask
& SWT
.BUTTON_MASK
) != 0) && ((fDragAndDrop
!= null) || fIsDragAndDrop
) && (fReorderMode
|| fCollapseProvider
!= null)) {
1591 fIsDragAndDrop
= false;
1592 if (fCurrentGraphNode
instanceof Lifeline
) {
1593 fDragAndDrop
= (Lifeline
) fCurrentGraphNode
;
1595 if (fDragAndDrop
!= null) {
1598 if (e
.x
> getContentsX() + getVisibleWidth()) {
1599 dx
= e
.x
- (getContentsX() + getVisibleWidth());
1600 } else if (e
.x
< getContentsX()) {
1601 dx
= -getContentsX() + e
.x
;
1603 if (e
.y
> getContentsY() + getVisibleHeight()) {
1604 dy
= e
.y
- (getContentsY() + getVisibleHeight());
1605 } else if (e
.y
< getContentsY()) {
1606 dy
= -getContentsY() + e
.y
;
1610 if (dx
!= 0 || dy
!= 0) {
1611 if (fLocalAutoScroll
== null) {
1612 if (fLocalAutoScrollTimer
== null) {
1613 fLocalAutoScrollTimer
= new Timer(true);
1615 fLocalAutoScroll
= new AutoScroll(this, dx
, dy
);
1616 fLocalAutoScrollTimer
.schedule(fLocalAutoScroll
, 0, 75);
1618 fLocalAutoScroll
.fDeltaX
= dx
;
1619 fLocalAutoScroll
.fDeltaY
= dy
;
1621 } else if (fLocalAutoScroll
!= null) {
1622 fLocalAutoScroll
.cancel();
1623 fLocalAutoScroll
= null;
1625 fDragX
= Math
.round(e
.x
/ fZoomValue
);
1626 fDragY
= Math
.round(e
.y
/ fZoomValue
);
1628 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1629 if ((node
!= null) && (node
!= fDragAndDrop
)) {
1632 int height
= Metrics
.getLifelineHeaderFontHeigth() + 2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
;
1633 int hMargin
= Metrics
.LIFELINE_VT_MAGIN
/ 4;
1634 int x
= node
.getX();
1635 int width
= node
.getWidth();
1636 if (fFrame
.getVisibleAreaY() < node
.getY() + node
.getHeight() - height
- hMargin
) {
1637 y
= contentsToViewY(Math
.round((node
.getY() + node
.getHeight()) * fZoomValue
));
1639 y
= Math
.round(height
* fZoomValue
);
1642 if (fFrame
.getVisibleAreaY() < contentsToViewY(node
.getY() - hMargin
)) {
1643 y1
= contentsToViewY(Math
.round((node
.getY() - hMargin
) * fZoomValue
));
1645 y1
= Math
.round(height
* fZoomValue
);
1648 int rx
= Math
.round(x
* fZoomValue
);
1650 fInsertionCartet
.setVisible(true);
1651 if ((fInsertionCartet
.getImage() != null) && (!fInsertionCartet
.getImage().isDisposed())) {
1652 fInsertionCartet
.getImage().dispose();
1654 if (rx
<= e
.x
&& Math
.round(rx
+ (width
* fZoomValue
)) >= e
.x
) {
1655 if (fCollapseProvider
!= null) {
1656 ImageData data
= fCollapaseCaretImg
.getImageData();
1657 data
= data
.scaledTo(Math
.round(fCollapaseCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fCollapaseCaretImg
.getBounds().height
* fZoomValue
));
1658 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1659 fInsertionCartet
.setImage(fCurrentCaretImage
);
1660 fInsertionCartet
.setLocation(contentsToViewX(rx
+ Math
.round((width
/ (float) 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y
);
1662 } else if (fReorderMode
) {
1664 if (node
.getIndex() > 1 && fFrame
.getLifeline(node
.getIndex() - 2) == fDragAndDrop
) {
1667 ImageData data
= fArrowUpCaretImg
.getImageData();
1668 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1669 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1670 fInsertionCartet
.setImage(fCurrentCaretImage
);
1671 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
- Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2, y1
);
1673 if (node
.getIndex() < fFrame
.lifeLinesCount() && fFrame
.getLifeline(node
.getIndex()) == fDragAndDrop
) {
1676 ImageData data
= fArrowUpCaretImg
.getImageData();
1677 data
= data
.scaledTo(Math
.round(fArrowUpCaretImg
.getBounds().width
* fZoomValue
), Math
.round(fArrowUpCaretImg
.getBounds().height
* fZoomValue
));
1678 fCurrentCaretImage
= new Image(Display
.getCurrent(), data
);
1679 fInsertionCartet
.setImage(fCurrentCaretImage
);
1680 fInsertionCartet
.setLocation(contentsToViewX(Math
.round((x
+ width
+ Metrics
.LIFELINE_SPACING
/ 2) * fZoomValue
)) - fCurrentCaretImage
.getBounds().width
/ 2 + 1, y1
);
1684 fInsertionCartet
.setVisible(false);
1688 super.contentsMouseMoveEvent(e
);
1694 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
1697 protected void contentsMouseUpEvent(MouseEvent event
) {
1698 // Just in case the diagram highlight a time compression region
1699 // this region need to be released when clicking everywhere
1700 fInsertionCartet
.setVisible(false);
1701 if (fDragAndDrop
!= null) {
1702 if ((fOverView
!= null) && (!fOverView
.isDisposed())) {
1703 fOverView
.dispose();
1706 Lifeline node
= fFrame
.getCloserLifeline(fDragX
);
1708 int rx
= Math
.round(node
.getX() * fZoomValue
);
1709 if (rx
<= event
.x
&& Math
.round(rx
+ (node
.getWidth() * fZoomValue
)) >= event
.x
) {
1710 if ((fCollapseProvider
!= null) && (fDragAndDrop
!= node
)) {
1711 fCollapseProvider
.collapseTwoLifelines((Lifeline
) fDragAndDrop
, node
);
1713 } else if (rx
< event
.x
) {
1714 fFrame
.insertLifelineAfter((Lifeline
) fDragAndDrop
, node
);
1715 if (node
.getIndex() < fFrame
.lifeLinesCount()) {
1716 Lifeline temp
[] = { (Lifeline
) fDragAndDrop
, fFrame
.getLifeline(node
.getIndex()) };
1717 fReorderList
.add(temp
);
1719 Lifeline temp
[] = { (Lifeline
) fDragAndDrop
, null };
1720 fReorderList
.add(temp
);
1723 fFrame
.insertLifelineBefore((Lifeline
) fDragAndDrop
, node
);
1724 Lifeline temp
[] = { (Lifeline
) fDragAndDrop
, node
};
1725 fReorderList
.add(temp
);
1729 fDragAndDrop
= null;
1731 if (fFrame
== null) {
1734 fFrame
.resetTimeCompression();
1736 // reset auto scroll if it's engaged
1737 if (fLocalAutoScroll
!= null) {
1738 fLocalAutoScroll
.cancel();
1739 fLocalAutoScroll
= null;
1741 super.contentsMouseUpEvent(event
);
1746 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseDownEvent(org.eclipse.swt.events.MouseEvent)
1749 protected void contentsMouseDownEvent(MouseEvent event
) {
1750 if (fCurrentGraphNode
!= null) {
1751 fCurrentGraphNode
.setFocused(false);
1754 // Just in case the diagram highlight a time compression region
1755 // this region need to be released when clicking everywhere
1756 if (fFrame
== null) {
1760 fFrame
.resetTimeCompression();
1762 if ((event
.stateMask
& SWT
.CTRL
) != 0) {
1763 fCtrlSelection
= true;
1765 fCtrlSelection
= false;
1768 if (((fZoomInMode
) || (fZoomOutMode
)) && (event
.button
== 1)) {
1769 int cx
= Math
.round(event
.x
/ fZoomValue
);
1770 int cy
= Math
.round(event
.y
/ fZoomValue
);
1772 if (fZoomValue
< 64) {
1773 fZoomValue
= fZoomValue
* (float) 1.25;
1776 fZoomValue
= fZoomValue
/ (float) 1.25;
1778 int x
= Math
.round(cx
* fZoomValue
- getVisibleWidth() / (float) 2);
1779 int y
= Math
.round(cy
* fZoomValue
- getVisibleHeight() / (float) 2);
1780 setContentsPos(x
, y
);
1781 if (fTimeBar
!= null) {
1782 fTimeBar
.setZoom(fZoomValue
);
1784 // redraw also resize the scrollView content
1786 } else {// if (event.button ==1)
1787 GraphNode node
= null;
1788 int x
= Math
.round(event
.x
/ fZoomValue
);
1789 int y
= Math
.round(event
.y
/ fZoomValue
);
1790 node
= fFrame
.getNodeAt(x
, y
);
1792 if ((event
.button
== 1) || ((node
!= null) && !node
.isSelected())) {
1793 if (!fShiftSelection
) {
1796 if (fShiftSelection
) {
1798 addSelection(fFrame
.getNodeList(fListStart
, node
));
1800 performSelection(node
);
1802 fCurrentGraphNode
= node
;
1804 node
.setFocused(true);
1809 if (fDragAndDrop
== null) {
1810 super.contentsMouseDownEvent(event
);
1812 fIsDragAndDrop
= (event
.button
== 1);
1817 * TimerTask for auto scroll feature.
1819 protected static class AutoScroll
extends TimerTask
{
1829 * Field sequence diagram reference.
1831 public SDWidget fSdWidget
;
1834 * Constructor for AutoScroll.
1835 * @param sv sequence diagram widget reference
1839 public AutoScroll(SDWidget sv
, int dx
, int dy
) {
1847 * @see java.util.TimerTask#run()
1851 Display
.getDefault().asyncExec(new Runnable() {
1854 if (fSdWidget
.isDisposed())
1856 fSdWidget
.fDragX
+= fDeltaX
;
1857 fSdWidget
.fDragY
+= fDeltaY
;
1858 fSdWidget
.scrollBy(fDeltaX
, fDeltaY
);
1866 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
1869 protected void drawContents(GC gc
, int clipx
, int clipy
, int clipw
, int cliph
) {
1870 if (fFrame
== null) {
1871 gc
.setBackground(getDisplay().getSystemColor(SWT
.COLOR_WHITE
));
1872 gc
.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
1876 // Frame.setUserPref(SDViewPref.getInstance());
1877 SDViewPref
.getInstance();
1880 Rectangle area
= getClientArea();
1881 Image dbuffer
= getDrawBuffer();
1882 int height
= Math
.round((fFrame
.getHeight() + 2 * Metrics
.FRAME_V_MARGIN
) * fZoomValue
);
1885 gc
.drawImage(dbuffer
, 0, 0, area
.width
, area
.height
, 0, 0, area
.width
, area
.height
);
1886 } catch (Exception e
) {
1887 TmfUiPlugin
.getDefault().getLog().log(new Status(IStatus
.ERROR
,TmfUiPlugin
.PLUGIN_ID
, "Error drawin content", e
)); //$NON-NLS-1$
1890 setHScrollBarIncrement(Math
.round(SDViewPref
.getInstance().getLifelineWidth() / (float) 2 * fZoomValue
));
1891 setVScrollBarIncrement(Math
.round(Metrics
.getMessagesSpacing() * fZoomValue
));
1892 if ((fTimeBar
!= null) && (fFrame
.hasTimeInfo())) {
1893 fTimeBar
.resizeContents(9, height
+ getHorizontalBarHeight());
1894 fTimeBar
.setContentsPos(getContentsX(), getContentsY());
1898 float xRatio
= getContentsWidth() / (float) getVisibleWidth();
1899 float yRatio
= getContentsHeight() / (float) getVisibleHeight();
1900 if (yRatio
> xRatio
) {
1901 setOverviewSize((int) (getVisibleHeight() * 0.75));
1903 setOverviewSize((int) (getVisibleWidth() * 0.75));
1909 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
1912 public void widgetDefaultSelected(SelectionEvent event
) {
1917 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
1920 public void widgetSelected(SelectionEvent event
) {
1921 if (event
.widget
== fZoomIn
) {
1922 fZoomValue
= fZoomValue
* 2;
1923 } else if (event
.widget
== fZoomOut
) {
1924 fZoomValue
= fZoomValue
/ 2;
1930 * Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply button
1933 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
1936 public void propertyChange(PropertyChangeEvent e
) {
1937 if (fFrame
!= null && !isDisposed()) {
1938 fFrame
.resetTimeCompression();
1940 if (e
.getProperty().equals("PREFOK")) //$NON-NLS-1$
1942 // Prepare the overview to be reused for the new
1943 // settings (especially the colors)
1944 if (fOverView
!= null)
1945 fOverView
.dispose();
1953 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
1956 public void widgetDisposed(DisposeEvent e
) {
1957 if (fOverView
!= null) {
1958 fOverView
.dispose();
1960 super.removeDisposeListener(this);
1961 if ((fCurrentCaretImage
!= null) && (!fCurrentCaretImage
.isDisposed())) {
1962 fCurrentCaretImage
.dispose();
1964 if ((fArrowUpCaretImg
!= null) && (!fArrowUpCaretImg
.isDisposed())) {
1965 fArrowUpCaretImg
.dispose();
1967 if ((fCollapaseCaretImg
!= null) && (!fCollapaseCaretImg
.isDisposed())) {
1968 fCollapaseCaretImg
.dispose();
1970 SDViewPref
.getInstance().removePropertyChangeListener(this);
1971 LoadersManager lm
= LoadersManager
.getInstance();
1972 if (fSite
instanceof SDView
) {
1973 ((SDView
) fSite
).resetProviders();
1975 lm
.resetLoader(((SDView
) fSite
).getViewSite().getId());
1982 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawOverview(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle)
1985 protected void drawOverview(GC gc
, Rectangle r
) {
1986 float oldzoom
= fZoomValue
;
1987 if (getContentsWidth() > getContentsHeight()) {
1988 fZoomValue
= (float) r
.width
/ (float) getContentsWidth() * oldzoom
;
1990 fZoomValue
= (float) r
.height
/ (float) getContentsHeight() * oldzoom
;
1992 if ((fOverView
!= null) && ((r
.width
!= fOverView
.getBounds().width
) || (r
.height
!= fOverView
.getBounds().height
))) {
1993 fOverView
.dispose();
1996 if (fOverView
== null) {
1997 int backX
= getContentsX();
1998 int backY
= getContentsY();
1999 setContentsPos(0, 0);
2000 fOverView
= new Image(getDisplay(), r
.width
, r
.height
);
2001 GC gcim
= new GC(fOverView
);
2002 NGC context
= new NGC(this, gcim
);
2003 context
.setBackground(SDViewPref
.getInstance().getBackGroundColor(SDViewPref
.PREF_FRAME
));
2004 fFrame
.draw(context
);
2005 setContentsPos(backX
, backY
);
2009 if ((fOverView
!= null) && (r
.width
== fOverView
.getBounds().width
) && (r
.height
== fOverView
.getBounds().height
)) {
2010 gc
.drawImage(fOverView
, 0, 0, r
.width
, r
.height
, 0, 0, r
.width
, r
.height
);
2013 fZoomValue
= oldzoom
;
2015 super.drawOverview(gc
, r
);
2020 * @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)
2023 public void deltaSelected(Lifeline lifeline
, int startEvent
, int nbEvent
, IColor color
) {
2024 fFrame
.highlightTimeCompression(lifeline
, startEvent
, nbEvent
, color
);
2025 ensureVisible(lifeline
);
2026 int y1
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * startEvent
;
2027 int y2
= lifeline
.getY() + lifeline
.getHeight() + (Metrics
.getMessageFontHeigth() + Metrics
.getMessagesSpacing()) * (startEvent
+ nbEvent
);
2028 ensureVisible(lifeline
.getX(), y1
- (Metrics
.getLifelineHeaderFontHeigth() + +2 * Metrics
.LIFELINE_HEARDER_TEXT_V_MARGIN
), lifeline
.getWidth(), y2
- y1
+ 3, SWT
.CENTER
| SWT
.VERTICAL
, true);
2035 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleWidth()
2038 public int getVisibleWidth() {
2040 return fPrinter
.getClientArea().width
;
2042 return super.getVisibleWidth();
2047 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleHeight()
2050 public int getVisibleHeight() {
2052 return fPrinter
.getClientArea().height
;
2054 return super.getVisibleHeight();
2059 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewX(int)
2062 public int contentsToViewX(int x
) {
2064 int v
= Math
.round(fPrinterX
* fPrinterZoom
);
2067 return x
- getContentsX();
2072 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewY(int)
2075 public int contentsToViewY(int y
) {
2077 int v
= Math
.round(fPrinterY
* fPrinterZoom
);
2080 return y
- getContentsY();
2085 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsX()
2088 public int getContentsX() {
2090 return Math
.round(fPrinterX
* fPrinterZoom
);
2092 return super.getContentsX();
2098 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsY()
2101 public int getContentsY() {
2103 return Math
.round(fPrinterY
* fPrinterZoom
);
2105 return super.getContentsY();
2109 * Traverse Listener implementation.
2111 protected static class LocalTraverseListener
implements TraverseListener
{
2115 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
2118 public void keyTraversed(TraverseEvent e
) {
2119 if ((e
.detail
== SWT
.TRAVERSE_TAB_NEXT
) || (e
.detail
== SWT
.TRAVERSE_TAB_PREVIOUS
)) {