From df0b8ff4ecb4993ab5757aad847025fe2fa42c2c Mon Sep 17 00:00:00 2001
From: Bernd Hufmann
Date: Wed, 2 May 2012 11:01:46 -0400
Subject: [PATCH] Java Doc and API clean up of TMF UML Sequence diagram
framework
---
.../uml2sd/ITmfAsyncSequenceDiagramEvent.java | 12 +-
.../uml2sd/ITmfSyncSequenceDiagramEvent.java | 16 +
.../uml2sd/TmfAsyncSequenceDiagramEvent.java | 23 +-
.../uml2sd/TmfSyncSequenceDiagramEvent.java | 36 +-
.../plugin.xml | 2 +-
.../tmf/ui/tests/AllTmfUITests.java | 6 +-
.../widgets => dialogs}/AllTests.java | 4 +-
.../widgets => dialogs}/CriteriaTest.java | 6 +-
.../views/uml2sd/load/LoadersManagerTest.java | 2 +-
.../uml2sd/{impl => loader}/AllTests.java | 4 +-
.../IUml2SDTestConstants.java | 4 +-
.../IUml2SdSignalValidator.java | 4 +-
.../TmfUml2SDSyncLoaderExpTest.java | 10 +-
.../TmfUml2SDSyncLoaderFilterTest.java | 10 +-
.../TmfUml2SDSyncLoaderFindTest.java | 8 +-
.../TmfUml2SDSyncLoaderPagesTest.java | 4 +-
.../TmfUml2SDSyncLoaderSignalTest.java | 4 +-
.../TmfUml2SDSyncLoaderTimeTest.java | 6 +-
.../Uml2SDSignalValidator.java | 4 +-
.../{impl => loader}/Uml2SDTestFacility.java | 14 +-
.../{impl => loader}/Uml2SDTestSetup.java | 4 +-
.../{impl => loader}/Uml2SDTestTimestamp.java | 4 +-
.../tmf/ui/tests/uml2sd/load/TestLoaders.java | 8 +-
.../META-INF/MANIFEST.MF | 6 +-
org.eclipse.linuxtools.tmf.ui/plugin.xml | 2 +-
.../tmf/ui/views/uml2sd/DiagramToolTip.java | 42 +-
.../tmf/ui/views/uml2sd/DrawableToolTip.java | 225 +-
.../uml2sd/ITimeCompressionListener.java | 18 +-
.../linuxtools/tmf/ui/views/uml2sd/NGC.java | 455 ++-
.../tmf/ui/views/uml2sd/SDView.java | 200 +-
.../tmf/ui/views/uml2sd/SDWidget.java | 2711 ++++++++++-------
.../uml2sd/SDWidgetSelectionProvider.java | 52 +-
.../tmf/ui/views/uml2sd/ScrollView.java | 488 ++-
.../ui/views/uml2sd/TimeCompressionBar.java | 440 ++-
.../ui/views/uml2sd/core/AsyncMessage.java | 199 +-
.../views/uml2sd/core/AsyncMessageReturn.java | 45 +-
.../tmf/ui/views/uml2sd/core/BaseMessage.java | 179 +-
.../uml2sd/core/BasicExecutionOccurrence.java | 118 +-
.../tmf/ui/views/uml2sd/core/BasicFrame.java | 199 +-
...sisisMessage.java => EllipsisMessage.java} | 50 +-
.../uml2sd/core/ExecutionOccurrence.java | 120 +-
.../tmf/ui/views/uml2sd/core/Frame.java | 633 ++--
.../tmf/ui/views/uml2sd/core/GraphNode.java | 173 +-
.../tmf/ui/views/uml2sd/core/HotSpot.java | 113 +-
.../tmf/ui/views/uml2sd/core/ITimeRange.java | 22 +-
.../tmf/ui/views/uml2sd/core/Lifeline.java | 183 +-
.../views/uml2sd/core/LifelineCategories.java | 42 +-
.../tmf/ui/views/uml2sd/core/Metrics.java | 92 +-
.../tmf/ui/views/uml2sd/core/SDTimeEvent.java | 49 +-
.../tmf/ui/views/uml2sd/core/Stop.java | 71 +-
.../tmf/ui/views/uml2sd/core/SyncMessage.java | 107 +-
.../views/uml2sd/core/SyncMessageReturn.java | 44 +-
.../widgets => dialogs}/Criteria.java | 125 +-
.../widgets => dialogs}/FilterCriteria.java | 155 +-
.../widgets => dialogs}/FilterListDialog.java | 276 +-
.../{util => dialogs}/MinMaxDialog.java | 102 +-
.../widgets => dialogs}/PagesDialog.java | 191 +-
.../{util => dialogs}/SDPrintDialog.java | 94 +-
.../{util => dialogs}/SDPrintDialogUI.java | 640 +++-
.../SearchFilterDialog.java | 142 +-
.../widgets => dialogs}/TabContents.java | 246 +-
.../tmf/ui/views/uml2sd/drawings/IColor.java | 8 +-
.../tmf/ui/views/uml2sd/drawings/IFont.java | 8 +-
.../tmf/ui/views/uml2sd/drawings/IGC.java | 13 +-
.../tmf/ui/views/uml2sd/drawings/IImage.java | 8 +-
.../views/uml2sd/drawings/impl/ColorImpl.java | 56 +-
.../views/uml2sd/drawings/impl/FontImpl.java | 62 +-
.../views/uml2sd/drawings/impl/ImageImpl.java | 54 +-
.../uml2sd/handlers/ConfigureMinMax.java | 37 +-
.../ui/views/uml2sd/handlers/FirstPage.java | 27 +-
.../uml2sd/handlers/KeyBindingsManager.java | 76 +-
.../ui/views/uml2sd/handlers/LastPage.java | 27 +-
.../ui/views/uml2sd/handlers/MoveSDDown.java | 31 +-
.../ui/views/uml2sd/handlers/MoveSDLeft.java | 33 +-
.../ui/views/uml2sd/handlers/MoveSDRight.java | 39 +-
.../ui/views/uml2sd/handlers/MoveSDUp.java | 29 +-
.../views/uml2sd/handlers/MoveToMessage.java | 36 +-
.../ui/views/uml2sd/handlers/NextPage.java | 24 +-
.../uml2sd/handlers/OpenSDFiltersDialog.java | 35 +-
.../uml2sd/handlers/OpenSDFindDialog.java | 46 +-
.../uml2sd/handlers/OpenSDPagesDialog.java | 29 +-
.../ui/views/uml2sd/handlers/PrevPage.java | 29 +-
.../tmf/ui/views/uml2sd/handlers/Print.java | 37 +-
.../ui/views/uml2sd/handlers/ShowNodeEnd.java | 57 +-
.../views/uml2sd/handlers/ShowNodeStart.java | 44 +-
.../tmf/ui/views/uml2sd/handlers/Zoom.java | 56 +-
.../provider/IExtendedFilterProvider.java | 17 +-
.../provider/IExtendedFindProvider.java | 20 +-
.../provider/ISDAdvancedPagingProvider.java | 18 +-
.../provider/ISDCollapseProvider.java | 10 +-
.../ISDExtendedActionBarProvider.java | 9 +-
.../handlers/provider/ISDFilterProvider.java | 12 +-
.../handlers/provider/ISDFindProvider.java | 16 +-
.../provider/ISDGraphNodeSupporter.java | 38 +-
.../handlers/provider/ISDPagingProvider.java | 12 +-
.../provider/ISDPropertiesProvider.java | 13 +-
.../ui/views/uml2sd/load/IUml2SDLoader.java | 14 +-
.../ui/views/uml2sd/load/LoadersManager.java | 51 +-
.../uml2sd/{impl => loader}/Messages.java | 6 +-
.../{impl => loader}/TmfAsyncMessage.java | 25 +-
.../{impl => loader}/TmfSyncMessage.java | 29 +-
.../{impl => loader}/TmfUml2SDSyncLoader.java | 216 +-
.../{impl => loader}/messages.properties | 11 +
.../ISDPreferences.java | 30 +-
.../views/uml2sd/preferences/SDViewPref.java | 234 +-
.../uml2sd/preferences/SDViewerPage.java | 100 +-
.../tmf/ui/views/uml2sd/util/SDMessages.java | 4 +-
.../uml2sd/util/SortAsyncForBackward.java | 61 +-
.../util/SortAsyncMessageComparator.java | 56 +-
.../util/SortSyncMessageComparator.java | 27 +-
.../uml2sd/util/TimeEventComparator.java | 30 +-
.../ui/views/uml2sd/util/messages.properties | 5 +-
112 files changed, 7876 insertions(+), 3333 deletions(-)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{handlers/widgets => dialogs}/AllTests.java (88%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{handlers/widgets => dialogs}/CriteriaTest.java (98%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/AllTests.java (91%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/IUml2SDTestConstants.java (93%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/IUml2SdSignalValidator.java (93%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/TmfUml2SDSyncLoaderExpTest.java (95%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/TmfUml2SDSyncLoaderFilterTest.java (95%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/TmfUml2SDSyncLoaderFindTest.java (98%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/TmfUml2SDSyncLoaderPagesTest.java (98%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/TmfUml2SDSyncLoaderSignalTest.java (98%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/TmfUml2SDSyncLoaderTimeTest.java (98%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/Uml2SDSignalValidator.java (98%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/Uml2SDTestFacility.java (95%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/Uml2SDTestSetup.java (91%)
rename org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/{impl => loader}/Uml2SDTestTimestamp.java (92%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/{EllipsisisMessage.java => EllipsisMessage.java} (80%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{handlers/widgets => dialogs}/Criteria.java (77%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{handlers/widgets => dialogs}/FilterCriteria.java (58%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{handlers/widgets => dialogs}/FilterListDialog.java (74%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{util => dialogs}/MinMaxDialog.java (68%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{handlers/widgets => dialogs}/PagesDialog.java (65%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{util => dialogs}/SDPrintDialog.java (58%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{util => dialogs}/SDPrintDialogUI.java (73%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{handlers/widgets => dialogs}/SearchFilterDialog.java (79%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{handlers/widgets => dialogs}/TabContents.java (77%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{impl => loader}/Messages.java (90%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{impl => loader}/TmfAsyncMessage.java (83%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{impl => loader}/TmfSyncMessage.java (80%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{impl => loader}/TmfUml2SDSyncLoader.java (89%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{impl => loader}/messages.properties (50%)
rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/{drawings => preferences}/ISDPreferences.java (84%)
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfAsyncSequenceDiagramEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfAsyncSequenceDiagramEvent.java
index b42ac070d8..cede55c9eb 100644
--- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfAsyncSequenceDiagramEvent.java
+++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfAsyncSequenceDiagramEvent.java
@@ -13,9 +13,19 @@ package org.eclipse.linuxtools.tmf.core.uml2sd;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+/**
+ *
+ * Interface for asynchronous sequence diagram events.
+ *
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
+ */
public interface ITmfAsyncSequenceDiagramEvent extends ITmfSyncSequenceDiagramEvent {
/**
- * @return End timestamp of message (i.e. receive time)
+ * Returns end timestamp of message (i.e. receive time)
+ *
+ * @return end timestamp of message (i.e. receive time)
*/
public ITmfTimestamp getEndTime();
}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfSyncSequenceDiagramEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfSyncSequenceDiagramEvent.java
index e655888cda..20f595c235 100644
--- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfSyncSequenceDiagramEvent.java
+++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/ITmfSyncSequenceDiagramEvent.java
@@ -13,24 +13,40 @@ package org.eclipse.linuxtools.tmf.core.uml2sd;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+/**
+ *
+ * Interface for synchronous sequence diagram events.
+ *
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
+ */
public interface ITmfSyncSequenceDiagramEvent {
/**
+ * Returns Name of message.
+ *
* @return Name of message
*/
public String getName();
/**
+ * Returns name of sender of message.
+ *
* @return name of sender of message
*/
public String getSender();
/**
+ * Returns Name of receiver of message.
+ *
* @return Name of receiver of message
*/
public String getReceiver();
/**
+ * Returns Start time of message (i.e. send time).
+ *
* @return Start timestamp of message (i.e. send time)
*/
public ITmfTimestamp getStartTime();
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfAsyncSequenceDiagramEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfAsyncSequenceDiagramEvent.java
index 40aefc9439..1b995e24d2 100644
--- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfAsyncSequenceDiagramEvent.java
+++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfAsyncSequenceDiagramEvent.java
@@ -15,22 +15,35 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
/**
- * TmfAsyncSequenceDiagramEvent
*
- * Sample implementation of the ITmfAsyncSequenceDiagramEvent
+ * A basic implementation of ITmfAsyncSequenceDiagramEvent.
*
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
*/
public class TmfAsyncSequenceDiagramEvent extends TmfSyncSequenceDiagramEvent implements ITmfAsyncSequenceDiagramEvent {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
-
+ /**
+ * The end time of the sequence diagram event (i.e. time when signal was received).
+ */
final protected ITmfTimestamp fEndTime;
// ------------------------------------------------------------------------
// Constructors
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param startEvent The start event (on sender side).
+ * @param endEvent The end event (receiver side).
+ * @param sender The name of sender of signal.
+ * @param receiver The Name of receiver of signal.
+ * @param name - The signal name
+ */
public TmfAsyncSequenceDiagramEvent(ITmfEvent startEvent, ITmfEvent endEvent, String sender, String receiver, String name) {
super(startEvent, sender, receiver, name);
@@ -46,7 +59,7 @@ public class TmfAsyncSequenceDiagramEvent extends TmfSyncSequenceDiagramEvent im
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.uml2sd.ITmfAsyncSequenceDiagramEvent#getEndTime()
+ * @see org.eclipse.linuxtools.tmf.core.uml2sd.ITmfAsyncSequenceDiagramEvent#getEndTime()
*/
@Override
public ITmfTimestamp getEndTime() {
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfSyncSequenceDiagramEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfSyncSequenceDiagramEvent.java
index c6b17b0450..bbb068bed6 100644
--- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfSyncSequenceDiagramEvent.java
+++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/uml2sd/TmfSyncSequenceDiagramEvent.java
@@ -15,24 +15,46 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
/**
- * TmfSyncSequenceDiagramEvent
*
- * Sample implementation of the ITmfSyncSequenceDiagramEvent
+ * A basic implementation of ITmfSyncSequenceDiagramEvent.
*
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
*/
public class TmfSyncSequenceDiagramEvent implements ITmfSyncSequenceDiagramEvent {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
+ /**
+ * The start time of the sequence diagram event (i.e. time when signal was sent).
+ */
final protected ITmfTimestamp fStartTime;
+ /**
+ * The name of the sender of the signal.
+ */
final protected String fSender;
+ /**
+ * The name of the receiver of the signal.
+ */
final protected String fReceiver;
+ /**
+ * The name of the signal
+ */
final protected String fName;
// ------------------------------------------------------------------------
// Constructors
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param startEvent The start event (on sender side).
+ * @param sender The name of sender of signal.
+ * @param receiver The Name of receiver of signal.
+ * @param name - The signal name
+ */
public TmfSyncSequenceDiagramEvent(ITmfEvent startEvent, String sender, String receiver, String name) {
if ((startEvent == null) || (sender == null) || (receiver == null) || (name == null)) {
@@ -56,7 +78,7 @@ public class TmfSyncSequenceDiagramEvent implements ITmfSyncSequenceDiagramEvent
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.uml2sd.ITmfSyncSequenceDiagramEvent#getSender()
+ * @see org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent#getSender()
*/
@Override
public String getSender() {
@@ -65,7 +87,7 @@ public class TmfSyncSequenceDiagramEvent implements ITmfSyncSequenceDiagramEvent
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.uml2sd.ITmfSyncSequenceDiagramEvent#getReceiver()
+ * @see org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent#getReceiver()
*/
@Override
public String getReceiver() {
@@ -74,7 +96,7 @@ public class TmfSyncSequenceDiagramEvent implements ITmfSyncSequenceDiagramEvent
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.uml2sd.ITmfSyncSequenceDiagramEvent#getName()
+ * @see org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent#getName()
*/
@Override
public String getName() {
@@ -83,7 +105,7 @@ public class TmfSyncSequenceDiagramEvent implements ITmfSyncSequenceDiagramEvent
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.uml2sd.ITmfSyncSequenceDiagramEvent#getStartTime()
+ * @see org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent#getStartTime()
*/
@Override
public ITmfTimestamp getStartTime() {
diff --git a/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml b/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml
index 33f04cedb5..d7805e67ff 100644
--- a/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml
+++ b/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml
@@ -48,7 +48,7 @@
* This class is used to reproduce the same tooltip behavior on Windows and Linux when the mouse hovers over the
* sequence diagram
+ *
*
+ * @version 1.0
* @author sveyrier
*/
public class DiagramToolTip {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
/**
- * The parent control where the tooltip must be drawn
+ * The parent control where the tooltip must be drawn.
*/
protected Control parent = null;
/**
- * The tooltip shell
+ * The tooltip shell.
*/
protected Shell toolTipShell = null;
/**
- * The tooltip text
+ * The tooltip text.
*/
protected String text = null;
+ /**
+ * The text box.
+ */
protected Text textBox = null;
- // added for defect 141750 in order to allow proper text wrapping of the toolTip
- // E. Dancy
-
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
* Create a new tooltip for the given parent control
*
- * @param _parent the parent control
+ * @param _parent the parent control.
*/
public DiagramToolTip(Control _parent) {
parent = _parent;
@@ -59,14 +70,17 @@ public class DiagramToolTip {
textBox.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
* Display the tooltip using the given text The tooltip will stay on screen until it is told otherwise
*
* @param value the text to display
*/
public void showToolTip(String value) {
- if ((value == null) || (value.equalsIgnoreCase("")))//$NON-NLS-1$
- {
+ if ((value == null) || (value.equalsIgnoreCase(""))) { //$NON-NLS-1$
toolTipShell.setVisible(false);
return;
}
@@ -76,13 +90,15 @@ public class DiagramToolTip {
Point hr = Display.getDefault().getCursorLocation();
int cursorH = 32;
for (int i = 0; i < Display.getDefault().getCursorSizes().length; i++) {
- if (Display.getDefault().getCursorSizes()[i].y < cursorH)
+ if (Display.getDefault().getCursorSizes()[i].y < cursorH) {
cursorH = Display.getDefault().getCursorSizes()[i].y;
+ }
}
if (hr.x + w > Display.getDefault().getBounds().width) {
int tempX = (hr.x + w) - Display.getDefault().getBounds().width;
- if (tempX > Display.getDefault().getBounds().width)
+ if (tempX > Display.getDefault().getBounds().width) {
hr.x = 0;
+ }
hr.x = hr.x - tempX;
}
textBox.setText(value);
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java
index cf656fc1a5..01f92c7b66 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: DrawableToolTip.java,v 1.3 2008/01/24 02:29:01 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -27,15 +28,22 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
+ *
* This class is used to reproduce the same tooltip behavior on Windows and Linux when the mouse move hover the time
* compression bar used to display elapsed time using a tooltip. The tooltip is composed of 2 parts, the text value and
- * below, a scale to visually locate the value in a time range (usually the min an max elapsed time in the whole
+ * below, a scale to visually locate the value in a time range (usually the minimum an maximum elapsed time in the whole
* diagram)
+ *
*
+ * @version 1.0
* @author sveyrier
*/
public class DrawableToolTip implements PaintListener {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
* The parent control where the tooltip must be drawn
*/
@@ -45,24 +53,47 @@ public class DrawableToolTip implements PaintListener {
*/
protected Shell toolTipShell = null;
/**
- * Time range data
+ * The Time range data.
*/
protected TmfTimeRange minMaxRange;
+ /**
+ * The current time.
+ */
protected ITmfTimestamp currentValue;
-
+ /**
+ * The horizontal margin used for drawing.
+ */
private static int H_MARGIN = 10;
+ /**
+ * The vertical margin used for drawing.
+ */
private static int V_MARGIN = 10;
-
+ /**
+ * The minimum text scale margin.
+ */
private static int TEXT_SCALE_MARGIN = 20;
+ /**
+ * The length of the text scale.
+ */
private static int SCALE_LENGTH = 100;
-
+ /**
+ * The text to display
+ */
protected String msg;
-
/**
* The color array used to represent the 10 time range slices
*/
protected Color[] col;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Creates a drawable tool tip instance.
+ *
+ * @param _parent The parent composite.
+ */
public DrawableToolTip(Composite _parent) {
parent = _parent;
toolTipShell = new Shell(parent.getShell(), SWT.ON_TOP);
@@ -84,6 +115,98 @@ public class DrawableToolTip implements PaintListener {
col[9] = new Color(Display.getDefault(), 255, 0, 0);
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /**
+ * Returns the message to display.
+ *
+ * @return the message to display.
+ */
+ public String getText() {
+ return msg;
+ }
+
+ /**
+ * Returns teh current time to display.
+ *
+ * @return the current time to display
+ */
+ public String getAccessibleText() {
+ return currentValue.toString();
+ }
+
+ /**
+ * Returns the horizontal margin.
+ *
+ * @return the horizontal margin.
+ */
+ protected static int getHorizontalMargin() {
+ return H_MARGIN;
+ }
+
+ /**
+ * Sets the horizontal margin.
+ *
+ * @param margin The margin to set.
+ */
+ protected static void setHorizontalMargin(int margin) {
+ H_MARGIN = margin;
+ }
+
+ /**
+ * Returns the vertical margin.
+ *
+ * @return the vertical margin.
+ */
+ protected static int getVerticalMargin() {
+ return V_MARGIN;
+ }
+
+ /**
+ * Sets the vertical margin.
+ *
+ * @param margin The margin to set.
+ */
+ protected static void setVerticalMargin(int margin) {
+ V_MARGIN = margin;
+ }
+
+ /**
+ * Returns the text scale margin.
+ *
+ * @return the text scale margin.
+ */
+ protected static int getTextScaleMargin() {
+ return TEXT_SCALE_MARGIN;
+ }
+
+ /**
+ * Sets the text scale margin.
+ * @param textScaleMargin The margin to set.
+ */
+ protected static void setTestScaleMargin(int textScaleMargin) {
+ TEXT_SCALE_MARGIN = textScaleMargin;
+ }
+
+ /**
+ * Returns the scale length.
+ *
+ * @return the scale length.
+ */
+ protected static int getScaleLength() {
+ return SCALE_LENGTH;
+ }
+
+ /**
+ * Sets the scale length.
+ *
+ * @param scaleLength The scale length to set.
+ */
+ protected static void setScaleLength(int scaleLength) {
+ SCALE_LENGTH = scaleLength;
+ }
+
/**
* Display the tooltip using the given time range(min,max) the current value and the time unit The tooltip will stay
* on screen until it is told otherwise
@@ -104,21 +227,31 @@ public class DrawableToolTip implements PaintListener {
}
/**
- * Hide the tooltip
+ * Hide the tooltip.
*/
public void hideToolTip() {
toolTipShell.setVisible(false);
}
/**
- * Draw the tooltip text on the control widget when a paint event is received
+ * Disposes the system resource used by this kind of toolTips (a colors array essentially)
+ */
+ public void dispose() {
+ for (int i = 0; i < col.length; i++)
+ col[i].dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
*/
@Override
public void paintControl(PaintEvent event) {
msg = SDMessages._138 + " " + currentValue.toString(); //$NON-NLS-1$
Point size = event.gc.textExtent(msg);
- if (size.x < SCALE_LENGTH)
+ if (size.x < SCALE_LENGTH) {
size.x = SCALE_LENGTH;
+ }
event.gc.drawText(msg, H_MARGIN, V_MARGIN, true);
event.gc.drawLine(H_MARGIN, V_MARGIN + TEXT_SCALE_MARGIN + size.y, H_MARGIN + SCALE_LENGTH, V_MARGIN + TEXT_SCALE_MARGIN + size.y);
@@ -136,79 +269,35 @@ public class DrawableToolTip implements PaintListener {
if (gr != 0) {
// colIndex = Math.round((float)(Math.log(1+delta)/gr));
colIndex = Math.round((float) (absDelta / gr));
- if (colIndex > col.length)
+ if (colIndex > col.length) {
colIndex = col.length;
- else if (colIndex <= 1)
+ } else if (colIndex <= 1) {
colIndex = 1;
- } else
+ }
+ } else {
colIndex = 1;
+ }
for (int i = 0; i <= 10; i++) {
- if (i < 10)
+ if (i < 10) {
event.gc.setBackground(col[i]);
- if ((i < colIndex) && (i < 10))
+ }
+ if ((i < colIndex) && (i < 10)) {
event.gc.fillRectangle(H_MARGIN + i * step, V_MARGIN + TEXT_SCALE_MARGIN + size.y - 5, step, 11);
- if (i == 0)
+ }
+ if (i == 0) {
event.gc.drawText(SDMessages._56, H_MARGIN, size.y + 2 * V_MARGIN + TEXT_SCALE_MARGIN, true);
+ }
if (i == 0) {
int len = event.gc.textExtent(SDMessages._55).x;
event.gc.drawText(SDMessages._55, H_MARGIN + SCALE_LENGTH - len + 1, size.y + 2 * V_MARGIN + TEXT_SCALE_MARGIN, true);
}
int lineWidth = 10;
- if ((i == 0) || (i == 10))
+ if ((i == 0) || (i == 10)) {
lineWidth = 14;
+ }
event.gc.drawLine(H_MARGIN + i * step, V_MARGIN + TEXT_SCALE_MARGIN + size.y - lineWidth / 2, H_MARGIN + i * step, V_MARGIN + TEXT_SCALE_MARGIN + size.y + lineWidth / 2);
}
toolTipShell.setSize(size.x + 2 * H_MARGIN + 2, 2 * size.y + 3 * V_MARGIN + TEXT_SCALE_MARGIN);
}
-
- public String getText() {
- return msg;
- }
-
- public String getAccessibleText() {
- return currentValue.toString();
- }
-
- /**
- * Dispose the system resource used by this kind of toolTips (a colors array essentially)
- *
- */
- public void dispose() {
- for (int i = 0; i < col.length; i++)
- col[i].dispose();
- }
-
- protected static int getHorizontalMargin() {
- return H_MARGIN;
- }
-
- protected static void setHorizontalMargin(int margin) {
- H_MARGIN = margin;
- }
-
- protected static int getVerticalMargin() {
- return V_MARGIN;
- }
-
- protected static void setVerticalMargin(int margin) {
- V_MARGIN = margin;
- }
-
- protected static int getTestScaleMargin() {
- return TEXT_SCALE_MARGIN;
- }
-
- protected static void setTestScaleMargin(int testScaleMargin) {
- TEXT_SCALE_MARGIN = testScaleMargin;
- }
-
- protected static int getScaleLength() {
- return SCALE_LENGTH;
- }
-
- protected static void setScaleLength(int scaleLength) {
- SCALE_LENGTH = scaleLength;
- }
-
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ITimeCompressionListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ITimeCompressionListener.java
index 519da066f7..a8f4e4012b 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ITimeCompressionListener.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ITimeCompressionListener.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ITimeCompressionListener.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -16,11 +17,24 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
/**
+ *
+ * Listener interface for the time compression bar to notify about dela selection.
+ *
+ *
* @author sveyrier
+ * @version 1.0
*
*/
public interface ITimeCompressionListener {
+ /**
+ * Notifies listeners about a selected delta.
+ *
+ * @param lifeline The current lifeline.
+ * @param startEvent The start event selected.
+ * @param nbEvent A number of events.
+ * @param color The current color to use.
+ */
public void deltaSelected(Lifeline lifeline, int startEvent, int nbEvent, IColor color);
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java
index ee744a0910..ad27da2fb2 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/NGC.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: NGC.java,v 1.3 2008/01/24 02:29:01 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -30,87 +31,192 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
/**
- * @author sveyrier
+ *
+ * This class implements the graphical context for the sequence diagram widgets.
+ *
*
+ * @version 1.0
+ * @author sveyrier
*/
public class NGC implements IGC {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The graphical context.
+ */
protected GC context;
+ /**
+ * The reference to the sequence diagram view.
+ */
protected SDWidget view;
+ /**
+ * A reference to the last used font.
+ */
protected Font tempFont = null;
+ /**
+ * The color of the gradient.
+ */
protected IColor gradientColor = null;
+ /**
+ * The color of the background.
+ */
protected IColor backGround = null;
+ /**
+ * The color of the foreground.
+ */
protected IColor foreGround = null;
+ /**
+ * The current vertical screen bounds.
+ */
protected int y_;
+ /**
+ * The current horizontal screen bounds.
+ */
protected int x_;
+ /**
+ * The current yx value (view visible height - visible screen bounds)
+ */
protected int yx;
+ /**
+ * The current xx value (view visible width - visible screen bounds)
+ */
protected int xx;
+ /**
+ * true
to draw with focus else false
.
+ */
protected boolean drawWithFocus = false;
+ /**
+ * The static visible screen bounds.
+ */
private static int vscreen_bounds = 0;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Default constructor.
+ *
+ * @param scrollView A sequence diagram view reference.
+ * @param gc A graphical context.
+ */
public NGC(SDWidget scrollView, GC gc) {
context = gc;
view = scrollView;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#setLineStyle(int)
+ */
@Override
public void setLineStyle(int style) {
context.setLineStyle(style);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getLineStyle()
+ */
@Override
public int getLineStyle() {
return context.getLineStyle();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getContentsX()
+ */
@Override
public int getContentsX() {
return Math.round(view.getContentsX() / view.zoomValue);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getContentsY()
+ */
@Override
public int getContentsY() {
return Math.round(view.getContentsY() / view.zoomValue);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getVisibleWidth()
+ */
@Override
public int getVisibleWidth() {
return Math.round(view.getVisibleWidth() / view.zoomValue);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getVisibleHeight()
+ */
@Override
public int getVisibleHeight() {
return Math.round(view.getVisibleHeight() / view.zoomValue);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#contentsToViewX(int)
+ */
@Override
public int contentsToViewX(int x) {
return view.contentsToViewX(x);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#contentsToViewY(int)
+ */
@Override
public int contentsToViewY(int y) {
return view.contentsToViewY(y);
}
+ /**
+ * Get code for drawings at given x and y position.
+ *
+ * @param x The x position
+ * @param y The y position.
+ * @return A code for top, bottom, right and left
+ */
protected byte code(int x, int y) {
byte c = 0;
y_ = vscreen_bounds;
x_ = vscreen_bounds;
yx = view.getVisibleHeight() + vscreen_bounds;
xx = view.getVisibleWidth() + vscreen_bounds;
- if (y > yx)
+ if (y > yx) {
c |= 0x01; // top
- else if (y < y_)
+ } else if (y < y_) {
c |= 0x02; // bottom
- if (x > xx)
+ }
+
+ if (x > xx) {
c |= 0x04; // right
- else if (x < x_)
+ } else if (x < x_) {
c |= 0x08; // left
+ }
return c;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawLine(int, int, int, int)
+ */
@Override
public void drawLine(int x1, int y1, int x2, int y2) {
x1 = Math.round(x1 * view.zoomValue);
@@ -137,20 +243,16 @@ public class NGC implements IGC {
end = true;
} else {
codex = (code1 != 0) ? code1 : code2;
- if ((codex & 0x01) != 0) // top
- {
+ if ((codex & 0x01) != 0) { // top
x = x1 + ((x2 - x1) * (yx - y1)) / (y2 - y1);
y = yx;
- } else if ((codex & 0x02) != 0) // bottom
- {
+ } else if ((codex & 0x02) != 0) { // bottom
x = x1 + ((x2 - x1) * (y_ - y1)) / (y2 - y1);
y = y_;
- } else if ((codex & 0x04) != 0) // right
- {
+ } else if ((codex & 0x04) != 0) { // right
y = y1 + ((y2 - y1) * (xx - x1)) / (x2 - x1);
x = xx;
- } else if ((codex & 0x08) != 0) // left
- {
+ } else if ((codex & 0x08) != 0) { // left
y = y1 + ((y2 - y1) * (x_ - x1)) / (x2 - x1);
x = x_;
}
@@ -166,11 +268,16 @@ public class NGC implements IGC {
}
}
} while (!end);
+
if (draw) {
context.drawLine(x1, y1, x2, y2);
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawRectangle(int, int, int, int)
+ */
@Override
public void drawRectangle(int x, int y, int width, int height) {
x = Math.round(x * view.zoomValue);
@@ -192,17 +299,23 @@ public class NGC implements IGC {
height = height + y + vscreen_bounds;
y = -vscreen_bounds;
}
- if ((width < -vscreen_bounds) && (x + width < -vscreen_bounds))
+ if ((width < -vscreen_bounds) && (x + width < -vscreen_bounds)) {
width = -vscreen_bounds;
- else if (width + x > view.getVisibleWidth() + vscreen_bounds)
+ } else if (width + x > view.getVisibleWidth() + vscreen_bounds) {
width = view.getVisibleWidth() + vscreen_bounds - x;
- if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds))
+ }
+ if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds)) {
height = -vscreen_bounds;
- else if (height + y > view.getVisibleHeight() + vscreen_bounds)
+ } else if (height + y > view.getVisibleHeight() + vscreen_bounds) {
height = view.getVisibleHeight() + vscreen_bounds - y;
+ }
context.drawRectangle(x, y, width, height);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawFocus(int, int, int, int)
+ */
@Override
public void drawFocus(int x, int y, int width, int height) {
IColor bC = getBackground();
@@ -232,6 +345,10 @@ public class NGC implements IGC {
setForeground(fC);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#fillPolygon(int[])
+ */
@Override
public void fillPolygon(int[] points) {
int len = (points.length / 2) * 2;
@@ -248,6 +365,10 @@ public class NGC implements IGC {
context.fillPolygon(localPoint);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawPolygon(int[])
+ */
@Override
public void drawPolygon(int[] points) {
int len = (points.length / 2) * 2;
@@ -258,34 +379,17 @@ public class NGC implements IGC {
localPoint[i] = view.contentsToViewY(Math.round(points[i] * view.zoomValue));
}
- if (validatePolygonHeight(localPoint) <= 0)
+ if (validatePolygonHeight(localPoint) <= 0) {
return;
+ }
context.drawPolygon(localPoint);
}
- private int validatePolygonHeight(int[] localPoint) {
- int i = 1;
- int max = 0;
- int min = Integer.MAX_VALUE;
- while (i < localPoint.length) {
- max = Math.abs(localPoint[i]) > Math.abs(max) ? localPoint[i] : max;
- min = Math.abs(localPoint[i]) < Math.abs(min) ? localPoint[i] : min;
- i+=2;
- }
- int height = max - min;
- if (min < -vscreen_bounds) {
- height = height + min + vscreen_bounds;
- min = -vscreen_bounds;
- }
- if ((height < -vscreen_bounds) && (min + height < -vscreen_bounds))
- height = -vscreen_bounds;
-
- else if (height + min > view.getVisibleHeight() + vscreen_bounds)
- height = view.getVisibleHeight() + vscreen_bounds - min;
- return height;
- }
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#fillRectangle(int, int, int, int)
+ */
@Override
public void fillRectangle(int x, int y, int width, int height) {
x = Math.round(x * view.zoomValue);
@@ -293,8 +397,9 @@ public class NGC implements IGC {
if (y != getContentsY()) {
y = Math.round(y * view.zoomValue);
y = view.contentsToViewY(y) + 1;
- } else
+ } else {
y = 1;
+ }
width = Math.round(width * view.zoomValue) - 1;
height = Math.round(height * view.zoomValue) - 1;
x = view.contentsToViewX(x) + 1;
@@ -306,18 +411,24 @@ public class NGC implements IGC {
height = height + y + vscreen_bounds;
y = -vscreen_bounds;
}
- if ((width < -vscreen_bounds) && (x + width < -vscreen_bounds))
+ if ((width < -vscreen_bounds) && (x + width < -vscreen_bounds)) {
width = -vscreen_bounds;
- else if (width + x > view.getVisibleWidth() + vscreen_bounds)
+ } else if (width + x > view.getVisibleWidth() + vscreen_bounds) {
width = view.getVisibleWidth() + vscreen_bounds - x;
- if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds))
+ }
+ if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds)) {
height = -vscreen_bounds;
- else if (height + y > view.getVisibleHeight() + vscreen_bounds)
+ } else if (height + y > view.getVisibleHeight() + vscreen_bounds) {
height = view.getVisibleHeight() + vscreen_bounds - y;
+ }
context.fillRectangle(x, y, width, height);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#fillGradientRectangle(int, int, int, int, boolean)
+ */
@Override
public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
x = Math.round(x * view.zoomValue);
@@ -337,14 +448,17 @@ public class NGC implements IGC {
height = height + y + vscreen_bounds;
y = -vscreen_bounds;
}
- if ((width < -vscreen_bounds) && (x + width < -vscreen_bounds))
+
+ if ((width < -vscreen_bounds) && (x + width < -vscreen_bounds)) {
width = -vscreen_bounds;
- else if (width + x > view.getVisibleWidth() + vscreen_bounds)
+ } else if (width + x > view.getVisibleWidth() + vscreen_bounds) {
width = view.getVisibleWidth() + vscreen_bounds - x;
- if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds))
+ }
+ if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds)) {
height = -vscreen_bounds;
- else if (height + y > view.getVisibleHeight() + vscreen_bounds)
+ } else if (height + y > view.getVisibleHeight() + vscreen_bounds) {
height = view.getVisibleHeight() + vscreen_bounds - y;
+ }
if (vertical) {
context.fillGradientRectangle(x, y, width, height, vertical);
}
@@ -355,11 +469,19 @@ public class NGC implements IGC {
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#textExtent(java.lang.String)
+ */
@Override
public int textExtent(String name) {
return ((Point) (context.textExtent(name))).x;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawText(java.lang.String, int, int, boolean)
+ */
@Override
public void drawText(String string, int x, int y, boolean trans) {
x = Math.round(x * view.zoomValue);
@@ -371,6 +493,10 @@ public class NGC implements IGC {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawText(java.lang.String, int, int)
+ */
@Override
public void drawText(String string, int x, int y) {
x = Math.round(x * view.zoomValue);
@@ -382,6 +508,10 @@ public class NGC implements IGC {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#fillOval(int, int, int, int)
+ */
@Override
public void fillOval(int x, int y, int width, int height) {
x = Math.round(x * view.zoomValue);
@@ -391,38 +521,54 @@ public class NGC implements IGC {
context.fillOval(view.contentsToViewX(x), view.contentsToViewY(y), width, height);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getBackground()
+ */
@Override
public IColor getBackground() {
- if (backGround != null)
- if (backGround.getColor() instanceof Color)
- if (!((Color) (backGround.getColor())).isDisposed())
- return backGround;
+ if ((backGround != null) && (backGround.getColor() instanceof Color) && (!((Color) (backGround.getColor())).isDisposed())) {
+ return backGround;
+ }
return ColorImpl.getSystemColor(SWT.COLOR_WHITE);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getForeground()
+ */
@Override
public IColor getForeground() {
- if (foreGround != null)
- if (foreGround.getColor() instanceof Color)
- if (!((Color) (foreGround.getColor())).isDisposed())
- return foreGround;
+ if ((foreGround != null) && (foreGround.getColor() instanceof Color) && (!((Color) (foreGround.getColor())).isDisposed())) {
+ return foreGround;
+ }
return ColorImpl.getSystemColor(SWT.COLOR_WHITE);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#setBackground(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor)
+ */
@Override
public void setBackground(IColor color) {
- if (color == null)
+ if (color == null) {
return;
+ }
if (color.getColor() instanceof Color) {
context.setBackground((Color) color.getColor());
backGround = color;
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#setForeground(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor)
+ */
@Override
public void setForeground(IColor color) {
- if (color == null)
+ if (color == null) {
return;
+ }
if (color.getColor() instanceof Color) {
Color c = (Color) color.getColor();
if (!c.isDisposed()) {
@@ -432,37 +578,66 @@ public class NGC implements IGC {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#setGradientColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor)
+ */
@Override
public void setGradientColor(IColor color) {
- if (color == null)
+ if (color == null) {
return;
- if (color.getColor() instanceof Color)
+ }
+ if (color.getColor() instanceof Color) {
gradientColor = color;
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#setLineWidth(int)
+ */
@Override
public void setLineWidth(int width) {
- if (view.isPrinting())
+ if (view.isPrinting()) {
context.setLineWidth(width * 2);
- else
+ }
+ else {
context.setLineWidth(width);
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getLineWidth()
+ */
@Override
public int getLineWidth() {
return context.getLineWidth();
}
- // Linux GTK Workaround
- protected void localDrawText(String string, int x, int y, boolean trans) {
+ /**
+ * Method to draw a text in rectangle. (Linux GTK Workaround)
+ *
+ * @param string The text to draw.
+ * @param x The x position.
+ * @param y The y position.
+ * @param isTransparent true for transparent else false
+ */
+ protected void localDrawText(String string, int x, int y, boolean isTransparent) {
Point r = context.textExtent(string);
- if (!trans)
+ if (!isTransparent) {
context.fillRectangle(x, y, r.x, r.y);
- context.drawText(string, x, y, trans);
- if ((drawWithFocus) && (string.length() > 1))
+ }
+ context.drawText(string, x, y, isTransparent);
+ if ((drawWithFocus) && (string.length() > 1)) {
context.drawFocus(x - 1, y - 1, r.x + 2, r.y + 2);
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawTextTruncatedCentred(java.lang.String, int, int, int, int, boolean)
+ */
@Override
public void drawTextTruncatedCentred(String name, int _x, int _y, int width, int height, boolean trans) {
Point tx = context.textExtent(name);
@@ -476,39 +651,46 @@ public class NGC implements IGC {
width = Math.round(width * view.zoomValue);
height = Math.round(height * view.zoomValue);
int x = view.contentsToViewX(_x);
- if (tx.y > height)
+ if (tx.y > height) {
return;
+ }
// Adjust height and y
if (y < -vscreen_bounds) {
height = height + y + vscreen_bounds;
y = -vscreen_bounds;
}
- if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds))
+ if ((height < -vscreen_bounds) && (y + height < -vscreen_bounds)) {
height = -vscreen_bounds;
- else if (height + y > view.getVisibleHeight() + vscreen_bounds)
+ } else if (height + y > view.getVisibleHeight() + vscreen_bounds) {
height = view.getVisibleHeight() + vscreen_bounds - y;
+ }
if (tx.x <= width) {
localDrawText(name, x + 1 + (width - tx.x) / 2, y + 1 + (height - tx.y) / 2, trans);
} else {
String nameToDisplay = name;
- for (int i = name.length() - 1; i >= 0 && context.textExtent(nameToDisplay).x >= width; i--)
+ for (int i = name.length() - 1; i >= 0 && context.textExtent(nameToDisplay).x >= width; i--) {
nameToDisplay = name.substring(0, i);
+ }
int dotCount = 0;
- for (int i = 1; i <= 3 && nameToDisplay.length() - i > 0; i++)
+ for (int i = 1; i <= 3 && nameToDisplay.length() - i > 0; i++) {
dotCount++;
+ }
nameToDisplay = nameToDisplay.substring(0, nameToDisplay.length() - dotCount);
StringBuffer buf = new StringBuffer(nameToDisplay);
for (int i = 0; i < dotCount; i++) {
buf.append("."); //$NON-NLS-1$
- // nameToDisplay = nameToDisplay + "."; //$NON-NLS-1$
}
nameToDisplay = buf.toString();
localDrawText(nameToDisplay, x + 1 + (width - context.textExtent(nameToDisplay).x) / 2, y + 1 + (height - context.textExtent(nameToDisplay).y) / 2, trans);
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawTextTruncated(java.lang.String, int, int, int, int, boolean)
+ */
@Override
public void drawTextTruncated(String name, int _x, int _y, int width, int height, boolean trans) {
_x = Math.round(_x * view.zoomValue);
@@ -521,8 +703,9 @@ public class NGC implements IGC {
localDrawText(name, x + 1, y + 1 + height, trans);
} else {
String nameToDisplay = name;
- for (int i = name.length() - 1; i >= 0 && context.textExtent(nameToDisplay).x >= width; i--)
+ for (int i = name.length() - 1; i >= 0 && context.textExtent(nameToDisplay).x >= width; i--) {
nameToDisplay = name.substring(0, i);
+ }
int dotCount = 0;
for (int i = 1; i <= 3 && nameToDisplay.length() - i > 0; i++)
dotCount++;
@@ -532,13 +715,16 @@ public class NGC implements IGC {
for (int i = 0; i < dotCount; i++) {
buf.append("."); //$NON-NLS-1$
- // nameToDisplay = nameToDisplay + "."; //$NON-NLS-1$
}
nameToDisplay = buf.toString();
localDrawText(nameToDisplay, x + 1, y + 1 + height, trans);
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawImage(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage, int, int, int, int)
+ */
@Override
public void drawImage(IImage image, int _x, int _y, int maxWith, int maxHeight) {
Image img = null;
@@ -563,10 +749,12 @@ public class NGC implements IGC {
Rectangle b = ((Image) image.getImage()).getBounds();
int width = b.width;
int height = b.height;
- if (width > maxWith)
+ if (width > maxWith) {
width = maxWith;
- if (height > maxHeight)
+ }
+ if (height > maxHeight) {
height = maxHeight;
+ }
float tempZoom = view.zoomValue;
width = Math.round(width * tempZoom);
height = Math.round(height * tempZoom);
@@ -585,33 +773,48 @@ public class NGC implements IGC {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#drawArc(int, int, int, int, int, int)
+ */
@Override
public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) {
x = Math.round(x * view.zoomValue);
y = Math.round(y * view.zoomValue);
width = Math.round(width * view.zoomValue);
height = Math.round(height * view.zoomValue);
- if (width == 0 || height == 0 || endAngle == 0)
+ if (width == 0 || height == 0 || endAngle == 0) {
return;
+ }
context.drawArc(view.contentsToViewX(x), view.contentsToViewY(y), width, height, startAngle, endAngle);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#setFont(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont)
+ */
@Override
public void setFont(IFont font) {
if (font.getFont() != null && ((Font) font.getFont()).getFontData().length > 0) {
FontData fontData = ((Font) font.getFont()).getFontData()[0];
if (SDViewPref.getInstance().fontLinked() || view.printing) {
int h = Math.round(fontData.getHeight() * view.zoomValue);
- if (h > 0)
+ if (h > 0) {
fontData.setHeight(h);
+ }
}
- if (tempFont != null)
+ if (tempFont != null) {
tempFont.dispose();
+ }
tempFont = new Font(Display.getCurrent(), fontData);
context.setFont(tempFont);
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getFontHeight(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont)
+ */
@Override
public int getFontHeight(IFont font) {
if (font.getFont() != null && (font.getFont() instanceof Font) && ((Font) font.getFont()).getFontData().length > 0) {
@@ -624,10 +827,19 @@ public class NGC implements IGC {
return 0;
}
+ /**
+ * Returns the current font height.
+ *
+ * @return the current font height.
+ */
protected int getCurrentFontHeight() {
return context.textExtent("lp").y; //$NON-NLS-1$
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getFontWidth(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont)
+ */
@Override
public int getFontWidth(IFont font) {
if ((font.getFont() != null) && (font.getFont() instanceof Font)) {
@@ -640,38 +852,64 @@ public class NGC implements IGC {
return 0;
}
+ /**
+ * Disposes all created resources.
+ */
public void dispose() {
- if (tempFont != null)
+ if (tempFont != null) {
tempFont.dispose();
+ }
tempFont = null;
- if (context != null)
+ if (context != null) {
context.dispose();
+ }
context = null;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getZoom()
+ */
@Override
public float getZoom() {
- if (view != null)
+ if (view != null) {
return view.zoomValue;
- else
+ } else {
return 1;
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getLineDotStyle()
+ */
@Override
public int getLineDotStyle() {
return SWT.LINE_DOT;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getLineDashStyle()
+ */
@Override
public int getLineDashStyle() {
return SWT.LINE_DASH;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#getLineSolidStyle()
+ */
@Override
public int getLineSolidStyle() {
return SWT.LINE_SOLID;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC#createColor(int, int, int)
+ */
@Override
public IColor createColor(int r, int g, int b) {
return new ColorImpl(Display.getDefault(), r, g, b);
@@ -686,12 +924,53 @@ public class NGC implements IGC {
drawWithFocus = focus;
}
+ /**
+ * Returns the screen bounds.
+ *
+ * @return the screen bounds.
+ */
protected static int getVscreenBounds() {
return vscreen_bounds;
}
+ /**
+ * Sets the visible screen bounds.
+ *
+ * @param vBounds the screen bounds.
+ */
protected static void setVscreenBounds(int vBounds) {
vscreen_bounds = vBounds;
}
-
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Validates the polygon height
+ *
+ * @param localPoint array of points
+ * @return height
+ */
+ private int validatePolygonHeight(int[] localPoint) {
+ int i = 1;
+ int max = 0;
+ int min = Integer.MAX_VALUE;
+ while (i < localPoint.length) {
+ max = Math.abs(localPoint[i]) > Math.abs(max) ? localPoint[i] : max;
+ min = Math.abs(localPoint[i]) < Math.abs(min) ? localPoint[i] : min;
+ i+=2;
+ }
+ int height = max - min;
+ if (min < -vscreen_bounds) {
+ height = height + min + vscreen_bounds;
+ min = -vscreen_bounds;
+ }
+ if ((height < -vscreen_bounds) && (min + height < -vscreen_bounds)) {
+ height = -vscreen_bounds;
+ } else if (height + min > view.getVisibleHeight() + vscreen_bounds) {
+ height = view.getVisibleHeight() + vscreen_bounds - min;
+ }
+ return height;
+ }
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java
index 848ccc4ef1..2f166f2c23 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDView.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDView.java,v 1.2 2008/01/24 02:29:01 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -76,29 +77,86 @@ import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.properties.IPropertySheetPage;
/**
+ *
+ * This class is a generic sequence diagram view implementation.
+ *
+
+ * @version 1.0
* @author sveyrier
- *
*/
public class SDView extends ViewPart {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram widget.
+ */
protected SDWidget sdWidget = null;
+ /**
+ * The time compression bar.
+ */
protected TimeCompressionBar timeCompressionBar = null;
+ /**
+ * The sequence diagram find provider implementation.
+ */
protected ISDFindProvider sdFindProvider = null;
+ /**
+ * The sequence diagram paging provider implementation.
+ */
protected ISDPagingProvider sdPagingProvider = null;
+ /**
+ * The sequence diagram filter provider implementation.
+ */
protected ISDFilterProvider sdFilterProvider = null;
+ /**
+ * The extended sequence diagram filter provider implementation.
+ */
protected IExtendedFilterProvider sdExFilterProvider = null;
+ /**
+ * The extended sequence diagram find provider implementation.
+ */
protected IExtendedFindProvider sdExFindProvider = null;
+ /**
+ * The extended sequence diagram action bar provider implementation.
+ */
protected ISDExtendedActionBarProvider sdExtendedActionBarProvider = null;
+ /**
+ * The sequence diagram property provider implementation.
+ */
protected ISDPropertiesProvider sdPropertiesProvider = null;
-
+ /**
+ * Button for executing the next page action.
+ */
protected NextPage nextPageButton = null;
+ /**
+ * Button for executing the previous page action.
+ */
protected PrevPage prevPageButton = null;
+ /**
+ * Button for executing the first page page action.
+ */
protected FirstPage firstPageButton = null;
+ /**
+ * Button for executing the last page action.
+ */
protected LastPage lastPageButton = null;
-
+ /**
+ * The menu manager reference.
+ */
protected MenuManager menuMgr = null;
-
+ /**
+ * Flag to indicate whether view needs initialization or not.
+ */
protected boolean needInit = true;
+ /**
+ * WaitCursor is the cursor to be displayed when long tasks are running
+ */
+ protected Cursor waitCursor;
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -140,15 +198,13 @@ public class SDView extends ViewPart {
}
/**
- * Load a blank page that is supposed to explain that a kind of interaction must be chosen
+ * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
*/
protected void loadBlank() {
- IUml2SDLoader l = new IUml2SDLoader() {
+ IUml2SDLoader loader = new IUml2SDLoader() {
/*
* (non-Javadoc)
- * @see
- * org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui
- * .views.uml2sd.SDView)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
*/
@Override
public void setViewer(SDView viewer) {
@@ -169,14 +225,14 @@ public class SDView extends ViewPart {
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#aboutToBeReplaced()
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#dispose()
*/
@Override
public void dispose() {
}
};
- l.setViewer(this);
- setContentDescription(l.getTitleString());
+ loader.setViewer(this);
+ setContentDescription(loader.getTitleString());
}
/*
@@ -206,12 +262,14 @@ public class SDView extends ViewPart {
}
/**
+ * Returns the SD widget.
+ *
* @return The SD widget.
*/
public SDWidget getSDWidget() {
return sdWidget;
}
-
+
/**
* Set the find provider for the opened sequence diagram viewer
* If the provider is not set, the find menu item will not be available in the viewer
@@ -232,7 +290,7 @@ public class SDView extends ViewPart {
KeyBindingsManager.getInstance().setFindEnabled(false);
}
}
-
+
/**
* Set the find provider for the opened sequence diagram viewer
* If the provider is not set, the find menu item will not be available in the viewer
@@ -385,7 +443,7 @@ public class SDView extends ViewPart {
}
/**
- * Set the properties view provider for the opened sequence diagram viewer
+ * Set the properties view provider for the opened sequence diagram viewer
*
* @param provider the properties provider
*/
@@ -394,7 +452,7 @@ public class SDView extends ViewPart {
}
/**
- * Returns the current extended action bar provider for the view
+ * Returns the current extended action bar provider for the view.
*
* @return the extended action bar provider
*/
@@ -547,10 +605,11 @@ public class SDView extends ViewPart {
minMax.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax); //$NON-NLS-1$
- if ((sdWidget.getFrame() != null) && (sdWidget.getFrame().hasTimeInfo()))
+ if ((sdWidget.getFrame() != null) && (sdWidget.getFrame().hasTimeInfo())) {
minMax.setEnabled(true);
- else
+ } else {
minMax.setEnabled(false);
+ }
// Do we need to display a paging item
if (sdPagingProvider != null) {
@@ -607,12 +666,15 @@ public class SDView extends ViewPart {
if (sdExFindProvider != null) {
Action action = sdExFindProvider.getFindAction();
if (action != null) {
- if (action.getId() == null)
+ if (action.getId() == null) {
action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
- if (action.getImageDescriptor() == null)
+ }
+ if (action.getImageDescriptor() == null) {
action.setImageDescriptor(TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ));
- if (action.getText() == null)
+ }
+ if (action.getText() == null) {
action.setText(SDMessages._41);
+ }
bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$
bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$
}
@@ -637,11 +699,13 @@ public class SDView extends ViewPart {
public void updateCoolBar() {
if (sdPagingProvider != null) {
IActionBars bar = getViewSite().getActionBars();
- if (bar == null)
+ if (bar == null) {
return;
+ }
IToolBarManager barManager = bar.getToolBarManager();
- if (barManager == null)
+ if (barManager == null) {
return;
+ }
IContributionItem nextPage = barManager.find(NextPage.ID);
if (nextPage != null && nextPage instanceof ActionContributionItem) {
IAction nextPageAction = ((ActionContributionItem) nextPage).getAction();
@@ -711,6 +775,7 @@ public class SDView extends ViewPart {
* The frame to render (the sequence diagram)
*
* @param frame the frame to display
+ * @param resetPosition boolean Flag whether to reset the position or not.
*/
protected void setFrame(Frame frame, boolean resetPosition) {
if (sdWidget == null)
@@ -721,17 +786,19 @@ public class SDView extends ViewPart {
return;
}
- IUml2SDLoader l = LoadersManager.getInstance().getCurrentLoader(getViewSite().getId(), this);
+ IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(getViewSite().getId(), this);
- if ((l != null) && (l.getTitleString() != null)) {
- setContentDescription(l.getTitleString());
+ if ((loader != null) && (loader.getTitleString() != null)) {
+ setContentDescription(loader.getTitleString());
}
- if (getSDWidget() != null)
+ if (getSDWidget() != null) {
getSDWidget().setFrame(frame, resetPosition);
+ }
- if (timeCompressionBar != null)
+ if (timeCompressionBar != null) {
timeCompressionBar.setFrame(frame);
+ }
updateCoolBar();
if (!frame.hasTimeInfo()) {
Composite parent = timeCompressionBar.getParent();
@@ -749,8 +816,9 @@ public class SDView extends ViewPart {
for (int i = 0; i < items.length; i++) {
if (items[i] instanceof ActionContributionItem) {
IAction action = ((ActionContributionItem) items[i]).getAction();
- if (action != null)
+ if (action != null) {
action.setEnabled(true);
+ }
}
}
}
@@ -766,20 +834,22 @@ public class SDView extends ViewPart {
public void setEnableCommand(String id, boolean value) {
IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
MenuManager shortKeys = (MenuManager) shortKeysMenu;
- if (shortKeys == null)
+ if (shortKeys == null) {
return;
+ }
IContributionItem item = shortKeys.find(id);
if ((item != null) && (item instanceof ActionContributionItem)) {
IAction action = ((ActionContributionItem) item).getAction();
- if (action != null)
+ if (action != null) {
action.setEnabled(value);
+ }
}
}
/**
* Set the frame from an other thread than the one executing the main loop
*
- * @param frame
+ * @param frame The frame to set (and display)
*/
public void setFrameSync(final Frame frame) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
@@ -800,7 +870,7 @@ public class SDView extends ViewPart {
/**
* Ensure an object is visible from an other thread than the one executing the main loop
*
- * @param sm
+ * @param sm The node to make visible in view
*/
public void ensureVisibleSync(final GraphNode sm) {
getSDWidget().getDisplay().syncExec(new Runnable() {
@@ -817,7 +887,8 @@ public class SDView extends ViewPart {
/**
* Set the frame and ensure an object is visible from an other thread than the one executing the main loop
*
- * @param sm
+ * @param sm The node to make visible in view
+ * @param frame Frame The frame to set
*/
public void setFrameAndEnsureVisibleSync(final Frame frame, final GraphNode sm) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
@@ -837,7 +908,8 @@ public class SDView extends ViewPart {
/**
* Set the frame and ensure an object is visible
*
- * @param sm
+ * @param sm The node to make visible in view
+ * @param frame Frame The frame to set
*/
public void setFrameAndEnsureVisible(Frame frame, GraphNode sm) {
getSDWidget().clearSelection();
@@ -848,9 +920,9 @@ public class SDView extends ViewPart {
/**
* Set the frame and ensure an object is visible from an other thread than the one executing the main loop
*
- * @param frame
- * @param x
- * @param y
+ * @param frame The frame to set.
+ * @param x The x coordinate to make visible.
+ * @param y The y coordinate to make visible.
*/
public void setFrameAndEnsureVisibleSync(final Frame frame, final int x, final int y) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
@@ -868,9 +940,9 @@ public class SDView extends ViewPart {
/**
* Set the frame and ensure an object is visible
*
- * @param frame
- * @param x
- * @param y
+ * @param frame The frame to set.
+ * @param x The x coordinate to make visible.
+ * @param y The y coordinate to make visible.
*/
public void setFrameAndEnsureVisible(Frame frame, int x, int y) {
getSDWidget().clearSelection();
@@ -879,15 +951,10 @@ public class SDView extends ViewPart {
getSDWidget().redraw();
}
- /**
- * waitCursor is the cursor to be displayed when long tasks are running
- */
- protected Cursor waitCursor;
-
/**
* Toggle between default and wait cursors from an other thread than the one executing the main loop
*
- * @param wait_
+ * @param wait_ true
for wait cursor else false
for default cursor.
*/
public void toggleWaitCursorAsync(final boolean wait_) {
if (getSDWidget() == null || getSDWidget().isDisposed()) {
@@ -922,7 +989,7 @@ public class SDView extends ViewPart {
/**
* Return the time compression bar widget
*
- * @return the time compression bar
+ * @return the time compression bar
*/
public TimeCompressionBar getTimeCompressionBar() {
return timeCompressionBar;
@@ -931,7 +998,7 @@ public class SDView extends ViewPart {
/**
* Returns the current Frame (the sequence diagram container)
*
- * @return the frame
+ * @return the current frame
*/
public Frame getFrame() {
if (getSDWidget() != null) {
@@ -942,16 +1009,21 @@ public class SDView extends ViewPart {
}
}
+ /**
+ * Restores the loader for the view based on the view ID.
+ *
+ * @return boolean true
if initialization is needed else false
.
+ */
protected boolean restoreLoader() {
String id = getViewSite().getId();
// System.err.println("restoreLoader() id="+id);
if (id == null) {
return true;
}
- IUml2SDLoader l = LoadersManager.getInstance().getCurrentLoader(id, this);
+ IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(id, this);
// System.err.println("restoreLoader() l="+l);
- if ((l != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
- l.setViewer(this);
+ if ((loader != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
+ loader.setViewer(this);
return false;
} else {
loadBlank();
@@ -959,12 +1031,18 @@ public class SDView extends ViewPart {
}
}
+ /**
+ * Checks if current view is ready to be used.
+ *
+ * @return boolean true
if view is ready else false
.
+ */
protected boolean isViewReady() {
- IWorkbenchPage persp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (persp == null)
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (page == null) {
return false;
+ }
- IViewReference[] ref = persp.getViewReferences();
+ IViewReference[] ref = page.getViewReferences();
for (int i = 0; i < ref.length; i++) {
if (ref[i].getView(false) == this) {
return true;
@@ -973,6 +1051,9 @@ public class SDView extends ViewPart {
return false;
}
+ /**
+ * Creates the menu group.
+ */
protected void createMenuGroup() {
IActionBars bar = getViewSite().getActionBars();
if (bar == null) {
@@ -996,6 +1077,11 @@ public class SDView extends ViewPart {
bar.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
}
+ /*
+ * Gets adapter for this view for properties.
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
+ */
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class _adapter) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java
index 965080947f..b68cd07fb0 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDWidget.java,v 1.6 2008/12/12 22:21:46 jcayne Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -18,6 +19,8 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.contexts.IContextIds;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -34,14 +37,14 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Metrics;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.SDPrintDialog;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.SDPrintDialogUI;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDCollapseProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.LoadersManager;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDPrintDialog;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDPrintDialogUI;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.ACC;
import org.eclipse.swt.accessibility.Accessible;
@@ -77,72 +80,186 @@ import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.part.ViewPart;
/**
+ *
+ * This class implements sequence diagram widget used in the sequence diagram view.
+ *
*
+ * @version 1.0
* @author sveyrier
*
*/
public class SDWidget extends ScrollView implements SelectionListener, IPropertyChangeListener, DisposeListener, ITimeCompressionListener {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The frame to display in the sequence diagram widget.
+ */
protected Frame frame;
+ /**
+ * The overview image to display.
+ */
protected Image overView = null;
+ /**
+ * The zoom in menu item.
+ */
protected MenuItem zoomIn = null;
+ /**
+ * The zoom out menu item.
+ */
protected MenuItem zoomOut = null;
+ /**
+ * The sequence diagram selection provider.
+ */
protected SDWidgetSelectionProvider selProvider = null;
+ /**
+ * The current zoom value.
+ */
public float zoomValue = 1;
+ /**
+ * The current zoomInMode (true for zoom in).
+ */
protected boolean zoomInMode = false;
+ /**
+ * The current zoomOutMode (true for zoom out).
+ */
protected boolean zoomOutMode = false;
-
+ /**
+ * The current list of selected graph nodes.
+ */
protected List selectedNodeList = null;
+ /**
+ * Flag whether ctrl button is selected or not.
+ */
protected boolean ctrlSelection = false;
-
+ /**
+ * A reference to the view site.
+ */
protected ViewPart site = null;
-
+ /**
+ * The current graph node (the last selected one).
+ */
public GraphNode currentGraphNode = null;
+ /**
+ * The first graph node in list (multiple selection).
+ */
public GraphNode listStart = null;
+ /**
+ * The previous graph node (multiple selection).
+ */
public ArrayList prevList = null;
-
+ /**
+ * The time compression bar.
+ */
protected TimeCompressionBar timeBar = null;
-
+ /**
+ * The current diagram tool tip.
+ */
protected DiagramToolTip toolTip = null;
-
+ /**
+ * The accessible object reference of view control.
+ */
protected Accessible accessible = null;
-
+ /**
+ * The current node for the tooltip to display.
+ */
protected GraphNode toolTipNode;
-
+ /**
+ * The life line to drag and drop.
+ */
protected Lifeline dragAndDrop = null;
-
+ /**
+ * The number of focused widgets.
+ */
protected int focusedWidget = -1;
-
+ /**
+ * The printer zoom.
+ */
protected float printerZoom = 0;
-
+ /**
+ * Y coordinate for printer.
+ */
protected int printerY = 0;
-
+ /**
+ * X coordinate for printer.
+ */
protected int printerX = 0;
-
+ /**
+ * Flag whether drag and drop is enabled or not.
+ */
protected boolean getDragAndDrop = false;
-
+ /**
+ * The x coordinate for drag.
+ */
protected int dragX = 0;
+ /**
+ * The y coordinate for drag.
+ */
protected int dragY = 0;
-
+ /**
+ * The reorder mode.
+ */
protected boolean reorderMode = false;
-
- Image collapaseCaretImg = null;
- Image arrowUpCaretImg = null;
- Image currentCaretImage = null;
-
+ /**
+ * The collapse caret image.
+ */
+ protected Image collapaseCaretImg = null;
+ /**
+ * The arrow up caret image.
+ */
+ protected Image arrowUpCaretImg = null;
+ /**
+ * The current caret image.
+ */
+ protected Image currentCaretImage = null;
+ /**
+ * A sequence diagramm collapse provider (for collapsing graph nodes)
+ */
protected ISDCollapseProvider collapseProvider = null;
-
+ /**
+ * The insertion caret.
+ */
protected Caret insertionCartet = null;
+ /**
+ * The reorder list when in reorder mode.
+ */
protected ArrayList reorderList = null;
-
+ /**
+ * Flag to specify whether in printing mode or not.
+ */
protected boolean printing = false;
+ /**
+ * A printer reference.
+ */
protected Printer printer = null;
-
+ /**
+ * Flag whether shift was selected or not.
+ */
protected boolean shiftSelection = false;
-
+ /**
+ * The scroll tooltip.
+ */
protected DiagramToolTip scrollToolTip = null;
+ /**
+ * Timer for auto_scroll feature
+ */
+ protected AutoScroll local_auto_scroll_ = null;
+ /**
+ * TimerTask for auto_scroll feature !=null when auto scroll is running
+ */
+ protected Timer local_auto_scroll_timer_ = null;
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor for SDWidget.
+ * @param c The parent composite
+ * @param s The style
+ */
public SDWidget(Composite c, int s) {
super(c, s | SWT.NO_BACKGROUND, true);
setOverviewEnabled(true);
@@ -161,64 +278,17 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
}
});
- // tooltip on vertical bar causes trouble when scrolling, because
- // tooltip is constantly updated and shown
- // getVerticalBar().addSelectionListener(new SelectionListener(){
- //
- // public void widgetSelected(SelectionEvent e) {
- // scrollToolTip.hideToolTip();
- // double minOcc=0;
- // boolean needInit=true;
- // GraphNode m=null;
- // for (int i=0;i();
getViewControl().addTraverseListener(new TraverseListener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
+ */
@Override
public void keyTraversed(TraverseEvent e) {
- if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))
+ if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
e.doit = true;
+ }
}
});
addTraverseListener(new TraverseListener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
+ */
@Override
public void keyTraversed(TraverseEvent e) {
- if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))
+ if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
e.doit = true;
+ }
}
});
getViewControl().addFocusListener(new FocusListener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
+ */
@Override
public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub
@@ -331,6 +427,10 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
redraw();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
@Override
public void focusLost(FocusEvent e) {
SDViewPref.getInstance().setNoFocusSelection(true);
@@ -338,124 +438,22 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
}
});
}
-
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Sets the time compression bar.
+ *
+ * @param bar The time compression bar to set
+ */
public void setTimeBar(TimeCompressionBar bar) {
if (bar != null) {
timeBar = bar;
timeBar.addTimeCompressionListener(this);
}
}
-
- protected void setCollapseProvider(ISDCollapseProvider provider) {
- collapseProvider = provider;
- }
-
- @Override
- protected void keyPressedEvent(KeyEvent event) {
- if (!(isFocusControl() || getViewControl().isFocusControl())) {
- Control[] child = getParent().getChildren();
- for (int i = 0; i < child.length; i++) {
- if (child[i].isFocusControl()) {
- if (!(child[i] instanceof ScrollView)) {
- getViewControl().setFocus();
- break;
- }
- }
- }
- }
- setFocus(-1);
-
- if (event.keyCode == SWT.CTRL)
- ctrlSelection = true;
- if (event.keyCode == SWT.SHIFT) {
- shiftSelection = true;
- prevList = new ArrayList();
- prevList.addAll(getSelection());
- }
-
- GraphNode prevNode = getFocusNode();
-
- if (event.keyCode == SWT.ARROW_RIGHT)
- traverseRight();
-
- if (event.keyCode == SWT.ARROW_LEFT)
- traverseLeft();
-
- if (event.keyCode == SWT.ARROW_DOWN)
- traverseDown();
-
- if (event.keyCode == SWT.ARROW_UP)
- traverseUp();
-
- if (event.keyCode == SWT.HOME)
- traverseHome();
-
- if (event.keyCode == SWT.END)
- traverseEnd();
-
- if ((!shiftSelection) && (!ctrlSelection))
- listStart = currentGraphNode;
-
- if (event.character == ' ') {
- performSelection(currentGraphNode);
- if (!shiftSelection)
- listStart = currentGraphNode;
- }
-
- if ((shiftSelection) && (prevNode != getFocusNode())) {
- clearSelection();
- addSelection(prevList);
- addSelection(frame.getNodeList(listStart, getFocusNode()));
- if (getFocusNode() instanceof Lifeline)
- ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT.CENTER | SWT.VERTICAL, true);
- else
- ensureVisible(getFocusNode());
- } else if ((!ctrlSelection) && (!shiftSelection)) {
-
- clearSelection();
- if (getFocusNode() != null) {
- addSelection(getFocusNode());
-
- if (getFocusNode() instanceof Lifeline)
- ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT.CENTER | SWT.VERTICAL, true);
- else
- ensureVisible(getFocusNode());
- }
- }
-
- if (currentGraphNode != null)
- currentGraphNode.setFocused(true);
- redraw();
-
- if ((event.character == ' ') && ((zoomInMode) || (zoomOutMode))) {
- int cx = Math.round((getContentsX() + getVisibleWidth() / 2) / zoomValue);
- int cy = Math.round((getContentsY() + getVisibleHeight() / 2) / zoomValue);
- if (zoomInMode) {
- if (zoomValue < 64)
- zoomValue = zoomValue * (float) 1.25;
- } else
- zoomValue = zoomValue / (float) 1.25;
- int x = Math.round(cx * zoomValue - getVisibleWidth() / (float) 2);
- int y = Math.round(cy * zoomValue - getVisibleHeight() / (float) 2);
- setContentsPos(x, y);
- if (timeBar != null)
- timeBar.setZoom(zoomValue);
- // redraw also resize the scrollView content
- redraw();
- }
- }
-
- @Override
- protected void keyReleasedEvent(KeyEvent event) {
- setFocus(-1);
- if (event.keyCode == SWT.CTRL)
- ctrlSelection = false;
- if (event.keyCode == SWT.SHIFT)
- shiftSelection = false;
- super.keyReleasedEvent(event);
- setFocus(1);
- }
-
+
/**
* Resize the contents to insure the frame fit into the view
*
@@ -467,35 +465,11 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
resizeContents(width, height);
}
- protected boolean checkFocusOnChilds(Control childs) {
- if (childs instanceof Composite) {
- Control[] child = ((Composite) childs).getChildren();
- for (int i = 0; i < child.length; i++) {
- if (child[i].isFocusControl()) {
- return true;
- } else
- checkFocusOnChilds(child[i]);
- }
- }
- return false;
- }
-
- @Override
- public boolean isFocusControl() {
- Control[] child = getChildren();
- for (int i = 0; i < child.length; i++) {
- if (child[i].isFocusControl()) {
- return true;
- } else
- checkFocusOnChilds(child[i]);
- }
- return false;
- }
-
/**
* The frame to render (the sequence diagram)
*
* @param theFrame the frame to display
+ * @param resetPosition boolean
*/
public void setFrame(Frame theFrame, boolean resetPosition) {
reorderList.clear();
@@ -508,8 +482,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
redraw();
}
// prepare the old overview to be reused
- if (overView != null)
+ if (overView != null) {
overView.dispose();
+ }
overView = null;
resizeContents(frame);
}
@@ -517,7 +492,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
/**
* Returns the current Frame (the sequence diagram container)
*
- * @return the frame
+ * @return the frame
*/
public Frame getFrame() {
return frame;
@@ -526,59 +501,731 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
/**
* Returns the selection provider for the current sequence diagram
*
- * @return the selection provider
+ * @return the selection provider
*/
public ISelectionProvider getSelectionProvider() {
return selProvider;
}
-
- @Override
- public boolean setContentsPos(int x, int y) {
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- if (frame == null)
- return false;
- if (x + getVisibleWidth() > getContentsWidth())
- x = getContentsWidth() - getVisibleWidth();
- if (y + getVisibleHeight() > getContentsHeight())
- y = getContentsHeight() - getVisibleHeight();
- int x1 = Math.round(x / zoomValue);
- int y2 = Math.round(y / zoomValue);
- int width = Math.round(getVisibleWidth() / zoomValue);
- int height = Math.round(getVisibleHeight() / zoomValue);
- frame.updateIndex(x1, y2, width, height);
-
- if (insertionCartet != null && insertionCartet.isVisible())
- insertionCartet.setVisible(false);
-
- return super.setContentsPos(x, y);
+
+ /**
+ * Returns a list of selected graph nodes.
+ *
+ * @return a list of selected graph nodes.
+ */
+ public List getSelection() {
+ return selectedNodeList;
}
- @Override
- protected void contentsMouseHover(MouseEvent event) {
- GraphNode graphNode = null;
- if (frame != null) {
- int x = Math.round(event.x / zoomValue);
- int y = Math.round(event.y / zoomValue);
- graphNode = frame.getNodeAt(x, y);
- if ((graphNode != null) && (SDViewPref.getInstance().tooltipEnabled())) {
- toolTipNode = graphNode;
- String postfix = getPostfixForTooltip(true);
- if (graphNode instanceof Lifeline) {
- Lifeline lifeline = (Lifeline) graphNode;
- toolTip.showToolTip(lifeline.getToolTipText() + postfix);
- setFocus(0);
+ /**
+ * Adds a graph node to the selected nodes list.
+ *
+ * @param node A graph node
+ */
+ public void addSelection(GraphNode node) {
+ if (node == null) {
+ return;
+ }
+ selectedNodeList.add(node);
+ node.setSelected(true);
+ currentGraphNode = node;
+ StructuredSelection selection = new StructuredSelection(selectedNodeList);
+ selProvider.setSelection(selection);
+ }
+
+ /**
+ * Adds a list of node to the selected nodes list.
+ *
+ * @param list of graph nodes
+ */
+ public void addSelection(List list) {
+ // selectedNodeList.addAll(list);
+ for (int i = 0; i < list.size(); i++) {
+ if (!selectedNodeList.contains(list.get(i))) {
+ selectedNodeList.add(list.get(i));
+ ((GraphNode) list.get(i)).setSelected(true);
+ }
+ }
+ StructuredSelection selection = new StructuredSelection(selectedNodeList);
+ selProvider.setSelection(selection);
+ }
+
+ /**
+ * Removes a node from the selected nodes list.
+ *
+ * @param node to remove
+ */
+ public void removeSelection(GraphNode node) {
+ selectedNodeList.remove(node);
+ node.setSelected(false);
+ node.setFocused(false);
+ StructuredSelection selection = new StructuredSelection(selectedNodeList);
+ selProvider.setSelection(selection);
+ }
+
+ /**
+ * Removes a list of graph nodes from the selected nodes list.
+ *
+ * @param list of nodes to remove.
+ */
+ public void removeSelection(List list) {
+ selectedNodeList.removeAll(list);
+ for (int i = 0; i < list.size(); i++) {
+ ((GraphNode) list.get(i)).setSelected(false);
+ ((GraphNode) list.get(i)).setFocused(false);
+ }
+ StructuredSelection selection = new StructuredSelection(selectedNodeList);
+ selProvider.setSelection(selection);
+ }
+
+ /**
+ * Clear the list of GraphNodes which must be drawn selected.
+ */
+ public void clearSelection() {
+ for (int i = 0; i < selectedNodeList.size(); i++) {
+ ((GraphNode) selectedNodeList.get(i)).setSelected(false);
+ ((GraphNode) selectedNodeList.get(i)).setFocused(false);
+ }
+ currentGraphNode = null;
+ selectedNodeList.clear();
+ selProvider.setSelection(new StructuredSelection());
+ }
+
+ /**
+ * Sets view part.
+ *
+ * @param viewSite The view part to set
+ */
+ public void setSite(ViewPart viewSite) {
+ site = viewSite;
+ site.getSite().setSelectionProvider(selProvider);
+ IContextService service = (IContextService) site.getSite().getWorkbenchWindow().getService(IContextService.class);
+ service.activateContext("org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"); //$NON-NLS-1$
+ service.activateContext(IContextIds.CONTEXT_ID_WINDOW);
+ }
+
+ /**
+ * Returns the GraphNode overView the mouse if any
+ *
+ * @return the current graph node
+ * */
+ public GraphNode getMouseOverNode() {
+ return currentGraphNode;
+ }
+
+ /**
+ * Sets the zoom in mode.
+ *
+ * @param The mode value to set.
+ */
+ public void setZoomInMode(boolean value) {
+ if (value) {
+ setZoomOutMode(false);
+ }
+ zoomInMode = value;
+ }
+
+ /**
+ * Sets the zoom out mode.
+ *
+ * @param The mode value to set.
+ */
+ public void setZoomOutMode(boolean value) {
+ if (value) {
+ setZoomInMode(false);
+ }
+ zoomOutMode = value;
+ }
+
+ /**
+ * Moves the Sequence diagram to ensure the given node is visible and draw it selected
+ *
+ * @param node the GraphNode to move to
+ */
+ public void moveTo(GraphNode node) {
+ if (node == null) {
+ return;
+ }
+ clearSelection();
+ addSelection(node);
+ ensureVisible(node);
+ }
+
+ /**
+ * Moves the Sequence diagram to ensure the given node is visible
+ *
+ * @param node the GraphNode to move to
+ */
+ public void ensureVisible(GraphNode node) {
+ if (node == null) {
+ return;
+ }
+ int x = Math.round(node.getX() * zoomValue);
+ int y = Math.round(node.getY() * zoomValue);
+ int width = Math.round(node.getWidth() * zoomValue);
+ int height = Math.round(node.getHeight() * zoomValue);
+ if (node instanceof BaseMessage) {
+ if (height == 0) {
+ int header = Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN * 2 + Metrics.getLifelineHeaderFontHeigth();
+ height = -Math.round((Metrics.getMessagesSpacing() + header) * zoomValue);
+ y = y + Math.round(Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT * zoomValue);
+ }
+ }
+ if (node instanceof BasicExecutionOccurrence) {
+ width = 1;
+ height = 1;
+ }
+ if (node instanceof Lifeline) {
+ y = getContentsY();
+ height = getVisibleHeight();
+ }
+ ensureVisible(x, y, width, height, SWT.CENTER, true);
+ redraw();
+ }
+
+ /**
+ * Returns the current zoom factor.
+ * @return the current zoom factor.
+ */
+ public float getZoomFactor() {
+ return zoomValue;
+ }
+
+ /**
+ * Returns teh printer reference.
+ *
+ * @return the printer reference
+ */
+ public Printer getPrinter() {
+ return printer;
+ }
+
+ /**
+ * Returns whether the widget is used for printing or not.
+ *
+ * @return whether the widget is used for printing or not
+ */
+ public boolean isPrinting() {
+ return printing;
+ }
+
+ /**
+ * Gets the overview image.
+ *
+ * @param rect Rectangle to include overview.
+ * @return the overview image
+ */
+ public Image getOverview(Rectangle rect) {
+ float oldzoom = zoomValue;
+ if ((overView != null) && ((rect.width != overView.getBounds().width) || (rect.height != overView.getBounds().height))) {
+ overView.dispose();
+ overView = null;
+ }
+ if (overView == null) {
+ int backX = getContentsX();
+ int backY = getContentsY();
+ setContentsPos(0, 0);
+ overView = new Image(getDisplay(), rect.width, rect.height);
+ GC gcim = new GC(overView);
+ NGC context = new NGC(this, gcim);
+ context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+ frame.draw(context);
+ setContentsPos(backX, backY);
+ gcim.dispose();
+ context.dispose();
+ }
+ zoomValue = oldzoom;
+ return overView;
+ }
+
+ /**
+ * Resets the zoom factor.
+ */
+ public void resetZoomFactor() {
+ int currentX = Math.round(getContentsX() / zoomValue);
+ int currentY = Math.round(getContentsY() / zoomValue);
+ zoomValue = 1;
+ if (timeBar != null && !timeBar.isDisposed()) {
+ timeBar.setZoom(zoomValue);
+ }
+ redraw();
+ update();
+ setContentsPos(currentX, currentY);
+ }
+
+ /**
+ * Enable or disable the lifeline reodering using Drag and Drop
+ *
+ * @param mode - true to enable false otherwise
+ */
+ public void setReorderMode(boolean mode) {
+ reorderMode = mode;
+ }
+
+ /**
+ * Return the lifelines reorder sequence (using Drag and Drop) if the the reorder mode is turn on. Each ArryList
+ * element is of type Lifeline[2] with Lifeline[0] inserted before Lifeline[1] in the diagram
+ *
+ * @return - the re-odered sequence
+ */
+ public ArrayList getLifelineReoderList() {
+ return reorderList;
+ }
+
+ /**
+ * Sets the focus on given graph node (current node).
+ *
+ * @param the graph node to focus on.
+ */
+ public void setFocus(GraphNode node) {
+ if (node == null) {
+ return;
+ }
+ if (currentGraphNode != null) {
+ currentGraphNode.setFocused(false);
+ }
+ currentGraphNode = node;
+ node.setFocused(true);
+ ensureVisible(node);
+ setFocus(0);
+ }
+
+ /**
+ * Returns the graph node focused on.
+ *
+ * @return the current graph node
+ */
+ public GraphNode getFocusNode() {
+ return currentGraphNode;
+ }
+
+ /**
+ * Method to traverse right.
+ */
+ public void traverseRight() {
+ Object selectedNode = getFocusNode();
+ if (selectedNode == null) {
+ traverseLeft();
+ }
+ GraphNode node = null;
+ if (selectedNode instanceof BaseMessage) {
+ if (((BaseMessage) selectedNode).getEndLifeline() != null) {
+ node = frame.getCalledMessage((BaseMessage) selectedNode);
+ }
+ }
+ if (selectedNode instanceof BasicExecutionOccurrence) {
+ selectedNode = ((BasicExecutionOccurrence) selectedNode).getLifeline();
+ }
+ if ((node == null) && (selectedNode instanceof Lifeline)) {
+ for (int i = 0; i < frame.lifeLinesCount(); i++) {
+ if ((selectedNode == frame.getLifeline(i)) && (i < frame.lifeLinesCount() - 1)) {
+ node = frame.getLifeline(i + 1);
+ break;
+ }
+ }
+ }
+ if (node != null) {
+ setFocus(node);
+ redraw();
+ }
+ }
+
+ /**
+ * Method to traverse left.
+ */
+ public void traverseLeft() {
+ Object selectedNode = getFocusNode();
+ GraphNode node = null;
+ if (selectedNode instanceof BaseMessage) {
+ if (((BaseMessage) selectedNode).getStartLifeline() != null) {
+ node = frame.getCallerMessage((BaseMessage) selectedNode);
+ }
+ }
+ if (selectedNode instanceof BasicExecutionOccurrence) {
+ selectedNode = ((BasicExecutionOccurrence) selectedNode).getLifeline();
+ }
+ if (node == null) {
+ if (selectedNode instanceof BaseMessage) {
+ if (((BaseMessage) selectedNode).getEndLifeline() != null) {
+ selectedNode = ((BaseMessage) selectedNode).getEndLifeline();
+ }
+ }
+ for (int i = 0; i < frame.lifeLinesCount(); i++) {
+ if ((selectedNode == frame.getLifeline(i)) && (i > 0)) {
+ node = frame.getLifeline(i - 1);
+ break;
+ }
+ }
+ if ((frame.lifeLinesCount() > 0) && (node == null)) {
+ node = frame.getLifeline(0);
+ }
+ }
+ if (node != null) {
+ setFocus(node);
+ redraw();
+ }
+ }
+
+ /**
+ * Method to traverse up.
+ */
+ public void traverseUp() {
+ Object selectedNode = getFocusNode();
+ if (selectedNode == null) {
+ traverseLeft();
+ }
+ GraphNode node = null;
+ if (selectedNode instanceof BaseMessage) {
+ node = frame.getPrevLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), (BaseMessage) selectedNode);
+ } else if (selectedNode instanceof Lifeline) {
+ node = frame.getPrevLifelineMessage((Lifeline) selectedNode, null);
+ if (!(node instanceof Lifeline)) {
+ node = null;
+ }
+ } else if (selectedNode instanceof BasicExecutionOccurrence) {
+ node = frame.getPrevExecOccurrence((BasicExecutionOccurrence) selectedNode);
+ if (node == null) {
+ node = ((BasicExecutionOccurrence) selectedNode).getLifeline();
+ }
+ }
+ if (node == null) {
+ if (selectedNode instanceof BaseMessage) {
+ if (((BaseMessage) selectedNode).getStartLifeline() != null) {
+ node = ((BaseMessage) selectedNode).getStartLifeline();
+ }
+ }
+ }
+
+ if (node != null) {
+ setFocus(node);
+ redraw();
+ }
+ }
+
+ /**
+ * Method to traverse down.
+ */
+ public void traverseDown() {
+ Object selectedNode = getFocusNode();
+ if (selectedNode == null) {
+ traverseLeft();
+ }
+ GraphNode node;
+ if (selectedNode instanceof BaseMessage) {
+ node = frame.getNextLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), (BaseMessage) selectedNode);
+ } else if (selectedNode instanceof Lifeline) {
+ // node = frame.getNextLifelineMessage((Lifeline)selectedNode,null);
+ node = frame.getFirstExecution((Lifeline) selectedNode);
+ } else if (selectedNode instanceof BasicExecutionOccurrence) {
+ node = frame.getNextExecOccurrence((BasicExecutionOccurrence) selectedNode);
+ } else {
+ return;
+ }
+
+ if (node != null) {
+ setFocus(node);
+ redraw();
+ }
+ }
+
+ /**
+ * Method to traverse home.
+ */
+ public void traverseHome() {
+ Object selectedNode = getFocusNode();
+ if (selectedNode == null) {
+ traverseLeft();
+ }
+ GraphNode node = null;
+
+ if (selectedNode instanceof BaseMessage) {
+ if (((BaseMessage) selectedNode).getStartLifeline() != null) {
+ node = frame.getNextLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), null);
+ } else {
+ node = frame.getNextLifelineMessage(((BaseMessage) selectedNode).getEndLifeline(), null);
+ }
+ } else if (selectedNode instanceof Lifeline) {
+ node = frame.getNextLifelineMessage((Lifeline) selectedNode, null);
+ } else if (selectedNode instanceof BasicExecutionOccurrence) {
+ node = frame.getFirstExecution(((BasicExecutionOccurrence) selectedNode).getLifeline());
+ } else {
+ if (frame.lifeLinesCount() > 0) {
+ Lifeline lifeline = frame.getLifeline(0);
+ node = frame.getNextLifelineMessage(lifeline, null);
+ }
+ }
+
+ if (node != null) {
+ setFocus(node);
+ redraw();
+ }
+ }
+
+ /**
+ * Method to traverse to the end.
+ */
+ public void traverseEnd() {
+ Object selectedNode = getFocusNode();
+ if (selectedNode == null) {
+ traverseLeft();
+ }
+ GraphNode node;
+ if (selectedNode instanceof BaseMessage) {
+ node = frame.getPrevLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), null);
+ } else if (selectedNode instanceof Lifeline) {
+ node = frame.getPrevLifelineMessage((Lifeline) selectedNode, null);
+ } else if (selectedNode instanceof BasicExecutionOccurrence) {
+ node = frame.getLastExecOccurrence(((BasicExecutionOccurrence) selectedNode).getLifeline());
+ } else {
+ if (frame.lifeLinesCount() > 0) {
+ Lifeline lifeline = frame.getLifeline(0);
+ node = frame.getPrevLifelineMessage(lifeline, null);
+ } else {
+ return;
+ }
+ }
+
+ if (node != null) {
+ setFocus(node);
+ redraw();
+ }
+ }
+
+ /**
+ * Method to print UI.
+ *
+ * @param sdPrintDialog the sequence diagram printer dialog.
+ */
+ public void printUI(SDPrintDialogUI sdPrintDialog) {
+ PrinterData data = sdPrintDialog.getPrinterData();
+
+ if ((data == null) || (frame == null)) {
+ return;
+ }
+
+ printer = new Printer(data);
+
+ String jobName = MessageFormat.format(SDMessages._116, new Object[] { String.valueOf(site.getContentDescription()), String.valueOf(frame.getName()) });
+ printer.startJob(jobName);
+
+ GC gc = new GC(printer);
+ Frame.setUserPref(SDViewPref.getInstance());
+
+ float lastZoom = zoomValue;
+
+ Rectangle area = getClientArea();
+ GC gcim = null;
+
+ gcim = gc;
+ NGC context = new NGC(this, gcim);
+
+ // Set the metrics to use for lifeline text and message text
+ // using the Graphical Context
+ Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
+ Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
+ Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
+ Metrics.setFrameFontHeight(context.getFontHeight(Frame.getUserPref().getFont(ISDPreferences.PREF_FRAME_NAME)));
+ Metrics.setLifelineHeaderFontHeight(context.getFontHeight(Frame.getUserPref().getFont(ISDPreferences.PREF_LIFELINE_HEADER)));
+
+ int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS));
+ int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS_RET));
+ int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS));
+ int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS_RET));
+
+ int messageFontHeight = 0;
+ if (syncMessFontH > syncMessRetFontH) {
+ messageFontHeight = syncMessFontH;
+ } else {
+ messageFontHeight = syncMessRetFontH;
+ }
+ if (messageFontHeight < asyncMessFontH) {
+ messageFontHeight = asyncMessFontH;
+ }
+ if (messageFontHeight < asyncMessRetFontH) {
+ messageFontHeight = asyncMessRetFontH;
+ }
+ Metrics.setMessageFontHeight(messageFontHeight);
+ context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+
+ int width = Math.round((frame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * zoomValue);
+ int height = Math.round((frame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * zoomValue);
+ if (width < area.width) {
+ width = area.width;
+ }
+ if (height < area.height) {
+ height = area.height;
+ }
+ resizeContents(width, height);
+
+ context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_FRAME));
+ context.fillRectangle(0, 0, getContentsWidth(), Metrics.FRAME_V_MARGIN);
+ context.fillRectangle(0, 0, frame.getX(), getContentsHeight());
+ context.fillRectangle(frame.getX() + frame.getWidth() + 1, 0, getContentsWidth() - (frame.getX() + frame.getWidth() + 1), getContentsHeight());
+ context.fillRectangle(0, frame.getY() + frame.getHeight() + 1, getContentsWidth(), getContentsHeight() - (frame.getY() + frame.getHeight() + 1));
+ gcim.setLineWidth(1);
+
+ printer.startPage();
+ zoomValue = lastZoom;
+
+ int restoreX = getContentsX();
+ int restoreY = getContentsY();
+
+ float zh = getContentsHeight();
+ float zw = getContentsWidth();
+
+ zh = sdPrintDialog.getStepY() * sdPrintDialog.getZoomFactor();
+ zw = sdPrintDialog.getStepX() * sdPrintDialog.getZoomFactor();
+
+ float zoomValueH = printer.getClientArea().height / zh;
+ float zoomValueW = printer.getClientArea().width / zw;
+ if (zoomValueH > zoomValueW) {
+ printerZoom = zoomValueH;
+ } else {
+ printerZoom = zoomValueW;
+ }
+
+ if (sdPrintDialog.printSelection()) {
+ int[] pagesList = sdPrintDialog.getPageList();
+
+ for (int pageIndex = 0; pageIndex < pagesList.length; pageIndex++) {
+ printPage(pagesList[pageIndex], sdPrintDialog, context);
+ }
+ } else if (sdPrintDialog.printAll()) {
+ for (int pageIndex = 1; pageIndex <= sdPrintDialog.maxNumOfPages(); pageIndex++) {
+ printPage(pageIndex, sdPrintDialog, context);
+ }
+ } else if (sdPrintDialog.printCurrent()) {
+ printPage(getContentsX(), getContentsY(), sdPrintDialog, context, 1);
+ } else if (sdPrintDialog.printRange()) {
+ for (int pageIndex = sdPrintDialog.getFrom(); pageIndex <= sdPrintDialog.maxNumOfPages() && pageIndex <= sdPrintDialog.getTo(); pageIndex++) {
+ printPage(pageIndex, sdPrintDialog, context);
+ }
+ }
+
+ printer.endJob();
+ printing = false;
+
+ gc.dispose();
+ context.dispose();
+
+ zoomValue = lastZoom;
+ printer.dispose();
+ setContentsPos(restoreX, restoreY);
+ }
+
+ /**
+ * Method to print.
+ */
+ public void print() {
+ SDPrintDialog sdPrinter = new SDPrintDialog(this.getShell(), this);
+ try {
+ if (sdPrinter.open() != 0) {
+ return;
+ }
+ } catch (Exception e) {
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error creating image", e)); //$NON-NLS-1$
+ return;
+ }
+ printUI(sdPrinter.getDialogUI());
+ }
+
+ /**
+ * Method to print a page.
+ *
+ * @param pageNum The page number
+ * @param pd The sequence diagram print dialog
+ * @param context The graphical context
+ */
+ public void printPage(int pageNum, SDPrintDialogUI pd, NGC context) {
+ int j = pageNum / pd.getNbRow();
+ int i = pageNum % pd.getNbRow();
+ if (i != 0) {
+ j++;
+ } else {
+ i = pd.getNbRow();
+ }
+
+ i--;
+ j--;
+
+ i = (int) (i * pd.getStepX());
+ j = (int) (j * pd.getStepY());
+
+ printPage(i, j, pd, context, pageNum);
+
+ printer.endPage();
+ }
+
+ /**
+ * Method to print page ranges.
+ *
+ * @param i The start page
+ * @param j The end page
+ * @param pd The sequence diagram print dialog
+ * @param context The graphical context
+ * @param pageNum int the current page
+ */
+ public void printPage(int i, int j, SDPrintDialogUI pd, NGC context, int pageNum) {
+ printing = false;
+ int pageNumFontZoom = printer.getClientArea().height / getVisibleHeight();
+ printerX = i;
+ printerY = j;
+ setContentsPos(i, j);
+ update();
+ printing = true;
+ float lastZoom = zoomValue;
+ zoomValue = printerZoom * lastZoom;
+
+ frame.draw(context);
+
+ zoomValue = pageNumFontZoom;
+ context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+ String currentPageNum = String.valueOf(pageNum);
+ int ii = context.textExtent(currentPageNum);
+ int jj = context.getCurrentFontHeight();
+ // context.setBackground(ColorImpl.getSystemColor(SWT.COLOR_BLACK));
+ // context.setForeground(ColorImpl.getSystemColor(SWT.COLOR_WHITE));
+ zoomValue = printerZoom * lastZoom;
+ context.drawText(currentPageNum, Math.round(printerX + getVisibleWidth() / printerZoom - ii / printerZoom), Math.round(printerY + getVisibleHeight() / printerZoom - jj / printerZoom), false);
+ printing = false;
+ zoomValue = lastZoom;
+ }
+
+ /**
+ * Sets the collapse provider.
+ *
+ * @param provider The collapse provider to set
+ */
+ protected void setCollapseProvider(ISDCollapseProvider provider) {
+ collapseProvider = provider;
+ }
+
+
+ /**
+ * Checks for focus of children.
+ *
+ * @param children Control to check
+ * @return true if child is on focus else false
+ */
+ protected boolean checkFocusOnChilds(Control children) {
+ if (children instanceof Composite) {
+ Control[] child = ((Composite) children).getChildren();
+ for (int i = 0; i < child.length; i++) {
+ if (child[i].isFocusControl()) {
+ return true;
} else {
- toolTip.showToolTip(graphNode.getName() + postfix);
- setFocus(0);
+ checkFocusOnChilds(child[i]);
}
- } else
- toolTip.hideToolTip();
+ }
}
+ return false;
}
+ /**
+ * A post action for a tooltip (before displaying).
+ *
+ * @param accessible true if accessible else false
+ * @return the tooltip text.
+ */
protected String getPostfixForTooltip(boolean accessible) {
String postfix = "";//$NON-NLS-1$
// Determine if the tooltip must show the time difference between the current mouse position and
@@ -605,275 +1252,31 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
if (firstTime != null) {
if (lastTime != null && firstTime.compareTo(lastTime, true) != 0) {
postfix += "start: " + firstTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
- postfix += "end: " + lastTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- postfix += firstTime.toString();
- }
- }
- else if (lastTime != null) {
- postfix += lastTime.toString();
- }
- }
- }
- return postfix;
- }
-
- protected void setFocus(int newFocusShape) {
- focusedWidget = newFocusShape;
- if (focusedWidget == -1) {
- getViewControl().getAccessible().setFocus(ACC.CHILDID_SELF);
- } else {
- getViewControl().getAccessible().setFocus(focusedWidget);
- }
- }
-
- /** Timer for auto_scroll feature */
- protected AutoScroll local_auto_scroll_ = null;
- /** TimerTask for auto_scroll feature !=null when auto scroll is running */
- protected Timer local_auto_scroll_timer_ = null;
-
- /** TimerTask for auto scroll feature. */
- protected static class AutoScroll extends TimerTask {
- public int dx_, dy_;
- public SDWidget sv_;
-
- public AutoScroll(SDWidget _sv, int _dx, int _dy) {
- sv_ = _sv;
- dx_ = _dx;
- dy_ = _dy;
- }
-
- @Override
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (sv_.isDisposed())
- return;
- sv_.dragX += dx_;
- sv_.dragY += dy_;
- sv_.scrollBy(dx_, dy_);
- }
- });
- }
- }
-
- @Override
- protected void contentsMouseMoveEvent(MouseEvent e) {
- scrollToolTip.hideToolTip();
- toolTip.hideToolTip();
- // super.contentsMouseMoveEvent(e);
- if (!(isFocusControl() || getViewControl().isFocusControl())) {
- Control[] child = getParent().getChildren();
- for (int i = 0; i < child.length; i++) {
- if (child[i].isFocusControl()) {
- if (!(child[i] instanceof ScrollView)) {
- getViewControl().setFocus();
- break;
- }
- }
- }
- }
- setFocus(-1);
-
- if (((e.stateMask & SWT.BUTTON_MASK) != 0) && ((dragAndDrop != null) || getDragAndDrop) && (reorderMode || collapseProvider != null)) {
- getDragAndDrop = false;
- if (currentGraphNode instanceof Lifeline)
- dragAndDrop = (Lifeline) currentGraphNode;
- if (dragAndDrop != null) {
- int dx = 0;
- int dy = 0;
- if (e.x > getContentsX() + getVisibleWidth()) {
- dx = e.x - (getContentsX() + getVisibleWidth());
- } else if (e.x < getContentsX()) {
- dx = -getContentsX() + e.x;
- }
- if (e.y > getContentsY() + getVisibleHeight()) {
- dy = e.y - (getContentsY() + getVisibleHeight());
- } else if (e.y < getContentsY()) {
- dy = -getContentsY() + e.y;
- }
- dragX = e.x;
- dragY = e.y;
- if (dx != 0 || dy != 0) {
- if (local_auto_scroll_ == null) {
- if (local_auto_scroll_timer_ == null) {
- local_auto_scroll_timer_ = new Timer(true);
- }
- local_auto_scroll_ = new AutoScroll(this, dx, dy);
- local_auto_scroll_timer_.schedule(local_auto_scroll_, 0, 75);
- } else {
- local_auto_scroll_.dx_ = dx;
- local_auto_scroll_.dy_ = dy;
- }
- } else if (local_auto_scroll_ != null) {
- local_auto_scroll_.cancel();
- local_auto_scroll_ = null;
- }
- dragX = Math.round(e.x / zoomValue);
- dragY = Math.round(e.y / zoomValue);
- redraw();
- Lifeline node = frame.getCloserLifeline(dragX);
- if ((node != null) && (node != dragAndDrop)) {
- int y = 0;
- int y1 = 0;
- int height = Metrics.getLifelineHeaderFontHeigth() + 2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN;
- int hMargin = Metrics.LIFELINE_VT_MAGIN / 4;
- int x = node.getX();
- int width = node.getWidth();
- if (frame.getVisibleAreaY() < node.getY() + node.getHeight() - height - hMargin)
- y = contentsToViewY(Math.round((node.getY() + node.getHeight()) * zoomValue));
- else
- y = Math.round(height * zoomValue);
-
- if (frame.getVisibleAreaY() < contentsToViewY(node.getY() - hMargin))
- y1 = contentsToViewY(Math.round((node.getY() - hMargin) * zoomValue));
- else
- y1 = Math.round(height * zoomValue);
-
- int rx = Math.round(x * zoomValue);
-
- insertionCartet.setVisible(true);
- if ((insertionCartet.getImage() != null) && (!insertionCartet.getImage().isDisposed()))
- insertionCartet.getImage().dispose();
- if (rx <= e.x && Math.round(rx + (width * zoomValue)) >= e.x) {
- if (collapseProvider != null) {
- ImageData data = collapaseCaretImg.getImageData();
- data = data.scaledTo(Math.round(collapaseCaretImg.getBounds().width * zoomValue), Math.round(collapaseCaretImg.getBounds().height * zoomValue));
- currentCaretImage = new Image(Display.getCurrent(), data);
- insertionCartet.setImage(currentCaretImage);
- insertionCartet.setLocation(contentsToViewX(rx + Math.round((width / (float) 2) * zoomValue)) - currentCaretImage.getBounds().width / 2, y);
- }
- } else if (reorderMode) {
- if (rx > e.x) {
- if (node.getIndex() > 1 && frame.getLifeline(node.getIndex() - 2) == dragAndDrop)
- return;
- ImageData data = arrowUpCaretImg.getImageData();
- data = data.scaledTo(Math.round(arrowUpCaretImg.getBounds().width * zoomValue), Math.round(arrowUpCaretImg.getBounds().height * zoomValue));
- currentCaretImage = new Image(Display.getCurrent(), data);
- insertionCartet.setImage(currentCaretImage);
- insertionCartet.setLocation(contentsToViewX(Math.round((x - Metrics.LIFELINE_SPACING / 2) * zoomValue)) - currentCaretImage.getBounds().width / 2, y1);
- } else {
- if (node.getIndex() < frame.lifeLinesCount() && frame.getLifeline(node.getIndex()) == dragAndDrop)
- return;
- ImageData data = arrowUpCaretImg.getImageData();
- data = data.scaledTo(Math.round(arrowUpCaretImg.getBounds().width * zoomValue), Math.round(arrowUpCaretImg.getBounds().height * zoomValue));
- currentCaretImage = new Image(Display.getCurrent(), data);
- insertionCartet.setImage(currentCaretImage);
- insertionCartet.setLocation(contentsToViewX(Math.round((x + width + Metrics.LIFELINE_SPACING / 2) * zoomValue)) - currentCaretImage.getBounds().width / 2 + 1, y1);
- }
- }
- } else
- insertionCartet.setVisible(false);
- }
- } else
- super.contentsMouseMoveEvent(e);
- }
-
- @Override
- protected void contentsMouseUpEvent(MouseEvent event) {
- // Just in case the diagram highlight a time compression region
- // this region need to be released when clicking everywhere
- insertionCartet.setVisible(false);
- if (dragAndDrop != null) {
- if ((overView != null) && (!overView.isDisposed()))
- overView.dispose();
- overView = null;
- Lifeline node = frame.getCloserLifeline(dragX);
- if (node != null) {
- int rx = Math.round(node.getX() * zoomValue);
- if (rx <= event.x && Math.round(rx + (node.getWidth() * zoomValue)) >= event.x) {
- if ((collapseProvider != null) && (dragAndDrop != node))
- collapseProvider.collapseTwoLifelines((Lifeline) dragAndDrop, node);
- } else if (rx < event.x) {
- frame.insertLifelineAfter((Lifeline) dragAndDrop, node);
- if (node.getIndex() < frame.lifeLinesCount()) {
- Lifeline temp[] = { (Lifeline) dragAndDrop, frame.getLifeline(node.getIndex()) };
- reorderList.add(temp);
- } else {
- Lifeline temp[] = { (Lifeline) dragAndDrop, null };
- reorderList.add(temp);
- }
- } else {
- frame.insertLifelineBefore((Lifeline) dragAndDrop, node);
- Lifeline temp[] = { (Lifeline) dragAndDrop, node };
- reorderList.add(temp);
- }
- }
- }
- dragAndDrop = null;
- redraw();
- if (frame == null) {
- return;
- }
- frame.resetTimeCompression();
-
- // reset auto scroll if it's engaged
- if (local_auto_scroll_ != null) {
- local_auto_scroll_.cancel();
- local_auto_scroll_ = null;
- }
- super.contentsMouseUpEvent(event);
- }
-
- @Override
- protected void contentsMouseDownEvent(MouseEvent event) {
- if (currentGraphNode != null)
- currentGraphNode.setFocused(false);
- // Just in case the diagram highlight a time compression region
- // this region need to be released when clicking everywhere
- if (frame == null) {
- return;
- }
- frame.resetTimeCompression();
-
- if ((event.stateMask & SWT.CTRL) != 0) {
- ctrlSelection = true;
- } else
- ctrlSelection = false;
-
- if (((zoomInMode) || (zoomOutMode)) && (event.button == 1)) {
- int cx = Math.round(event.x / zoomValue);
- int cy = Math.round(event.y / zoomValue);
- if (zoomInMode) {
- if (zoomValue < 64)
- zoomValue = zoomValue * (float) 1.25;
- } else
- zoomValue = zoomValue / (float) 1.25;
- int x = Math.round(cx * zoomValue - getVisibleWidth() / (float) 2);
- int y = Math.round(cy * zoomValue - getVisibleHeight() / (float) 2);
- setContentsPos(x, y);
- if (timeBar != null)
- timeBar.setZoom(zoomValue);
- // redraw also resize the scrollView content
- redraw();
- } else// if (event.button ==1)
- {
- GraphNode node = null;
- if (frame != null) {
- int x = Math.round(event.x / zoomValue);
- int y = Math.round(event.y / zoomValue);
- node = frame.getNodeAt(x, y);
-
- if ((event.button == 1) || ((node != null) && !node.isSelected())) {
- if (!shiftSelection)
- listStart = node;
- if (shiftSelection) {
- clearSelection();
- addSelection(frame.getNodeList(listStart, node));
- } else
- performSelection(node);
- currentGraphNode = node;
- if (node != null)
- node.setFocused(true);
+ postfix += "end: " + lastTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ postfix += firstTime.toString();
+ }
+ }
+ else if (lastTime != null) {
+ postfix += lastTime.toString();
}
- redraw();
}
}
- if (dragAndDrop == null)
- super.contentsMouseDownEvent(event);
- getDragAndDrop = (event.button == 1);
+ return postfix;
+ }
+ /**
+ * Sets a new focused widget.
+ *
+ * @param newFocusShape A new focus shape.
+ */
+ protected void setFocus(int newFocusShape) {
+ focusedWidget = newFocusShape;
+ if (focusedWidget == -1) {
+ getViewControl().getAccessible().setFocus(ACC.CHILDID_SELF);
+ } else {
+ getViewControl().getAccessible().setFocus(focusedWidget);
+ }
}
/**
@@ -890,8 +1293,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
} else {
addSelection(node);
}
- } else
+ } else {
return;
+ }
} else {
clearSelection();
if (node != null) {
@@ -900,73 +1304,12 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
}
}
- public List getSelection() {
- return selectedNodeList;
- }
-
- public void addSelection(GraphNode node) {
- if (node == null)
- return;
- selectedNodeList.add(node);
- node.setSelected(true);
- currentGraphNode = node;
- StructuredSelection selection = new StructuredSelection(selectedNodeList);
- selProvider.setSelection(selection);
- }
-
- public void addSelection(List list) {
- // selectedNodeList.addAll(list);
- for (int i = 0; i < list.size(); i++) {
- if (!selectedNodeList.contains(list.get(i))) {
- selectedNodeList.add(list.get(i));
- ((GraphNode) list.get(i)).setSelected(true);
- }
- }
- StructuredSelection selection = new StructuredSelection(selectedNodeList);
- selProvider.setSelection(selection);
- }
-
- public void removeSelection(GraphNode node) {
- selectedNodeList.remove(node);
- node.setSelected(false);
- node.setFocused(false);
- StructuredSelection selection = new StructuredSelection(selectedNodeList);
- selProvider.setSelection(selection);
- }
-
- public void removeSelection(List list) {
- selectedNodeList.removeAll(list);
- for (int i = 0; i < list.size(); i++) {
- ((GraphNode) list.get(i)).setSelected(false);
- ((GraphNode) list.get(i)).setFocused(false);
- }
- StructuredSelection selection = new StructuredSelection(selectedNodeList);
- selProvider.setSelection(selection);
- }
-
/**
- * Clear the list of GraphNodes which must be drawn selected
+ * Returns a draw buffer image.
*
+ * @return a Image containing the draw buffer.
*/
- public void clearSelection() {
- for (int i = 0; i < selectedNodeList.size(); i++) {
- ((GraphNode) selectedNodeList.get(i)).setSelected(false);
- ((GraphNode) selectedNodeList.get(i)).setFocused(false);
- }
- currentGraphNode = null;
- selectedNodeList.clear();
- selProvider.setSelection(new StructuredSelection());
- }
-
- public void setSite(ViewPart viewSite) {
- site = viewSite;
- site.getSite().setSelectionProvider(selProvider);
- IContextService service = (IContextService) site.getSite().getWorkbenchWindow().getService(IContextService.class);
- service.activateContext("org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"); //$NON-NLS-1$
- service.activateContext(IContextIds.CONTEXT_ID_WINDOW);
- }
-
- protected Image getDrawBuffer(GC gc) {
+ protected Image getDrawBuffer() {
update();
Rectangle area = getClientArea();
@@ -974,12 +1317,11 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
GC gcim = null;
try {
- // if (dbuffer!=null)
- // dbuffer.dispose();
dbuffer = new Image(getDisplay(), area.width, area.height);
} catch (Exception e) {
- System.out.println(e.toString());
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error creating image", e)); //$NON-NLS-1$
}
+
gcim = new GC(dbuffer);
NGC context = new NGC(this, gcim);
@@ -998,23 +1340,23 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS_RET));
int messageFontHeight = 0;
- if (syncMessFontH > syncMessRetFontH)
+ if (syncMessFontH > syncMessRetFontH) {
messageFontHeight = syncMessFontH;
- else
+ } else {
messageFontHeight = syncMessRetFontH;
- if (messageFontHeight < asyncMessFontH)
+ }
+ if (messageFontHeight < asyncMessFontH) {
messageFontHeight = asyncMessFontH;
- if (messageFontHeight < asyncMessRetFontH)
+ }
+ if (messageFontHeight < asyncMessRetFontH) {
messageFontHeight = asyncMessRetFontH;
+ }
Metrics.setMessageFontHeight(messageFontHeight);
context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
int width = (int) ((frame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * zoomValue);
int height = (int) ((frame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * zoomValue);
- // if (width();
+ prevList.addAll(getSelection());
+ }
- try {
- gc.drawImage(dbuffer, 0, 0, area.width, area.height, 0, 0, area.width, area.height);
- } catch (Exception e) {
- System.out.println(e.getMessage());
+ GraphNode prevNode = getFocusNode();
+
+ if (event.keyCode == SWT.ARROW_RIGHT) {
+ traverseRight();
}
- dbuffer.dispose();
- setHScrollBarIncrement(Math.round(SDViewPref.getInstance().getLifelineWidth() / (float) 2 * zoomValue));
- setVScrollBarIncrement(Math.round(Metrics.getMessagesSpacing() * zoomValue));
- if ((timeBar != null) && (frame.hasTimeInfo())) {
- timeBar.resizeContents(9, height + getHorizontalBarHeight());
- timeBar.setContentsPos(getContentsX(), getContentsY());
- timeBar.redraw();
- timeBar.update();
+
+ if (event.keyCode == SWT.ARROW_LEFT) {
+ traverseLeft();
}
- float xRatio = getContentsWidth() / (float) getVisibleWidth();
- float yRatio = getContentsHeight() / (float) getVisibleHeight();
- if (yRatio > xRatio) {
- setOverviewSize((int) (getVisibleHeight() * 0.75));
- } else {
- setOverviewSize((int) (getVisibleWidth() * 0.75));
+
+ if (event.keyCode == SWT.ARROW_DOWN) {
+ traverseDown();
}
- }
- /**
- * Returns the GraphNode overView the mouse if any
- *
- * @return the GraphNode
- */
- public GraphNode getMouseOverNode() {
- return currentGraphNode;
- }
+ if (event.keyCode == SWT.ARROW_UP) {
+ traverseUp();
+ }
- @Override
- public void widgetDefaultSelected(SelectionEvent event) {
- }
+ if (event.keyCode == SWT.HOME) {
+ traverseHome();
+ }
- @Override
- public void widgetSelected(SelectionEvent event) {
- if (event.widget == zoomIn)
- zoomValue = zoomValue * 2;
- else if (event.widget == zoomOut)
- zoomValue = zoomValue / 2;
- else {
- // SearchFilterDialog tt = new SearchFilterDialog(null);//display.getActiveShell());
+ if (event.keyCode == SWT.END) {
+ traverseEnd();
}
- redraw();
- }
- public void setZoomInMode(boolean value) {
- if (value)
- setZoomOutMode(false);
- zoomInMode = value;
- }
+ if ((!shiftSelection) && (!ctrlSelection)) {
+ listStart = currentGraphNode;
+ }
- public void setZoomOutMode(boolean value) {
- if (value)
- setZoomInMode(false);
- zoomOutMode = value;
- }
+ if (event.character == ' ') {
+ performSelection(currentGraphNode);
+ if (!shiftSelection)
+ listStart = currentGraphNode;
+ }
- /**
- * Moves the Sequence diagram to ensure the given node is visible and draw it selected
- *
- * @param node the GraphNode to move to
- */
- public void moveTo(GraphNode node) {
- if (node == null)
- return;
- clearSelection();
- addSelection(node);
- ensureVisible(node);
- }
+ if ((shiftSelection) && (prevNode != getFocusNode())) {
+ clearSelection();
+ addSelection(prevList);
+ addSelection(frame.getNodeList(listStart, getFocusNode()));
+ if (getFocusNode() instanceof Lifeline) {
+ ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT.CENTER | SWT.VERTICAL, true);
+ } else {
+ ensureVisible(getFocusNode());
+ }
+ } else if ((!ctrlSelection) && (!shiftSelection)) {
- /**
- * Moves the Sequence diagram to ensure the given node is visible
- *
- * @param node the GraphNode to move to
- */
- public void ensureVisible(GraphNode node) {
- if (node == null)
- return;
- int x = Math.round(node.getX() * zoomValue);
- int y = Math.round(node.getY() * zoomValue);
- int width = Math.round(node.getWidth() * zoomValue);
- int height = Math.round(node.getHeight() * zoomValue);
- if (node instanceof BaseMessage) {
- if (height == 0) {
- int header = Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN * 2 + Metrics.getLifelineHeaderFontHeigth();
- height = -Math.round((Metrics.getMessagesSpacing() + header) * zoomValue);
- y = y + Math.round(Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT * zoomValue);
+ clearSelection();
+ if (getFocusNode() != null) {
+ addSelection(getFocusNode());
+
+ if (getFocusNode() instanceof Lifeline) {
+ ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT.CENTER | SWT.VERTICAL, true);
+ } else {
+ ensureVisible(getFocusNode());
+ }
}
}
- if (node instanceof BasicExecutionOccurrence) {
- width = 1;
- height = 1;
- }
- if (node instanceof Lifeline) {
- y = getContentsY();
- height = getVisibleHeight();
+
+ if (currentGraphNode != null) {
+ currentGraphNode.setFocused(true);
}
- ensureVisible(x, y, width, height, SWT.CENTER, true);
redraw();
- }
- public float getZoomFactor() {
- return zoomValue;
+ if ((event.character == ' ') && ((zoomInMode) || (zoomOutMode))) {
+ int cx = Math.round((getContentsX() + getVisibleWidth() / 2) / zoomValue);
+ int cy = Math.round((getContentsY() + getVisibleHeight() / 2) / zoomValue);
+ if (zoomInMode) {
+ if (zoomValue < 64) {
+ zoomValue = zoomValue * (float) 1.25;
+ }
+ } else {
+ zoomValue = zoomValue / (float) 1.25;
+ }
+ int x = Math.round(cx * zoomValue - getVisibleWidth() / (float) 2);
+ int y = Math.round(cy * zoomValue - getVisibleHeight() / (float) 2);
+ setContentsPos(x, y);
+ if (timeBar != null) {
+ timeBar.setZoom(zoomValue);
+ }
+ // redraw also resize the scrollView content
+ redraw();
+ }
}
- /**
- * Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply
- * button
- *
- * @param e the PropertyChangeEvent
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
*/
@Override
- public void propertyChange(PropertyChangeEvent e) {
- if (frame != null && !isDisposed()) {
- frame.resetTimeCompression();
- }
- if (e.getProperty().equals("PREFOK")) //$NON-NLS-1$
- {
- // Prepare the overview to be reused for the new
- // settings (especially the colors)
- if (overView != null)
- overView.dispose();
- overView = null;
- redraw();
- }
+ protected void keyReleasedEvent(KeyEvent event) {
+ setFocus(-1);
+ if (event.keyCode == SWT.CTRL)
+ ctrlSelection = false;
+ if (event.keyCode == SWT.SHIFT)
+ shiftSelection = false;
+ super.keyReleasedEvent(event);
+ setFocus(1);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Control#isFocusControl()
+ */
@Override
- public void widgetDisposed(DisposeEvent e) {
- if (overView != null)
- overView.dispose();
- super.removeDisposeListener(this);
- if ((currentCaretImage != null) && (!currentCaretImage.isDisposed()))
- currentCaretImage.dispose();
- if ((arrowUpCaretImg != null) && (!arrowUpCaretImg.isDisposed()))
- arrowUpCaretImg.dispose();
- if ((collapaseCaretImg != null) && (!collapaseCaretImg.isDisposed()))
- collapaseCaretImg.dispose();
- SDViewPref.getInstance().removePropertyChangeListener(this);
- LoadersManager lm = LoadersManager.getInstance();
- if (site != null && site instanceof SDView) {
- ((SDView) site).resetProviders();
- if (lm != null)
- lm.resetLoader(((SDView) site).getViewSite().getId());
+ public boolean isFocusControl() {
+ Control[] child = getChildren();
+ for (int i = 0; i < child.length; i++) {
+ if (child[i].isFocusControl()) {
+ return true;
+ } else {
+ checkFocusOnChilds(child[i]);
+ }
}
+ return false;
}
- public Image getOverview(Rectangle r) {
- float oldzoom = zoomValue;
- if ((overView != null) && ((r.width != overView.getBounds().width) || (r.height != overView.getBounds().height))) {
- overView.dispose();
- overView = null;
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#setContentsPos(int, int)
+ */
+ @Override
+ public boolean setContentsPos(int x, int y) {
+ if (x < 0) {
+ x = 0;
}
- if (overView == null) {
- int backX = getContentsX();
- int backY = getContentsY();
- setContentsPos(0, 0);
- overView = new Image(getDisplay(), r.width, r.height);
- GC gcim = new GC(overView);
- NGC context = new NGC(this, gcim);
- context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
- frame.draw(context);
- setContentsPos(backX, backY);
- gcim.dispose();
- context.dispose();
+ if (y < 0) {
+ y = 0;
}
- zoomValue = oldzoom;
- return overView;
- }
-
- @Override
- protected void drawOverview(GC gc, Rectangle r) {
- float oldzoom = zoomValue;
- if (getContentsWidth() > getContentsHeight())
- zoomValue = (float) r.width / (float) getContentsWidth() * oldzoom;
- else
- zoomValue = (float) r.height / (float) getContentsHeight() * oldzoom;
- if ((overView != null) && ((r.width != overView.getBounds().width) || (r.height != overView.getBounds().height))) {
- overView.dispose();
- overView = null;
+ if (frame == null) {
+ return false;
}
- if (overView == null) {
- int backX = getContentsX();
- int backY = getContentsY();
- setContentsPos(0, 0);
- overView = new Image(getDisplay(), r.width, r.height);
- GC gcim = new GC(overView);
- NGC context = new NGC(this, gcim);
- context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
- frame.draw(context);
- setContentsPos(backX, backY);
- gcim.dispose();
- context.dispose();
+ if (x + getVisibleWidth() > getContentsWidth()) {
+ x = getContentsWidth() - getVisibleWidth();
}
- if ((overView != null) && (r.width == overView.getBounds().width) && (r.height == overView.getBounds().height))
- gc.drawImage(overView, 0, 0, r.width, r.height, 0, 0, r.width, r.height);
+ if (y + getVisibleHeight() > getContentsHeight()) {
+ y = getContentsHeight() - getVisibleHeight();
+ }
+ int x1 = Math.round(x / zoomValue);
+ int y2 = Math.round(y / zoomValue);
+ int width = Math.round(getVisibleWidth() / zoomValue);
+ int height = Math.round(getVisibleHeight() / zoomValue);
+ frame.updateIndex(x1, y2, width, height);
- zoomValue = oldzoom;
+ if (insertionCartet != null && insertionCartet.isVisible()) {
+ insertionCartet.setVisible(false);
+ }
- super.drawOverview(gc, r);
+ return super.setContentsPos(x, y);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
+ */
@Override
- public void deltaSelected(Lifeline lifeline, int startEvent, int nbEvent, IColor color) {
- frame.highlightTimeCompression(lifeline, startEvent, nbEvent, color);
- ensureVisible(lifeline);
- int y1 = lifeline.getY() + lifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * startEvent;
- int y2 = lifeline.getY() + lifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * (startEvent + nbEvent);
- ensureVisible(lifeline.getX(), y1 - (Metrics.getLifelineHeaderFontHeigth() + +2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN), lifeline.getWidth(), y2 - y1 + 3, SWT.CENTER | SWT.VERTICAL, true);
- redraw();
- update();
- }
-
- public void resetZoomFactor() {
- int currentX = Math.round(getContentsX() / zoomValue);
- int currentY = Math.round(getContentsY() / zoomValue);
- zoomValue = 1;
- if (timeBar != null && !timeBar.isDisposed()) {
- timeBar.setZoom(zoomValue);
+ protected void contentsMouseHover(MouseEvent event) {
+ GraphNode graphNode = null;
+ if (frame != null) {
+ int x = Math.round(event.x / zoomValue);
+ int y = Math.round(event.y / zoomValue);
+ graphNode = frame.getNodeAt(x, y);
+ if ((graphNode != null) && (SDViewPref.getInstance().tooltipEnabled())) {
+ toolTipNode = graphNode;
+ String postfix = getPostfixForTooltip(true);
+ if (graphNode instanceof Lifeline) {
+ Lifeline lifeline = (Lifeline) graphNode;
+ toolTip.showToolTip(lifeline.getToolTipText() + postfix);
+ setFocus(0);
+ } else {
+ toolTip.showToolTip(graphNode.getName() + postfix);
+ setFocus(0);
+ }
+ } else {
+ toolTip.hideToolTip();
+ }
}
- redraw();
- update();
- setContentsPos(currentX, currentY);
- }
-
- /**
- * Enable or disable the lifeline reodering using Drag and Drop
- *
- * @param mode - true to enable false otherwise
- */
- public void setReorderMode(boolean mode) {
- reorderMode = mode;
}
- /**
- * Return the lifelines reorder sequence (using Drag and Drop) if the the reorder mode is turn on. Each ArryList
- * element is of type Lifeline[2] with Lifeline[0] inserted before Lifeline[1] in the diagram
- *
- * @return - the re-odered sequence
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
*/
- public ArrayList getLifelineReoderList() {
- return reorderList;
- }
-
- public void setFocus(GraphNode node) {
- if (node == null)
- return;
- if (currentGraphNode != null)
- currentGraphNode.setFocused(false);
- currentGraphNode = node;
- node.setFocused(true);
- ensureVisible(node);
- setFocus(0);
- }
+ @Override
+ protected void contentsMouseMoveEvent(MouseEvent e) {
+ scrollToolTip.hideToolTip();
+ toolTip.hideToolTip();
+ // super.contentsMouseMoveEvent(e);
+ if (!(isFocusControl() || getViewControl().isFocusControl())) {
+ Control[] child = getParent().getChildren();
+ for (int i = 0; i < child.length; i++) {
+ if (child[i].isFocusControl()) {
+ if (!(child[i] instanceof ScrollView)) {
+ getViewControl().setFocus();
+ break;
+ }
+ }
+ }
+ }
+ setFocus(-1);
- public GraphNode getFocusNode() {
- return currentGraphNode;
- }
+ if (((e.stateMask & SWT.BUTTON_MASK) != 0) && ((dragAndDrop != null) || getDragAndDrop) && (reorderMode || collapseProvider != null)) {
+ getDragAndDrop = false;
+ if (currentGraphNode instanceof Lifeline) {
+ dragAndDrop = (Lifeline) currentGraphNode;
+ }
+ if (dragAndDrop != null) {
+ int dx = 0;
+ int dy = 0;
+ if (e.x > getContentsX() + getVisibleWidth()) {
+ dx = e.x - (getContentsX() + getVisibleWidth());
+ } else if (e.x < getContentsX()) {
+ dx = -getContentsX() + e.x;
+ }
+ if (e.y > getContentsY() + getVisibleHeight()) {
+ dy = e.y - (getContentsY() + getVisibleHeight());
+ } else if (e.y < getContentsY()) {
+ dy = -getContentsY() + e.y;
+ }
+ dragX = e.x;
+ dragY = e.y;
+ if (dx != 0 || dy != 0) {
+ if (local_auto_scroll_ == null) {
+ if (local_auto_scroll_timer_ == null) {
+ local_auto_scroll_timer_ = new Timer(true);
+ }
+ local_auto_scroll_ = new AutoScroll(this, dx, dy);
+ local_auto_scroll_timer_.schedule(local_auto_scroll_, 0, 75);
+ } else {
+ local_auto_scroll_.dx_ = dx;
+ local_auto_scroll_.dy_ = dy;
+ }
+ } else if (local_auto_scroll_ != null) {
+ local_auto_scroll_.cancel();
+ local_auto_scroll_ = null;
+ }
+ dragX = Math.round(e.x / zoomValue);
+ dragY = Math.round(e.y / zoomValue);
+ redraw();
+ Lifeline node = frame.getCloserLifeline(dragX);
+ if ((node != null) && (node != dragAndDrop)) {
+ int y = 0;
+ int y1 = 0;
+ int height = Metrics.getLifelineHeaderFontHeigth() + 2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN;
+ int hMargin = Metrics.LIFELINE_VT_MAGIN / 4;
+ int x = node.getX();
+ int width = node.getWidth();
+ if (frame.getVisibleAreaY() < node.getY() + node.getHeight() - height - hMargin) {
+ y = contentsToViewY(Math.round((node.getY() + node.getHeight()) * zoomValue));
+ } else {
+ y = Math.round(height * zoomValue);
+ }
- public void traverseRight() {
- Object selectedNode = getFocusNode();
- if (selectedNode == null)
- traverseLeft();
- GraphNode node = null;
- if (selectedNode instanceof BaseMessage) {
- if (((BaseMessage) selectedNode).getEndLifeline() != null)
- node = frame.getCalledMessage((BaseMessage) selectedNode);
- }
- if (selectedNode instanceof BasicExecutionOccurrence) {
- selectedNode = ((BasicExecutionOccurrence) selectedNode).getLifeline();
- }
- if ((node == null) && (selectedNode instanceof Lifeline)) {
- // if (selectedNode instanceof BaseMessage)
- // {
- // if (((BaseMessage)selectedNode).getStartLifeline()!=null)
- // selectedNode = ((BaseMessage)selectedNode).getStartLifeline();
- // }
- for (int i = 0; i < frame.lifeLinesCount(); i++) {
- if ((selectedNode == frame.getLifeline(i)) && (i < frame.lifeLinesCount() - 1)) {
- node = frame.getLifeline(i + 1);
- break;
+ if (frame.getVisibleAreaY() < contentsToViewY(node.getY() - hMargin)) {
+ y1 = contentsToViewY(Math.round((node.getY() - hMargin) * zoomValue));
+ } else {
+ y1 = Math.round(height * zoomValue);
+ }
+
+ int rx = Math.round(x * zoomValue);
+
+ insertionCartet.setVisible(true);
+ if ((insertionCartet.getImage() != null) && (!insertionCartet.getImage().isDisposed())) {
+ insertionCartet.getImage().dispose();
+ }
+ if (rx <= e.x && Math.round(rx + (width * zoomValue)) >= e.x) {
+ if (collapseProvider != null) {
+ ImageData data = collapaseCaretImg.getImageData();
+ data = data.scaledTo(Math.round(collapaseCaretImg.getBounds().width * zoomValue), Math.round(collapaseCaretImg.getBounds().height * zoomValue));
+ currentCaretImage = new Image(Display.getCurrent(), data);
+ insertionCartet.setImage(currentCaretImage);
+ insertionCartet.setLocation(contentsToViewX(rx + Math.round((width / (float) 2) * zoomValue)) - currentCaretImage.getBounds().width / 2, y);
+ }
+ } else if (reorderMode) {
+ if (rx > e.x) {
+ if (node.getIndex() > 1 && frame.getLifeline(node.getIndex() - 2) == dragAndDrop) {
+ return;
+ }
+ ImageData data = arrowUpCaretImg.getImageData();
+ data = data.scaledTo(Math.round(arrowUpCaretImg.getBounds().width * zoomValue), Math.round(arrowUpCaretImg.getBounds().height * zoomValue));
+ currentCaretImage = new Image(Display.getCurrent(), data);
+ insertionCartet.setImage(currentCaretImage);
+ insertionCartet.setLocation(contentsToViewX(Math.round((x - Metrics.LIFELINE_SPACING / 2) * zoomValue)) - currentCaretImage.getBounds().width / 2, y1);
+ } else {
+ if (node.getIndex() < frame.lifeLinesCount() && frame.getLifeline(node.getIndex()) == dragAndDrop) {
+ return;
+ }
+ ImageData data = arrowUpCaretImg.getImageData();
+ data = data.scaledTo(Math.round(arrowUpCaretImg.getBounds().width * zoomValue), Math.round(arrowUpCaretImg.getBounds().height * zoomValue));
+ currentCaretImage = new Image(Display.getCurrent(), data);
+ insertionCartet.setImage(currentCaretImage);
+ insertionCartet.setLocation(contentsToViewX(Math.round((x + width + Metrics.LIFELINE_SPACING / 2) * zoomValue)) - currentCaretImage.getBounds().width / 2 + 1, y1);
+ }
+ }
+ } else {
+ insertionCartet.setVisible(false);
}
}
- }
- if (node != null) {
- setFocus(node);
- redraw();
+ } else {
+ super.contentsMouseMoveEvent(e);
}
}
- public void traverseLeft() {
- Object selectedNode = getFocusNode();
- GraphNode node = null;
- if (selectedNode instanceof BaseMessage) {
- if (((BaseMessage) selectedNode).getStartLifeline() != null)
- node = frame.getCallerMessage((BaseMessage) selectedNode);
- }
- if (selectedNode instanceof BasicExecutionOccurrence) {
- selectedNode = ((BasicExecutionOccurrence) selectedNode).getLifeline();
- }
- if (node == null) {
- if (selectedNode instanceof BaseMessage) {
- if (((BaseMessage) selectedNode).getEndLifeline() != null)
- selectedNode = ((BaseMessage) selectedNode).getEndLifeline();
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
+ */
+ @Override
+ protected void contentsMouseUpEvent(MouseEvent event) {
+ // Just in case the diagram highlight a time compression region
+ // this region need to be released when clicking everywhere
+ insertionCartet.setVisible(false);
+ if (dragAndDrop != null) {
+ if ((overView != null) && (!overView.isDisposed())) {
+ overView.dispose();
}
- for (int i = 0; i < frame.lifeLinesCount(); i++) {
- if ((selectedNode == frame.getLifeline(i)) && (i > 0)) {
- node = frame.getLifeline(i - 1);
- break;
+ overView = null;
+ Lifeline node = frame.getCloserLifeline(dragX);
+ if (node != null) {
+ int rx = Math.round(node.getX() * zoomValue);
+ if (rx <= event.x && Math.round(rx + (node.getWidth() * zoomValue)) >= event.x) {
+ if ((collapseProvider != null) && (dragAndDrop != node)) {
+ collapseProvider.collapseTwoLifelines((Lifeline) dragAndDrop, node);
+ }
+ } else if (rx < event.x) {
+ frame.insertLifelineAfter((Lifeline) dragAndDrop, node);
+ if (node.getIndex() < frame.lifeLinesCount()) {
+ Lifeline temp[] = { (Lifeline) dragAndDrop, frame.getLifeline(node.getIndex()) };
+ reorderList.add(temp);
+ } else {
+ Lifeline temp[] = { (Lifeline) dragAndDrop, null };
+ reorderList.add(temp);
+ }
+ } else {
+ frame.insertLifelineBefore((Lifeline) dragAndDrop, node);
+ Lifeline temp[] = { (Lifeline) dragAndDrop, node };
+ reorderList.add(temp);
}
}
- if ((frame.lifeLinesCount() > 0) && (node == null))
- node = frame.getLifeline(0);
- }
- if (node != null) {
- setFocus(node);
- redraw();
- }
- }
-
- public void traverseUp() {
- Object selectedNode = getFocusNode();
- if (selectedNode == null)
- traverseLeft();
- GraphNode node = null;
- if (selectedNode instanceof BaseMessage)
- node = frame.getPrevLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), (BaseMessage) selectedNode);
- else if (selectedNode instanceof Lifeline) {
- node = frame.getPrevLifelineMessage((Lifeline) selectedNode, null);
- if (!(node instanceof Lifeline))
- node = null;
- } else if (selectedNode instanceof BasicExecutionOccurrence) {
- node = frame.getPrevExecOccurrence((BasicExecutionOccurrence) selectedNode);
- if (node == null)
- node = ((BasicExecutionOccurrence) selectedNode).getLifeline();
- }
- if (node == null) {
- if (selectedNode instanceof BaseMessage) {
- if (((BaseMessage) selectedNode).getStartLifeline() != null)
- node = ((BaseMessage) selectedNode).getStartLifeline();
- }
- }
-
- if (node != null) {
- setFocus(node);
- redraw();
}
- }
-
- public void traverseDown() {
- Object selectedNode = getFocusNode();
- if (selectedNode == null)
- traverseLeft();
- GraphNode node;
- if (selectedNode instanceof BaseMessage)
- node = frame.getNextLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), (BaseMessage) selectedNode);
- else if (selectedNode instanceof Lifeline) {
- // node = frame.getNextLifelineMessage((Lifeline)selectedNode,null);
- node = frame.getFirstExecution((Lifeline) selectedNode);
- } else if (selectedNode instanceof BasicExecutionOccurrence) {
- node = frame.getNextExecOccurrence((BasicExecutionOccurrence) selectedNode);
- } else
+ dragAndDrop = null;
+ redraw();
+ if (frame == null) {
return;
-
- if (node != null) {
- setFocus(node);
- redraw();
- }
- }
-
- public void traverseHome() {
- Object selectedNode = getFocusNode();
- if (selectedNode == null)
- traverseLeft();
- GraphNode node = null;
- /*
- * if (selectedNode instanceof BaseMessage) { if (((BaseMessage)selectedNode).getStartLifeline()!=null) node =
- * ((BaseMessage)selectedNode).getStartLifeline(); }
- */
- if (selectedNode instanceof BaseMessage) {
- if (((BaseMessage) selectedNode).getStartLifeline() != null)
- node = frame.getNextLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), null);
- else
- node = frame.getNextLifelineMessage(((BaseMessage) selectedNode).getEndLifeline(), null);
- } else if (selectedNode instanceof Lifeline)
- node = frame.getNextLifelineMessage((Lifeline) selectedNode, null);
- else if (selectedNode instanceof BasicExecutionOccurrence) {
- node = frame.getFirstExecution(((BasicExecutionOccurrence) selectedNode).getLifeline());
- } else {
- if (frame.lifeLinesCount() > 0) {
- Lifeline lifeline = frame.getLifeline(0);
- node = frame.getNextLifelineMessage(lifeline, null);
- }
}
+ frame.resetTimeCompression();
- if (node != null) {
- setFocus(node);
- redraw();
+ // reset auto scroll if it's engaged
+ if (local_auto_scroll_ != null) {
+ local_auto_scroll_.cancel();
+ local_auto_scroll_ = null;
}
+ super.contentsMouseUpEvent(event);
}
- public void traverseEnd() {
- Object selectedNode = getFocusNode();
- if (selectedNode == null)
- traverseLeft();
- GraphNode node;
- if (selectedNode instanceof BaseMessage)
- node = frame.getPrevLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), null);
- else if (selectedNode instanceof Lifeline)
- node = frame.getPrevLifelineMessage((Lifeline) selectedNode, null);
- else if (selectedNode instanceof BasicExecutionOccurrence) {
- node = frame.getLastExecOccurrence(((BasicExecutionOccurrence) selectedNode).getLifeline());
- } else {
- if (frame.lifeLinesCount() > 0) {
- Lifeline lifeline = frame.getLifeline(0);
- node = frame.getPrevLifelineMessage(lifeline, null);
- } else
- return;
- }
-
- if (node != null) {
- setFocus(node);
- redraw();
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseDownEvent(org.eclipse.swt.events.MouseEvent)
+ */
+ @Override
+ protected void contentsMouseDownEvent(MouseEvent event) {
+ if (currentGraphNode != null) {
+ currentGraphNode.setFocused(false);
}
- }
-
- public void printUI(SDPrintDialogUI sdPrinter) {
- PrinterData data = sdPrinter.getPrinterData();
- if ((data == null) || (frame == null)) {
+ // Just in case the diagram highlight a time compression region
+ // this region need to be released when clicking everywhere
+ if (frame == null) {
return;
}
-
- printer = new Printer(data);
-
- String jobName = MessageFormat.format(SDMessages._116, new Object[] { String.valueOf(site.getContentDescription()), String.valueOf(frame.getName()) });
- printer.startJob(jobName);
-
- GC gc = new GC(printer);
- Frame.setUserPref(SDViewPref.getInstance());
-
- float lastZoom = zoomValue;
-
- Rectangle area = getClientArea();
- GC gcim = null;
-
- gcim = gc;
- NGC context = new NGC(this, gcim);
-
- // Set the metrics to use for lifeline text and message text
- // using the Graphical Context
- Metrics.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
- Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE)));
- Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
- Metrics.setFrameFontHeight(context.getFontHeight(Frame.getUserPref().getFont(ISDPreferences.PREF_FRAME_NAME)));
- Metrics.setLifelineHeaderFontHeight(context.getFontHeight(Frame.getUserPref().getFont(ISDPreferences.PREF_LIFELINE_HEADER)));
-
- int syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS));
- int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_SYNC_MESS_RET));
- int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS));
- int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(SDViewPref.PREF_ASYNC_MESS_RET));
-
- int messageFontHeight = 0;
- if (syncMessFontH > syncMessRetFontH)
- messageFontHeight = syncMessFontH;
- else
- messageFontHeight = syncMessRetFontH;
- if (messageFontHeight < asyncMessFontH)
- messageFontHeight = asyncMessFontH;
- if (messageFontHeight < asyncMessRetFontH)
- messageFontHeight = asyncMessRetFontH;
- Metrics.setMessageFontHeight(messageFontHeight);
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
-
- int width = Math.round((frame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * zoomValue);
- int height = Math.round((frame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * zoomValue);
- if (width < area.width)
- width = area.width;
- if (height < area.height)
- height = area.height;
- resizeContents(width, height);
-
- context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_FRAME));
- context.fillRectangle(0, 0, getContentsWidth(), Metrics.FRAME_V_MARGIN);
- context.fillRectangle(0, 0, frame.getX(), getContentsHeight());
- context.fillRectangle(frame.getX() + frame.getWidth() + 1, 0, getContentsWidth() - (frame.getX() + frame.getWidth() + 1), getContentsHeight());
- context.fillRectangle(0, frame.getY() + frame.getHeight() + 1, getContentsWidth(), getContentsHeight() - (frame.getY() + frame.getHeight() + 1));
- gcim.setLineWidth(1);
-
- printer.startPage();
- zoomValue = lastZoom;
-
- int restoreX = getContentsX();
- int restoreY = getContentsY();
-
- float zh = getContentsHeight();
- float zw = getContentsWidth();
-
- zh = sdPrinter.getStepY() * sdPrinter.getZoomFactor();
- zw = sdPrinter.getStepX() * sdPrinter.getZoomFactor();
-
- float zoomValueH = printer.getClientArea().height / zh;
- float zoomValueW = printer.getClientArea().width / zw;
- if (zoomValueH > zoomValueW)
- printerZoom = zoomValueH;
- else
- printerZoom = zoomValueW;
+ frame.resetTimeCompression();
- if (sdPrinter.printSelection()) {
- int[] pagesList = sdPrinter.getPageList();
+ if ((event.stateMask & SWT.CTRL) != 0) {
+ ctrlSelection = true;
+ } else {
+ ctrlSelection = false;
+ }
- for (int pageIndex = 0; pageIndex < pagesList.length; pageIndex++) {
- printPage(pagesList[pageIndex], sdPrinter, context);
+ if (((zoomInMode) || (zoomOutMode)) && (event.button == 1)) {
+ int cx = Math.round(event.x / zoomValue);
+ int cy = Math.round(event.y / zoomValue);
+ if (zoomInMode) {
+ if (zoomValue < 64) {
+ zoomValue = zoomValue * (float) 1.25;
+ }
+ } else {
+ zoomValue = zoomValue / (float) 1.25;
}
- } else if (sdPrinter.printAll()) {
- for (int pageIndex = 1; pageIndex <= sdPrinter.maxNumOfPages(); pageIndex++) {
- printPage(pageIndex, sdPrinter, context);
+ int x = Math.round(cx * zoomValue - getVisibleWidth() / (float) 2);
+ int y = Math.round(cy * zoomValue - getVisibleHeight() / (float) 2);
+ setContentsPos(x, y);
+ if (timeBar != null) {
+ timeBar.setZoom(zoomValue);
}
- } else if (sdPrinter.printCurrent()) {
- printPage(getContentsX(), getContentsY(), sdPrinter, context, 1);
- } else if (sdPrinter.printRange()) {
- for (int pageIndex = sdPrinter.getFrom(); pageIndex <= sdPrinter.maxNumOfPages() && pageIndex <= sdPrinter.getTo(); pageIndex++) {
- printPage(pageIndex, sdPrinter, context);
+ // redraw also resize the scrollView content
+ redraw();
+ } else {// if (event.button ==1)
+ GraphNode node = null;
+ if (frame != null) {
+ int x = Math.round(event.x / zoomValue);
+ int y = Math.round(event.y / zoomValue);
+ node = frame.getNodeAt(x, y);
+
+ if ((event.button == 1) || ((node != null) && !node.isSelected())) {
+ if (!shiftSelection) {
+ listStart = node;
+ }
+ if (shiftSelection) {
+ clearSelection();
+ addSelection(frame.getNodeList(listStart, node));
+ } else {
+ performSelection(node);
+ }
+ currentGraphNode = node;
+ if (node != null) {
+ node.setFocused(true);
+ }
+ }
+ redraw();
}
}
+ if (dragAndDrop == null) {
+ super.contentsMouseDownEvent(event);
+ }
+ getDragAndDrop = (event.button == 1);
- printer.endJob();
- printing = false;
-
- gc.dispose();
- context.dispose();
+ }
+
+ /**
+ * TimerTask for auto scroll feature.
+ */
+ protected static class AutoScroll extends TimerTask {
+ /**
+ * Field delta x.
+ */
+ public int dx_;
+ /**
+ * Field delta y.
+ */
+ public int dy_;
+ /**
+ * Field sequence diagram reference.
+ */
+ public SDWidget sv_;
- zoomValue = lastZoom;
- printer.dispose();
- setContentsPos(restoreX, restoreY);
+ /**
+ * Constructor for AutoScroll.
+ * @param _sv sequence diagram widget reference
+ * @param _dx delta x
+ * @param _dy delta y
+ */
+ public AutoScroll(SDWidget _sv, int _dx, int _dy) {
+ sv_ = _sv;
+ dx_ = _dx;
+ dy_ = _dy;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.TimerTask#run()
+ */
+ @Override
+ public void run() {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (sv_.isDisposed())
+ return;
+ sv_.dragX += dx_;
+ sv_.dragY += dy_;
+ sv_.scrollBy(dx_, dy_);
+ }
+ });
+ }
}
- public void print() {
- SDPrintDialog sdPrinter = new SDPrintDialog(this.getShell(), this);
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
+ */
+ @Override
+ protected void drawContents(GC gc, int clipx, int clipy, int clipw, int cliph) {
+ if (frame == null) {
+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ gc.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
+ gc.dispose();
+ return;
+ } else {
+ Frame.setUserPref(SDViewPref.getInstance());
+ }
+
+ Rectangle area = getClientArea();
+ Image dbuffer = getDrawBuffer();
+ int height = Math.round((frame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * zoomValue);
+
try {
- if (sdPrinter.open() != 0)
- return;
+ gc.drawImage(dbuffer, 0, 0, area.width, area.height, 0, 0, area.width, area.height);
} catch (Exception e) {
-
+ System.out.println(e.getMessage());
+ }
+ dbuffer.dispose();
+ setHScrollBarIncrement(Math.round(SDViewPref.getInstance().getLifelineWidth() / (float) 2 * zoomValue));
+ setVScrollBarIncrement(Math.round(Metrics.getMessagesSpacing() * zoomValue));
+ if ((timeBar != null) && (frame.hasTimeInfo())) {
+ timeBar.resizeContents(9, height + getHorizontalBarHeight());
+ timeBar.setContentsPos(getContentsX(), getContentsY());
+ timeBar.redraw();
+ timeBar.update();
}
+ float xRatio = getContentsWidth() / (float) getVisibleWidth();
+ float yRatio = getContentsHeight() / (float) getVisibleHeight();
+ if (yRatio > xRatio) {
+ setOverviewSize((int) (getVisibleHeight() * 0.75));
+ } else {
+ setOverviewSize((int) (getVisibleWidth() * 0.75));
+ }
+ }
- printUI(sdPrinter.getDialogUI());
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent event) {
}
- public void printPage(int pageNum, SDPrintDialogUI pd, NGC context) {
- int j = pageNum / pd.getNbRow();
- int i = pageNum % pd.getNbRow();
- if (i != 0)
- j++;
- else
- i = pd.getNbRow();
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ if (event.widget == zoomIn) {
+ zoomValue = zoomValue * 2;
+ } else if (event.widget == zoomOut) {
+ zoomValue = zoomValue / 2;
+ }
+ redraw();
+ }
- i--;
- j--;
+ /*
+ * Called when property changed occurs in the preference page. "PREFOK" is fired when the user press the ok or apply button
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if (frame != null && !isDisposed()) {
+ frame.resetTimeCompression();
+ }
+ if (e.getProperty().equals("PREFOK")) //$NON-NLS-1$
+ {
+ // Prepare the overview to be reused for the new
+ // settings (especially the colors)
+ if (overView != null)
+ overView.dispose();
+ overView = null;
+ redraw();
+ }
+ }
- i = (int) (i * pd.getStepX());
- j = (int) (j * pd.getStepY());
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
+ */
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ if (overView != null) {
+ overView.dispose();
+ }
+ super.removeDisposeListener(this);
+ if ((currentCaretImage != null) && (!currentCaretImage.isDisposed())) {
+ currentCaretImage.dispose();
+ }
+ if ((arrowUpCaretImg != null) && (!arrowUpCaretImg.isDisposed())) {
+ arrowUpCaretImg.dispose();
+ }
+ if ((collapaseCaretImg != null) && (!collapaseCaretImg.isDisposed())) {
+ collapaseCaretImg.dispose();
+ }
+ SDViewPref.getInstance().removePropertyChangeListener(this);
+ LoadersManager lm = LoadersManager.getInstance();
+ if (site != null && site instanceof SDView) {
+ ((SDView) site).resetProviders();
+ if (lm != null) {
+ lm.resetLoader(((SDView) site).getViewSite().getId());
+ }
+ }
+ }
- printPage(i, j, pd, context, pageNum);
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawOverview(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle)
+ */
+ @Override
+ protected void drawOverview(GC gc, Rectangle r) {
+ float oldzoom = zoomValue;
+ if (getContentsWidth() > getContentsHeight()) {
+ zoomValue = (float) r.width / (float) getContentsWidth() * oldzoom;
+ } else {
+ zoomValue = (float) r.height / (float) getContentsHeight() * oldzoom;
+ }
+ if ((overView != null) && ((r.width != overView.getBounds().width) || (r.height != overView.getBounds().height))) {
+ overView.dispose();
+ overView = null;
+ }
+ if (overView == null) {
+ int backX = getContentsX();
+ int backY = getContentsY();
+ setContentsPos(0, 0);
+ overView = new Image(getDisplay(), r.width, r.height);
+ GC gcim = new GC(overView);
+ NGC context = new NGC(this, gcim);
+ context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+ frame.draw(context);
+ setContentsPos(backX, backY);
+ gcim.dispose();
+ context.dispose();
+ }
+ if ((overView != null) && (r.width == overView.getBounds().width) && (r.height == overView.getBounds().height)) {
+ gc.drawImage(overView, 0, 0, r.width, r.height, 0, 0, r.width, r.height);
+ }
- printer.endPage();
+ zoomValue = oldzoom;
+
+ super.drawOverview(gc, r);
}
- public void printPage(int i, int j, SDPrintDialogUI pd, NGC context, int pageNum) {
- printing = false;
- int pageNumFontZoom = printer.getClientArea().height / getVisibleHeight();
- printerX = i;
- printerY = j;
- setContentsPos(i, j);
+ /*
+ * (non-Javadoc)
+ * @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)
+ */
+ @Override
+ public void deltaSelected(Lifeline lifeline, int startEvent, int nbEvent, IColor color) {
+ frame.highlightTimeCompression(lifeline, startEvent, nbEvent, color);
+ ensureVisible(lifeline);
+ int y1 = lifeline.getY() + lifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * startEvent;
+ int y2 = lifeline.getY() + lifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * (startEvent + nbEvent);
+ ensureVisible(lifeline.getX(), y1 - (Metrics.getLifelineHeaderFontHeigth() + +2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN), lifeline.getWidth(), y2 - y1 + 3, SWT.CENTER | SWT.VERTICAL, true);
+ redraw();
update();
- printing = true;
- float lastZoom = zoomValue;
- zoomValue = printerZoom * lastZoom;
-
- frame.draw(context);
-
- zoomValue = pageNumFontZoom;
- context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
- String currentPageNum = String.valueOf(pageNum);
- int ii = context.textExtent(currentPageNum);
- int jj = context.getCurrentFontHeight();
- // context.setBackground(ColorImpl.getSystemColor(SWT.COLOR_BLACK));
- // context.setForeground(ColorImpl.getSystemColor(SWT.COLOR_WHITE));
- zoomValue = printerZoom * lastZoom;
- context.drawText(currentPageNum, Math.round(printerX + getVisibleWidth() / printerZoom - ii / printerZoom), Math.round(printerY + getVisibleHeight() / printerZoom - jj / printerZoom), false);
- printing = false;
- zoomValue = lastZoom;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleWidth()
+ */
@Override
public int getVisibleWidth() {
- if (printing)
+ if (printing) {
return printer.getClientArea().width;
+ }
return super.getVisibleWidth();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getVisibleHeight()
+ */
@Override
public int getVisibleHeight() {
- if (printing)
+ if (printing) {
return printer.getClientArea().height;
+ }
return super.getVisibleHeight();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewX(int)
+ */
@Override
public int contentsToViewX(int _x) {
if (printing) {
@@ -1680,6 +2091,10 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
return _x - getContentsX();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsToViewY(int)
+ */
@Override
public int contentsToViewY(int _y) {
if (printing) {
@@ -1689,26 +2104,28 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
return _y - getContentsY();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsX()
+ */
@Override
public int getContentsX() {
- if (printing)
+ if (printing) {
return Math.round(printerX * printerZoom);
+ }
return super.getContentsX();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsY()
+ */
@Override
public int getContentsY() {
- if (printing)
+ if (printing) {
return Math.round(printerY * printerZoom);
+ }
return super.getContentsY();
}
-
- public Printer getPrinter() {
- return printer;
- }
-
- public boolean isPrinting() {
- return printing;
- }
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java
index 4978b6aab1..d912ed15e0 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidgetSelectionProvider.java
@@ -1,10 +1,10 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDWidgetSelectionProvider.java,v 1.3 2008/01/24 02:29:01 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -20,31 +20,46 @@ import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
/**
- * Informs all registered listeners of graph node selection change in the Frame
+ *
+ * Informs all registered listeners of graph node selection change in the Frame.
+ *
*
+ * @version 1.0
* @author sveyrier
*
*/
public class SDWidgetSelectionProvider implements ISelectionProvider {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
* The listener list
*/
protected ArrayList listenerList = null;
-
/**
* The current selection
*/
protected ISelection currentSelection = null;
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+ /**
+ * Standard constructor
+ */
protected SDWidgetSelectionProvider() {
listenerList = new ArrayList();
}
- /**
- * Adds the given listener from the selection change listener list
- *
- * @param listener the listener to add
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
@@ -52,20 +67,18 @@ public class SDWidgetSelectionProvider implements ISelectionProvider {
listenerList.add(listener);
}
- /**
- * Removes the given listener from the selection change listener list
- *
- * @param listener the listener to remove
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
listenerList.remove(listener);
}
- /**
- * Changes the selection to the given selection and inform all listener
- *
- * @param selection the new current selection
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
*/
@Override
public void setSelection(ISelection selection) {
@@ -76,10 +89,9 @@ public class SDWidgetSelectionProvider implements ISelectionProvider {
}
}
- /**
- * Returns the current selection
- *
- * @return the current selection
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
*/
@Override
public ISelection getSelection() {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ScrollView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ScrollView.java
index 9b8faafbea..90b83b48c1 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ScrollView.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/ScrollView.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ScrollView.java,v 1.3 2008/01/24 02:29:01 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -50,48 +51,132 @@ import org.eclipse.swt.widgets.Scrollable;
import org.eclipse.swt.widgets.Shell;
/**
- * ScrollView widget provides a scrolling area with on-demand scroll bars. Overview scrollable panel can be use (@see
- * setOverviewEnabled()).
+ * ScrollView widget provides a scrolling area with on-demand scroll bars.
+ * Overview scrollable panel can be used (@see setOverviewEnabled()).
*
* @author Eric Miravete
* @version 1.0
*/
public class ScrollView extends Composite {
- /** Value for scroll bar mode, default is AUTO */
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // Value for scroll bar mode, default is AUTO
+ /**
+ * Scroll bar mode AUTO
+ */
public static final int AUTO = 0;
- public static final int ALWAYS_OFF = 2;
+ /**
+ * Scroll bar mode ALWAYS_ON
+ */
public static final int ALWAYS_ON = 1;
-
+ /**
+ * Scroll bar mode ALWAYS_OFF
+ */
+ public static final int ALWAYS_OFF = 2;
+ /**
+ * Bit mask for visible vertical scroll bar
+ */
+ public static final int VBAR = 0x01;
+ /**
+ * Bit mask for visible horizontal scroll bar
+ */
+ public static final int HBAR = 0x02;
+ /**
+ * Value of the contents_height_ property.
+ */
protected int contents_height_ = 0;
+ /**
+ * Value of the contents_width_ property.
+ */
protected int contents_width_ = 0;
+ /**
+ * Value of the contents_x_ property
+ */
protected int contents_x_ = 0;
+ /**
+ * Value of the contents_y_ property
+ */
protected int contents_y_ = 0;
+ /**
+ * Scroll bar mode of vertical scroll bar.
+ */
protected int h_scrollbar_mode_ = AUTO;
+ /**
+ * Scroll bar mode of horizontal scroll bar.
+ */
protected int v_scrollbar_mode_ = AUTO;
+ /**
+ * Increment for the horizontal scroll bar.
+ */
protected int h_scrollbar_increment_ = 10;
+ /**
+ * Increment for the vertical scroll bar.
+ */
protected int v_scrollbar_increment_ = 10;
+ /**
+ * Flag whether auto scroll is enabled or not.
+ */
protected boolean auto_scroll_enabled_ = true;
+ /**
+ * Value of the auto scroll period.
+ */
protected int auto_scroll_period_ = 75;
+ /**
+ * The local paint listener reference.
+ */
protected PaintListener localPaintListener = null;
+ /**
+ * The local mouse move listener reference.
+ */
protected MouseMoveListener localMouseMoveListener = null;
+ /**
+ * The local mouse listener reference.
+ */
protected MouseListener localMouseListener = null;
+ /**
+ * The local control listener reference.
+ */
protected ControlListener localControlListener = null;
+ /**
+ * The local key listener reference.
+ */
protected KeyListener localKeyListener = null;
-
- // Canvas for vertical/horz SB only ... because new ScrollBar() does works.
- protected Canvas vertsb_, horzsb_; // parcequ'on peut pas creer de SB !!!
+ // Canvas for vertical/horizontal Scroll Bar only ... because new ScrollBar() does works.
+ /**
+ * Canvas for horizontal scroll bar.
+ */
+ protected Canvas horzsb_;
+ /**
+ * Canvas for vertical scroll bar.
+ */
+ protected Canvas vertsb_;
+ /**
+ * Canvas for the view control.
+ */
protected Canvas viewcontrol_;
- /** control used in the bottom right corner @see setCornerControl() and @see setOverviewEnabled(true) */
+ /**
+ * Control used in the bottom right corner @see setCornerControl() and @see setOverviewEnabled(true)
+ */
protected Control corner_control_;
+ /**
+ * Size of overview widget.
+ */
protected int overview_size_ = 100; // default size for overview
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
* Create a ScrollView, child of composite c. Both scroll bar have the mode AUTO. Auto scroll feature is enabled
* using a delay of 250ms. Overview feature is not enabled by default (use setOverviewEnabled()).
*
- * @param c
- * @param style SWT style bits @see SWT
+ * @param c The parent composite
+ * @param style The SWT style bits @see SWT
*/
public ScrollView(Composite c, int style) {
this(c, style, true);
@@ -101,19 +186,20 @@ public class ScrollView extends Composite {
* Create a ScrollView, child of composite c. Both scroll bar have the mode AUTO. Auto scroll feature is enabled
* using a delay of 250ms. Overview feature is not enabled by default (use setOverviewEnabled()).
*
- * @param c
- * @param style SWT style bits @see SWT
- * @param mouseWheel force scrollView to handles mouse wheel
+ * @param c The parent composite.
+ * @param style The SWT style bits @see SWT
+ * @param mouseWheel Flag to force scrollView to handles mouse wheel
*/
public ScrollView(Composite c, int style, boolean mouseWheel) {
super(c, SWT.NONE); // style&(~(SWT.H_SCROLL|SWT.V_SCROLL)));
horzsb_ = new Canvas(this, SWT.H_SCROLL);
- if (mouseWheel)
+ if (mouseWheel) {
// force scroll bar to get mouse wheel, those scrollbar will be hidden
viewcontrol_ = new Canvas(this, style | SWT.H_SCROLL | SWT.V_SCROLL);
- else
+ } else {
viewcontrol_ = new Canvas(this, style);
+ }
viewcontrol_.setBackground(getBackground());
// hide scroll bar as their are replaced by vertsb_ and horzsb_.
if (mouseWheel) {
@@ -235,7 +321,7 @@ public class ScrollView extends Composite {
keyReleasedEvent(e);
}
};
- // addKeyListener(localKeyListener);
+
viewcontrol_.addKeyListener(localKeyListener);
getVerticalBar().addSelectionListener(new SelectionListener() {
@@ -244,8 +330,9 @@ public class ScrollView extends Composite {
setContentsPos(contents_x_, getVerticalBar().getSelection());
// need to change "hidden" vertical bar value ?
// force focus on viewcontrol_ so we got future mouse wheel's scroll events
- if (!viewcontrol_.isFocusControl())
+ if (!viewcontrol_.isFocusControl()) {
viewcontrol_.setFocus();
+ }
}
@Override
@@ -274,8 +361,9 @@ public class ScrollView extends Composite {
setContentsPos(getHorizontalBar().getSelection(), contents_y_);
// need to change "real" horizontal bar too ?
// force focus on viewcontrol_ so we got future mouse wheel's scroll events
- if (!viewcontrol_.isFocusControl())
+ if (!viewcontrol_.isFocusControl()) {
viewcontrol_.setFocus();
+ }
}
@Override
@@ -298,31 +386,51 @@ public class ScrollView extends Composite {
});
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Composite#setFocus()
+ */
@Override
public boolean setFocus() {
return viewcontrol_.forceFocus();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Control#setCursor(org.eclipse.swt.graphics.Cursor)
+ */
@Override
public void setCursor(Cursor cursor) {
viewcontrol_.setCursor(cursor);
}
- // dispose controls used in scroll view
+ /*
+ * Dispose controls used in scroll view
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Widget#dispose()
+ */
@Override
public void dispose() {
if (auto_scroll_ != null) {
auto_scroll_.cancel();
auto_scroll_ = null;
}
- if (viewcontrol_ != null)
+ if (viewcontrol_ != null) {
viewcontrol_.dispose();
+ }
viewcontrol_ = null;
- if (vertsb_ != null)
+ if (vertsb_ != null) {
vertsb_.dispose();
+ }
vertsb_ = null;
- if (horzsb_ != null)
+ if (horzsb_ != null) {
horzsb_.dispose();
+ }
horzsb_ = null;
if (corner_control_ != null) {
Object data = corner_control_.getData();
@@ -335,19 +443,29 @@ public class ScrollView extends Composite {
super.dispose();
}
- /** @return client area of scrollview */
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Composite#getClientArea()
+ */
@Override
public Rectangle getClientArea() {
return viewcontrol_.getClientArea();
}
- /** change background color of client area */
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
+ */
@Override
public void setBackground(Color c) {
super.setBackground(c);
viewcontrol_.setBackground(c);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Control#setToolTipText(java.lang.String)
+ */
@Override
public void setToolTipText(String text) {
viewcontrol_.setToolTipText(text);
@@ -367,11 +485,13 @@ public class ScrollView extends Composite {
int vw = getVisibleWidth();
int vh = getVisibleHeight();
int w = r.width - 1;
- if (contents_width_ > vw)
+ if (contents_width_ > vw) {
w = (int) (r.width * vw / (float) contents_width_);
+ }
int h = r.height - 1;
- if (contents_height_ > vh)
+ if (contents_height_ > vh) {
h = (int) (r.height * vh / (float) contents_height_);
+ }
gc.setForeground(getForeground());
// too small rectangle ?
@@ -595,8 +715,9 @@ public class ScrollView extends Composite {
* @param _b true to engage overview feature
*/
public void setOverviewEnabled(boolean _b) {
- if (getOverviewEnabled() == _b)
+ if (getOverviewEnabled() == _b) {
return;
+ }
Control cc = null;
if (_b) {
@@ -619,19 +740,24 @@ public class ScrollView extends Composite {
}
/**
+ * Returns whether the overview is enabled or not.
+ *
* @return true is overview feature is enabled
*/
public boolean getOverviewEnabled() {
if (corner_control_ instanceof Button) {
Object data = ((Button) corner_control_).getData();
// overview alreay
- if (data instanceof Overview)
+ if (data instanceof Overview) {
return true;
+ }
}
return false;
}
/**
+ * Returns the overview size at ratio 1:1.
+ *
* @return current overview size at ratio 1:1
*/
public int getOverviewSize() {
@@ -639,8 +765,10 @@ public class ScrollView extends Composite {
}
/**
- * @return control used to display view (might not be this object). use this control to add/remove listener on the
- * draw area
+ * Returns control used to display view (might not be this object). Use this control to add/remove listener on the
+ * draw area.
+ *
+ * @return control used to display view (might not be this object).
*/
public Control getViewControl() {
return viewcontrol_;
@@ -808,16 +936,19 @@ public class ScrollView extends Composite {
*/
public void resizeContents(int width, int height) {
// System.out.println("SV--resizeContents("+_w+","+_h+" ) {");
- if (width < 0)
+ if (width < 0) {
width = 0;
- if (height < 0)
+ }
+ if (height < 0) {
height = 0;
+ }
int oldW = contents_width_;
int oldH = contents_height_;
- if (width == oldW && height == oldH)
+ if (width == oldW && height == oldH) {
return;
+ }
// System.out.println("RESIZE-CONTENTS("+_w+","+_h+")");
contents_width_ = width;
@@ -944,15 +1075,16 @@ public class ScrollView extends Composite {
}
if (_y < getContentsY()) {
cy = _y;
-
} else if (_y + _h > bottom) {
cy = _y - _h;
}
- if (_w > getVisibleWidth())
+ if (_w > getVisibleWidth()) {
align_h = true;
- if (_h > getVisibleHeight())
+ }
+ if (_h > getVisibleHeight()) {
align_v = true;
+ }
// compute alignment on visible area horizontally
if (align_h || (forceAlign && _x + _w > right)) {
// use _align flags
@@ -960,8 +1092,7 @@ public class ScrollView extends Composite {
cx = _x;
} else if ((_align & SWT.RIGHT) != 0) {
cx = right - _w;
- } else // center
- {
+ } else { // center
cx = _x + (_w - getVisibleWidth()) / 2;
}
}
@@ -972,8 +1103,7 @@ public class ScrollView extends Composite {
cy = _y;
} else if ((_align & SWT.BOTTOM) != 0) {
cy = bottom - _h;
- } else // center
- {
+ } else { // center
cy = _y + (_h - getVisibleHeight()) / 2;
}
}
@@ -981,69 +1111,94 @@ public class ScrollView extends Composite {
}
/**
+ * Returns true if point is visible (expressed in contents coordinates).
+ *
* @return true if point is visible (expressed in contents coordinates)
*/
public boolean isVisible(int _px, int _py) {
- if (_px < getContentsX())
+ if (_px < getContentsX()) {
return false;
- if (_py < getContentsY())
+ }
+ if (_py < getContentsY()) {
return false;
- if (_px > (getContentsX() + getVisibleWidth()))
+ }
+ if (_px > (getContentsX() + getVisibleWidth())) {
return false;
- if (_py > (getContentsY() + getVisibleHeight()))
+ }
+ if (_py > (getContentsY() + getVisibleHeight())) {
return false;
+ }
return true;
}
/**
+ * Returns true if rectangle if partially visible.
+ *
* @return true if rectangle if partially visible.
*/
public boolean isVisible(int _x, int _y, int _w, int _h) {
- if (_x + _w < getContentsX())
+ if (_x + _w < getContentsX()) {
return false;
- if (_y + _h < getContentsY())
+ }
+ if (_y + _h < getContentsY()) {
return false;
+ }
int vr = getContentsX() + getVisibleWidth();
int vb = getContentsY() + getVisibleHeight();
- if (_x > vr)
+ if (_x > vr) {
return false;
- if (_y > vb)
+ }
+ if (_y > vb) {
return false;
+ }
return true;
}
/**
- * @return visible part of rectangle, or null if rectangle is not visible. rectangle is expressed in contents
+ * Returns visible part of rectangle, or null if rectangle is not visible. Rectangle is expressed in contents
* coordinates.
+ * @return visible part of rectangle, or null if rectangle is not visible.
*/
public Rectangle getVisiblePart(int _x, int _y, int _w, int _h) {
- if (_x + _w < getContentsX())
+ if (_x + _w < getContentsX()) {
return null;
- if (_y + _h < getContentsY())
+ }
+ if (_y + _h < getContentsY()) {
return null;
+ }
int vr = getContentsX() + getVisibleWidth();
int vb = getContentsY() + getVisibleHeight();
- if (_x > vr)
+ if (_x > vr) {
return null;
- if (_y > vb)
+ }
+ if (_y > vb) {
return null;
+ }
int rr = _x + _w, rb = _y + _h;
int nl = Math.max(_x, getContentsX()), nt = Math.max(_y, getContentsY()), nr = Math.min(rr, vr), nb = Math.min(rb, vb);
Rectangle c = new Rectangle(nl, nt, nr - nl, nb - nt);
return c;
}
+ /**
+ * Returns the visible part for given rectangle.
+ *
+ * @param _r A rectangle
+ *
+ * @return gets visible part of rectangle (or null
)
+ */
public final Rectangle getVisiblePart(Rectangle _r) {
- if (_r == null)
+ if (_r == null) {
return null;
+ }
return getVisiblePart(_r.x, _r.y, _r.width, _r.height);
}
/**
* Change top left position of visible area. Check if the given point is inside contents area.
*
- * @param _x
- * @param _y
+ * @param _x x contents coordinates of visible area.
+ * @param _y y contents coordinates of visible area.
* @return true if view really moves
*/
public boolean setContentsPos(int _x, int _y) {
@@ -1079,23 +1234,33 @@ public class ScrollView extends Composite {
}
// redefined to return our vertical bar
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Scrollable#getVerticalBar()
+ */
@Override
public ScrollBar getVerticalBar() {
return vertsb_.getVerticalBar();
}
// redefined to return out horizontal bar
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Scrollable#getHorizontalBar()
+ */
@Override
public ScrollBar getHorizontalBar() {
return horzsb_.getHorizontalBar();
}
- public static final int VBAR = 0x01;
- public static final int HBAR = 0x02;
-
/**
- * compute visibility of vert/hor bar using given width/height and current visibility (i.e. is bar size are already in
+ * Compute visibility of vertical/horizontal bar using given width/height and current visibility (i.e. is bar size are already in
* for_xxx)
+ * @param for_width width of foreground
+ * @param for_height height of foreground
+ * @param curr_h_vis The current visibility state of horizontal scroll bar
+ * @param curr_v_vis The current visibility state of vertical scroll bar
+ * @return true
if visibility changed else false
*/
public int computeBarVisibility(int for_width, int for_height, boolean curr_h_vis, boolean curr_v_vis) {
int vis = 0x00;
@@ -1109,13 +1274,13 @@ public class ScrollView extends Composite {
if (getContentsHeight() > for_height) {
vis = VBAR;
// v bar size is already in for_width.
- if (!curr_v_vis)// (curr_vis&0x01)==0)
- {
+ if (!curr_v_vis) {// (curr_vis&0x01)==0)
for_width -= getVerticalBarWidth();
}
}
break;
}
+
switch (h_scrollbar_mode_) {
case ALWAYS_OFF:
break;
@@ -1173,7 +1338,6 @@ public class ScrollView extends Composite {
/**
* Setup scroll bar using contents, visible and scroll bar mode properties.
- *
*/
protected void updateScrollBarsValues() {
// System.out.println("UPDATE-SCROLL-BAR-VALUES");
@@ -1226,6 +1390,7 @@ public class ScrollView extends Composite {
* corner control. This control is visible only if at least one scrollbar is visible. Given control will be disposed
* by ScrollView, at dispose() time, at next setCornetControl() call or when calling setOverviewEnabled(). Pay
* attention calling this reset overview feature until setOverviewEnabled(true) if called.
+ * @param _w The control for the overview
*/
public void setCornerControl(Control _w) {
if (corner_control_ != null) {
@@ -1243,21 +1408,31 @@ public class ScrollView extends Composite {
/**
* Transform (x,y) point in widget coordinates to contents coordinates.
*
- * @param x
- * @param y
- * @return org.eclipse.swt.graphics.Point
+ * @param x The x widget coordinate.
+ * @param y The y widget coordinate.
+ * @return org.eclipse.swt.graphics.Point with content coordinates.
*/
public final Point viewToContents(int x, int y) {
Point p = new Point(viewToContentsX(x), viewToContentsY(y));
return p;
}
- /** Transform x in widget coordinates to contents coordinates */
+ /**
+ * Transform x in widget coordinates to contents coordinates
+ *
+ * @param _x The y widget coordinate.
+ * @return the x content coordinate.
+ */
public int viewToContentsX(int _x) {
return contents_x_ + _x;
}
- /** Transform y in widget coordinates to contents coordinates */
+ /**
+ * Transform y in widget coordinates to contents coordinates
+ *
+ * @param _y The y widget coordinate.
+ * @return the y content coordinate.
+ */
public int viewToContentsY(int _y) {
return contents_y_ + _y;
}
@@ -1265,9 +1440,9 @@ public class ScrollView extends Composite {
/**
* Transform (x,y) point from contents coordinates, to widget coordinates.
*
- * @param x
- * @param y
- * @return org.eclipse.swt.graphics.Point
+ * @param x The x content coordinate.
+ * @param y The y content coordinate.
+ * @return coordinates widget area as.
*/
public final Point contentsToView(int x, int y) {
Point p = new Point(contentsToViewX(x), contentsToViewY(y));
@@ -1277,8 +1452,8 @@ public class ScrollView extends Composite {
/**
* Transform X axis coordinates from contents to widgets.
*
- * @param _x contents coordinate to transform
- * @return coordinate in widget area
+ * @param _x contents coordinate to transform.
+ * @return x coordinate in widget area
*/
public int contentsToViewX(int _x) {
return _x - contents_x_;
@@ -1288,14 +1463,16 @@ public class ScrollView extends Composite {
* Transform Y axis coordinates from contents to widgets.
*
* @param _y contents coordinate to transform
- * @return coordinate in widget area
+ * @return y coordinate in widget area
*/
public int contentsToViewY(int _y) {
return _y - contents_y_;
}
/**
- * @return int the visible height of scroll view, might be > contentsHeight()
+ * Return the visible height of scroll view, might be > contentsHeight
+ *
+ * @return the visible height of scroll view, might be > contentsHeight()
*/
public int getVisibleHeight() {
Rectangle r = viewcontrol_.getClientArea();
@@ -1303,6 +1480,8 @@ public class ScrollView extends Composite {
}
/**
+ * Return int the visible width of scroll view, might be > contentsWidth().
+ *
* @return int the visible width of scroll view, might be > contentsWidth()
*/
public int getVisibleWidth() {
@@ -1330,7 +1509,10 @@ public class ScrollView extends Composite {
}
}
- /** Redefine this method at your convenience */
+ /**
+ * Redefine this method at your convenience
+ * @param _e The key event.
+ */
protected void keyReleasedEvent(KeyEvent _e) {
}
@@ -1348,14 +1530,22 @@ public class ScrollView extends Composite {
}
}
- /** @return vertical bar width, even if bar isn't visible */
+ /**
+ * Returns vertical bar width, even if bar isn't visible.
+ *
+ * @return vertical bar width, even if bar isn't visible
+ */
public int getVerticalBarWidth() {
// include vertical bar width and trimming of scrollable used
int bw = vertsb_.computeTrim(0, 0, 0, 0).width;
return bw + 1;
}
- /** @return horizontal bar height even if bar isn't visible */
+ /**
+ * Returns horizontal bar height even if bar isn't visible.
+ *
+ * @return horizontal bar height even if bar isn't visible
+ */
public int getHorizontalBarHeight() {
// include horiz. bar height and trimming of scrollable used
int bh = horzsb_.computeTrim(0, 0, 0, 0).height;
@@ -1363,6 +1553,10 @@ public class ScrollView extends Composite {
return bh + 1;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Scrollable#computeTrim(int, int, int, int)
+ */
@Override
public Rectangle computeTrim(int x, int y, int w, int h) {
Rectangle r = new Rectangle(x, y, w, h);
@@ -1376,28 +1570,42 @@ public class ScrollView extends Composite {
return r;
}
- /** Internal layout for ScrollView, handle scrollbars, drawzone and corner control */
+ /**
+ * Internal layout for ScrollView, handle scrollbars, drawzone and corner control
+ */
protected class SVLayout extends Layout {
+ int seek = 0;
+ boolean dont_layout = false;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite, int, int, boolean)
+ */
@Override
protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
Point p = new Point(250, 250);
- if (contents_width_ < p.x)
+ if (contents_width_ < p.x) {
p.x = contents_width_;
- if (contents_height_ < p.y)
+ }
+ if (contents_height_ < p.y) {
p.y = contents_height_;
+ }
return p;
}
- int seek = 0;
- boolean dont_layout = false;
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean)
+ */
@Override
protected void layout(Composite composite, boolean flushCache) {
- if (dont_layout)
+ if (dont_layout) {
return;
+ }
seek++;
- if (seek > 10)
+ if (seek > 10) {
dont_layout = true;
+ }
// System.out.println(">>> SV.layout() {");
Point cs = composite.getSize();
@@ -1413,8 +1621,7 @@ public class ScrollView extends Composite {
int cww = 0, cwh = 0;
// System.out.println("SV-LAYOUT H.vis="+hb_vis+" V.vis="+vb_vis);
- if (corner_control_ != null && (vb_vis || hb_vis))// corner_control_.getVisible())
- {
+ if (corner_control_ != null && (vb_vis || hb_vis)) { // corner_control_.getVisible())
corner_control_.setVisible(true);
cww = vbw;
cwh = hbh;
@@ -1423,13 +1630,15 @@ public class ScrollView extends Composite {
if (hb == 0)
hb = hbh;
} else if (vb_vis && hb_vis) {
- if (corner_control_ != null)
+ if (corner_control_ != null) {
corner_control_.setVisible(false);
+ }
cww = vbw;
cwh = hbh;
}
- if (vb_vis || hb_vis)
+ if (vb_vis || hb_vis) {
updateScrollBarsValues();
+ }
int vw = cs.x - (vb_vis ? vbw : 0);
int vh = cs.y - (hb_vis ? hbh : 0);
@@ -1468,8 +1677,9 @@ public class ScrollView extends Composite {
}
// System.out.println("<<< SV.layout() }");
seek--;
- if (seek == 0)
+ if (seek == 0) {
dont_layout = false;
+ }
}
}
@@ -1564,18 +1774,25 @@ public class ScrollView extends Composite {
});
}
- /** Dispose controls of overview */
+ /**
+ * Dispose controls of overview
+ */
public void dispose() {
- if (overview != null)
+ if (overview != null) {
overview.dispose();
+ }
}
- /** @return true if overview is currently on screen */
+ /**
+ * @return true if overview is currently on screen
+ */
protected boolean overviewing() {
return (overview != null && overview.isVisible());
}
- /** Process overview appear */
+ /**
+ * Process overview appear
+ */
protected void overviewAppear(int mx, int my) {
if (overview == null) {
overview = new Shell(getShell(), SWT.ON_TOP | SWT.NO_BACKGROUND);
@@ -1602,17 +1819,19 @@ public class ScrollView extends Composite {
if (contents_width_ > contents_height_) {
float ratio = contents_height_ / (float) contents_width_;
h = (int) (w * ratio);
- if (h < ccs.y)
+ if (h < ccs.y) {
h = ccs.y;
- else if (h >= scr.height / 2)
+ } else if (h >= scr.height / 2) {
h = scr.height / 2;
+ }
} else {
float ratio = contents_width_ / (float) contents_height_;
w = (int) (h * ratio);
- if (w < ccs.x)
+ if (w < ccs.x) {
w = ccs.x;
- else if (w >= scr.width / 2)
+ } else if (w >= scr.width / 2) {
w = scr.width / 2;
+ }
}
overview_factor_x_ = contents_width_ / (float) w;
overview_factor_y_ = contents_height_ / (float) h;
@@ -1625,32 +1844,31 @@ public class ScrollView extends Composite {
// if outside screen, extend pop-up to top left
// if( x+w > scr.width ) x = scr.width-w; //x += corner_control_.getSize().x-w;
// if( y+h > scr.height ) y = scr.height-h;//y += corner_control_.getSize().y-h;
- if (x <= 0)
+ if (x <= 0) {
x = 1;
- if (y <= 0)
+ }
+ if (y <= 0) {
y = 1;
+ }
x = x - w + ccs.x;
y = y - h + ccs.y;
overview.setBounds(x, y, w, h);
overview.setVisible(true);
overview.redraw();
// mouse cursor disappear, so set invisible mouse cursor ...
- // if (hideCursor)
- {
- if (overview_cursor_ == null) {
- RGB rgb[] = { new RGB(0, 0, 0), new RGB(255, 0, 0) };
- PaletteData pal_ = new PaletteData(rgb);
- int s = 1;
- byte src[] = new byte[s * s];
- byte msk[] = new byte[s * s];
- for (int i = 0; i < s * s; ++i)
- src[i] = (byte) 0xFF;
- ImageData i_src = new ImageData(s, s, 1, pal_, 1, src);
- ImageData i_msk = new ImageData(s, s, 1, pal_, 1, msk);
- overview_cursor_ = new Cursor(null, i_src, i_msk, 0, 0);
- }
- corner_control_.setCursor(overview_cursor_);
+ if (overview_cursor_ == null) {
+ RGB rgb[] = { new RGB(0, 0, 0), new RGB(255, 0, 0) };
+ PaletteData pal_ = new PaletteData(rgb);
+ int s = 1;
+ byte src[] = new byte[s * s];
+ byte msk[] = new byte[s * s];
+ for (int i = 0; i < s * s; ++i)
+ src[i] = (byte) 0xFF;
+ ImageData i_src = new ImageData(s, s, 1, pal_, 1, src);
+ ImageData i_msk = new ImageData(s, s, 1, pal_, 1, msk);
+ overview_cursor_ = new Cursor(null, i_src, i_msk, 0, 0);
}
+ corner_control_.setCursor(overview_cursor_);
// convert to global coordinates
p = toGlobalCoordinates(corner_control_, mx, my);
save_cursor_x = p.x;
@@ -1667,23 +1885,33 @@ public class ScrollView extends Composite {
}
- /** Process disappear of overview */
+ /**
+ * Process disappear of overview
+ */
protected void overviewDisappear() {
overviewDisappear(true);
}
- /** Process disappear of overview */
+ /**
+ * Process disappear of overview
+ * @param restoreCursorLoc A flag to restore cursor location
+ */
protected void overviewDisappear(boolean restoreCursorLoc) {
if (overview == null)
return;
overview.setVisible(false);
corner_control_.setCursor(null);
- if (restoreCursorLoc)
+ if (restoreCursorLoc) {
getDisplay().setCursorLocation(save_cursor_x, save_cursor_y);
+ }
overview.dispose();
overview = null;
}
+ /**
+ * Process mouse move in overview
+ * @param event The mouse event
+ */
protected void overviewMove(MouseEvent event) {
Point p = toGlobalCoordinates(corner_control_, event.x, event.y);
int dx = p.x - save_cursor_x;
@@ -1691,7 +1919,13 @@ public class ScrollView extends Composite {
overviewMove(dx, dy, event);
}
- /** Process mouse move event when overviewing */
+ /**
+ * Process mouse move event when overviewing
+ *
+ * @param dx The x coordinates delta
+ * @param dy The y coordinates delta
+ * @param event The typed event
+ */
protected void overviewMove(int dx, int dy, TypedEvent event) {
boolean ctrl = false;
boolean shift = false;
@@ -1733,6 +1967,14 @@ public class ScrollView extends Composite {
}
}
+ /**
+ * Convert overview coordinates to global coordinates.
+ *
+ * @param _loc the control reference
+ * @param _x The x coordinate to convert
+ * @param _y The y coordinate to convert
+ * @return
+ */
protected Point toGlobalCoordinates(Control _loc, int _x, int _y) {
Point p = new Point(_x, _y);
for (Control c = _loc; c != null; c = c.getParent()) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java
index d1b7eff752..66119257aa 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: TimeCompressionBar.java,v 1.3 2008/01/24 02:29:01 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -17,6 +18,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage;
@@ -57,39 +61,98 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
/**
+ *
+ * The time compression bar implementation.
+ *
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class TimeCompressionBar extends ScrollView implements DisposeListener {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
* The listener list
*/
protected ArrayList listenerList = null;
-
+ /**
+ * The current frame displayed.
+ */
protected Frame frame = null;
+ /**
+ * List of time events.
+ */
protected List nodeList = null;
+ /**
+ * The minimum time delta.
+ */
protected ITmfTimestamp min = new TmfTimestamp();
+ /**
+ * The maximum time delta.
+ */
protected ITmfTimestamp max = new TmfTimestamp();
+ /**
+ * The current zoom value.
+ */
protected float zoomValue = 1;
+ /**
+ * The tooltip to display.
+ */
protected DrawableToolTip tooltip = null;
-
+ /**
+ * Array of colors for displaying wight of time deltas.
+ */
protected ColorImpl[] col;
-
+ /**
+ * The accessible object reference.
+ */
protected Accessible accessible = null;
-
+ /**
+ * The focused widget reference.
+ */
protected int focusedWidget = -1;
-
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView view = null;
-
+ /**
+ * The current lifeline.
+ */
protected Lifeline ll = null;
+ /**
+ * The current start event value.
+ */
protected int ls = 0;
+ /**
+ * The current number of events.
+ */
protected int ln = 0;
+ /**
+ * The Current color of range to display.
+ */
protected IColor lc = null;
-
+ /**
+ * The next graph node y coordinate.
+ */
protected int nextNodeY = 0;
+ /**
+ * The previous graph node y coordinate.
+ */
protected int prevNodeY = 0;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Standard constructor
+ *
+ * @param parent The parent composite
+ * @param s The style bits
+ */
public TimeCompressionBar(Composite parent, int s) {
super(parent, s | SWT.NO_BACKGROUND, false);
setVScrollBarMode(ScrollView.ALWAYS_OFF);
@@ -118,8 +181,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
}
// Case toolTip
else if (e.childID == 0) {
- if (tooltip != null)
+ if (tooltip != null) {
e.result = tooltip.getAccessibleText();
+ }
} else if (e.childID == 1) {
createFakeTooltip();
e.result = tooltip.getAccessibleText();
@@ -128,14 +192,24 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
});
accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getFocus(org.eclipse.swt.accessibility.AccessibleControlEvent)
+ */
@Override
public void getFocus(AccessibleControlEvent e) {
- if (focusedWidget == -1)
+ if (focusedWidget == -1) {
e.childID = ACC.CHILDID_SELF;
- else
+ }
+ else {
e.childID = focusedWidget;
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getRole(org.eclipse.swt.accessibility.AccessibleControlEvent)
+ */
@Override
public void getRole(AccessibleControlEvent e) {
switch (e.childID) {
@@ -151,6 +225,10 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getState(org.eclipse.swt.accessibility.AccessibleControlEvent)
+ */
@Override
public void getState(AccessibleControlEvent e) {
e.detail = ACC.STATE_FOCUSABLE;
@@ -158,42 +236,58 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
e.detail |= ACC.STATE_FOCUSED;
} else {
e.detail |= ACC.STATE_SELECTABLE;
- if (e.childID == focusedWidget)
+ if (e.childID == focusedWidget) {
e.detail |= ACC.STATE_FOCUSED | ACC.STATE_SELECTED | ACC.STATE_CHECKED;
+ }
}
}
});
getViewControl().addTraverseListener(new TraverseListener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
+ */
@Override
public void keyTraversed(TraverseEvent e) {
- if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))
+ if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
e.doit = true;
-
+ }
}
});
addTraverseListener(new TraverseListener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
+ */
@Override
public void keyTraversed(TraverseEvent e) {
- if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))
+ if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
e.doit = true;
-
+ }
}
});
getViewControl().addFocusListener(new FocusListener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
+ */
@Override
public void focusGained(FocusEvent e) {
-
redraw();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
@Override
public void focusLost(FocusEvent e) {
redraw();
@@ -201,6 +295,15 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
});
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Sets the focus widget
+ *
+ * @param newFocusShape widget reference to set
+ */
void setFocus(int newFocusShape) {
focusedWidget = newFocusShape;
if (focusedWidget == -1) {
@@ -210,51 +313,67 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
}
}
+ /**
+ * Sets the current frame.
+ *
+ * @param theFrame The frame to set
+ */
public void setFrame(Frame theFrame) {
frame = theFrame;
min = frame.getMinTime();
max = frame.getMaxTime();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
+ */
@Override
protected void drawContents(GC gc, int clipx, int clipy, int clipw, int cliph) {
- if (frame == null)
+ if (frame == null) {
return;
+ }
nodeList = new ArrayList();
int messageArraysStep = 1;
- if ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * zoomValue < Metrics.MESSAGE_SIGNIFICANT_VSPACING + 1)
+ if ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * zoomValue < Metrics.MESSAGE_SIGNIFICANT_VSPACING + 1) {
messageArraysStep = Math.round(Metrics.MESSAGE_SIGNIFICANT_VSPACING + 1 / ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * zoomValue));
+ }
int firstVisible = frame.getFirstVisibleSyncMessage();
- if (firstVisible > 0)
+ if (firstVisible > 0) {
firstVisible = firstVisible - 1;
+ }
for (int i = firstVisible; i < frame.syncMessageCount(); i = i + messageArraysStep) {
SyncMessage m = frame.getSyncMessage(i);
if (m.hasTimeInfo()) {
SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
nodeList.add(t);
- if (m.getY() * zoomValue > getContentsY() + getVisibleHeight())
+ if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
break;
+ }
}
}
firstVisible = frame.getFirstVisibleSyncMessageReturn();
- if (firstVisible > 0)
+ if (firstVisible > 0) {
firstVisible = firstVisible - 1;
+ }
for (int i = firstVisible; i < frame.syncMessageReturnCount(); i = i + messageArraysStep) {
SyncMessage m = frame.getSyncMessageReturn(i);
if (m.hasTimeInfo()) {
SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
nodeList.add(t);
- if (m.getY() * zoomValue > getContentsY() + getVisibleHeight())
+ if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
break;
+ }
}
}
firstVisible = frame.getFirstVisibleAsyncMessage();
- if (firstVisible > 0)
+ if (firstVisible > 0) {
firstVisible = firstVisible - 1;
+ }
for (int i = firstVisible; i < frame.asyncMessageCount(); i = i + messageArraysStep) {
AsyncMessage m = frame.getAsyncMessage(i);
if (m.hasTimeInfo()) {
@@ -262,14 +381,16 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
nodeList.add(t);
t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
nodeList.add(t);
- if (m.getY() * zoomValue > getContentsY() + getVisibleHeight())
+ if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
break;
+ }
}
}
firstVisible = frame.getFirstVisibleAsyncMessageReturn();
- if (firstVisible > 0)
+ if (firstVisible > 0) {
firstVisible = firstVisible - 1;
+ }
for (int i = firstVisible; i < frame.asyncMessageReturnCount(); i = i + messageArraysStep) {
AsyncMessageReturn m = frame.getAsyncMessageReturn(i);
if (m.hasTimeInfo()) {
@@ -277,28 +398,12 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
nodeList.add(t);
t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
nodeList.add(t);
- if (m.getY() * zoomValue > getContentsY() + getVisibleHeight())
+ if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
break;
+ }
}
}
- /*
- * for (int i=0; igetContentsY()+getVisibleHeight()) break;
- * }
- * float g= lifeline.getX()*zoomValue;
- * int h=frame.getContentX(); int r=frame.getVisibleWidth();
- * }
- */
List executionOccurrencesWithTime = frame.getExecutionOccurrencesWithTime();
if (executionOccurrencesWithTime != null) {
nodeList.addAll(executionOccurrencesWithTime);
@@ -313,7 +418,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
try {
dbuffer = new Image(getDisplay(), getClientArea().width, getClientArea().height);
} catch (Exception e) {
- System.out.println(e.toString());
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error creating image", e)); //$NON-NLS-1$
}
gcim = new GC(dbuffer);
for (int i = 0; i < nodeList.size() - 1; i++) {
@@ -324,56 +429,64 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
- if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null))
+ if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
continue;
+ }
}
}
min = frame.getMinTime();
max = frame.getMaxTime();
- ITmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
+ ITmfTimestamp minMaxdelta = max.getDelta(min);
double gr = (minMaxdelta.getValue()) / (double) 10;
- ITmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime()).getDelta(min);
+ ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
long absDelta = Math.abs(delta.getValue());
ColorImpl color;
if (gr != 0) {
int colIndex = Math.round((float) (absDelta / gr));
- if (colIndex < col.length && colIndex > 0)
+ if (colIndex < col.length && colIndex > 0) {
color = col[colIndex - 1];
- else if (colIndex <= 0)
+ } else if (colIndex <= 0) {
color = col[0];
- else
+ } else {
color = col[col.length - 1];
- } else
+ }
+ } else {
color = col[0];
+ }
- if (color.getColor() instanceof Color)
+ if (color.getColor() instanceof Color) {
gcim.setBackground((Color) color.getColor());
+ }
int y1 = ((GraphNode) m1.getGraphNode()).getY();
int y2 = ((GraphNode) m2.getGraphNode()).getY();
if (m1.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m1.getGraphNode();
- if (as.getEndTime() == m1.getTime())
+ if (as.getEndTime() == m1.getTime()) {
y1 += as.getHeight();
+ }
}
if (m2.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m2.getGraphNode();
- if (as.getEndTime() == m2.getTime())
+ if (as.getEndTime() == m2.getTime()) {
y2 += as.getHeight();
+ }
}
if (m1.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
- if (m1.getEvent() == eo.getEndOccurrence())
+ if (m1.getEvent() == eo.getEndOccurrence()) {
y1 += eo.getHeight();
+ }
if (m2.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
- if (m2.getEvent() == eo2.getEndOccurrence())
+ if (m2.getEvent() == eo2.getEndOccurrence()) {
y2 += eo2.getHeight();
+ }
}
}
@@ -391,7 +504,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
try {
gc.drawImage(dbuffer, 0, 0, getClientArea().width, getClientArea().height, 0, 0, getClientArea().width, getClientArea().height);
} catch (Exception e) {
- System.out.println(e.getMessage());
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error drawing image", e)); //$NON-NLS-1$
}
gcim.dispose();
if (dbuffer != null) {
@@ -400,41 +513,57 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
gc.dispose();
}
+ /**
+ * Checks for focus of children.
+ *
+ * @param children Control to check
+ * @return true if child is on focus else false
+ */
protected boolean checkFocusOnChilds(Control childs) {
if (childs instanceof Composite) {
Control[] child = ((Composite) childs).getChildren();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else
+ } else {
checkFocusOnChilds(child[i]);
+ }
}
}
return false;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Control#isFocusControl()
+ */
@Override
public boolean isFocusControl() {
Control[] child = getChildren();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else
+ } else {
checkFocusOnChilds(child[i]);
+ }
}
return false;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
+ */
@Override
protected void contentsMouseMoveEvent(MouseEvent event) {
- if (tooltip != null)
+ if (tooltip != null) {
tooltip.hideToolTip();
+ }
super.contentsMouseMoveEvent(event);
if (!isFocusControl() || getViewControl().isFocusControl()) {
Control[] child = getParent().getChildren();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
- // getViewControl().setFocus();
break;
}
}
@@ -442,6 +571,10 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
setFocus(-1);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
+ */
@Override
protected void contentsMouseHover(MouseEvent e) {
if (tooltip == null) {
@@ -457,8 +590,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
- if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null))
+ if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
continue;
+ }
}
}
@@ -467,31 +601,34 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
if (m1.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m1.getGraphNode();
- if (as.getEndTime() == m1.getTime())
+ if (as.getEndTime() == m1.getTime()) {
y1 += as.getHeight();
+ }
}
if (m2.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m2.getGraphNode();
- if (as.getEndTime() == m2.getTime())
+ if (as.getEndTime() == m2.getTime()) {
y2 += as.getHeight();
+ }
}
if (m1.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
- if (m1.getEvent() == eo.getEndOccurrence())
+ if (m1.getEvent() == eo.getEndOccurrence()) {
y1 += eo.getHeight();
+ }
if (m2.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
- if (m2.getEvent() == eo2.getEndOccurrence())
+ if (m2.getEvent() == eo2.getEndOccurrence()) {
y2 += eo2.getHeight();
-
+ }
}
}
int m1Y = Math.round(y1 * zoomValue);
int m2Y = Math.round(y2 * zoomValue);
if ((m1Y < e.y) && (m2Y >= e.y)) {
- TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
+ ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
tooltip.showToolTip(delta, min, max);
}
}
@@ -499,12 +636,20 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
setFocus(0);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseExit(org.eclipse.swt.events.MouseEvent)
+ */
@Override
protected void contentsMouseExit(MouseEvent e) {
if (tooltip != null)
tooltip.hideToolTip();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
+ */
@Override
protected void contentsMouseUpEvent(MouseEvent event) {
selectTimeDelta(event.y, 0);
@@ -517,15 +662,18 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
* occurrences are highlighted on the first message's end lifeline
*
* @param mes1 the first message
- * @param mes2
+ * @param mes2 the second message
*/
public void highlightRegion(BaseMessage mes1, BaseMessage mes2) {
- if (frame == null)
+ if (frame == null) {
return;
- if (!(mes1 instanceof ITimeRange))
+ }
+ if (!(mes1 instanceof ITimeRange)) {
return;
- if (!(mes2 instanceof ITimeRange))
+ }
+ if (!(mes2 instanceof ITimeRange)) {
return;
+ }
ITimeRange t1 = (ITimeRange) mes1;
ITimeRange t2 = (ITimeRange) mes2;
@@ -580,29 +728,32 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
}
}
- TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
+ ITmfTimestamp minMaxdelta = max.getDelta(min);
double gr = (minMaxdelta.getValue()) / (double) 10;
- TmfTimestamp delta = (TmfTimestamp) time2.getDelta(time1).getDelta(min);
+ ITmfTimestamp delta = time2.getDelta(time1).getDelta(min);
long absDelta = Math.abs(delta.getValue());
int colIndex = 0;
if (gr != 0) {
colIndex = Math.round((float) (absDelta / gr));
- if (colIndex >= col.length)
+ if (colIndex >= col.length) {
colIndex = col.length - 1;
- else if (colIndex < 0)
+ } else if (colIndex < 0) {
colIndex = 0;
- } else
+ }
+ } else {
colIndex = 0;
+ }
for (int j = 0; j < listenerList.size(); j++) {
ITimeCompressionListener list = (ITimeCompressionListener) listenerList.get(j);
if (mes1.getEndLifeline() != null) {
list.deltaSelected(mes1.getEndLifeline(), event1, event2 - event1, col[colIndex]);
} else if (mes2.getStartLifeline() != null) {
list.deltaSelected(mes2.getStartLifeline(), event1, event2 - event1, col[colIndex]);
- } else
+ } else {
list.deltaSelected(mes1.getStartLifeline(), event1, event2 - event1, col[colIndex]);
+ }
}
}
@@ -611,7 +762,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
* occurrences are highlighted on the first message's end lifeline
*
* @param mes1 the first message
- * @param mes2
+ * @param mes2 the second message
*/
public void highlightRegionSync(final BaseMessage mes1, final BaseMessage mes2) {
getDisplay().syncExec(new Runnable() {
@@ -622,37 +773,68 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
});
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#scrollBy(int, int)
+ */
@Override
public void scrollBy(int x, int y) {
}
+ /**
+ * Sets the zoom value.
+ *
+ * @param value The zoom value to set.
+ */
public void setZoom(float value) {
zoomValue = value;
redraw();
}
+ /**
+ * Adds a listener to the time compression listener list to be notified about selected deltas.
+ *
+ * @param listener The listener to add
+ */
public void addTimeCompressionListener(ITimeCompressionListener listener) {
- if (!listenerList.contains(listener))
+ if (!listenerList.contains(listener)) {
listenerList.add(listener);
+ }
}
+ /**
+ * Removes a time compression listener.
+ *
+ * @param listener The listener to remove.
+ */
public void removeSelectionChangedListener(ITimeCompressionListener listener) {
listenerList.remove(listener);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
+ */
@Override
public void widgetDisposed(DisposeEvent e) {
- if (tooltip != null)
+ if (tooltip != null) {
tooltip.dispose();
+ }
super.removeDisposeListener(this);
- for (int i = 0; i < col.length; i++)
+ for (int i = 0; i < col.length; i++) {
col[i].dispose();
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
+ */
@Override
protected void keyPressedEvent(KeyEvent _e) {
- if (tooltip != null)
+ if (tooltip != null) {
tooltip.hideToolTip();
+ }
if (!isFocusControl() || getViewControl().isFocusControl()) {
Control[] child = getParent().getChildren();
for (int i = 0; i < child.length; i++) {
@@ -665,8 +847,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
setFocus(-1);
boolean top = false;
- if (nextNodeY == 0)
+ if (nextNodeY == 0) {
top = true;
+ }
if ((frame != null) && (nextNodeY == 0)) {
for (int i = 0; i < nodeList.size() - 1 && i < 1; i++) {
SDTimeEvent m1 = (SDTimeEvent) nodeList.get(i);
@@ -675,8 +858,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
- if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null))
+ if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
continue;
+ }
}
}
@@ -684,25 +868,28 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
int y2 = ((GraphNode) m2.getGraphNode()).getY();
if (m1.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m1.getGraphNode();
- if (as.getEndTime() == m1.getTime())
+ if (as.getEndTime() == m1.getTime()) {
y1 += as.getHeight();
+ }
}
if (m2.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m2.getGraphNode();
- if (as.getEndTime() == m2.getTime())
+ if (as.getEndTime() == m2.getTime()) {
y2 += as.getHeight();
+ }
}
if (m1.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
- if (m1.getEvent() == eo.getEndOccurrence())
+ if (m1.getEvent() == eo.getEndOccurrence()) {
y1 += eo.getHeight();
+ }
if (m2.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
- if (m2.getEvent() == eo2.getEndOccurrence())
+ if (m2.getEvent() == eo2.getEndOccurrence()) {
y2 += eo2.getHeight();
-
+ }
}
}
prevNodeY = Math.round(y1 * zoomValue);
@@ -710,17 +897,19 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
}
}
- if (ll != null)
+ if (ll != null) {
for (int j = 0; j < listenerList.size(); j++) {
ITimeCompressionListener list = (ITimeCompressionListener) listenerList.get(j);
list.deltaSelected(ll, ls, ln, lc);
}
+ }
if (_e.keyCode == SWT.ARROW_DOWN) {
- if (!top)
+ if (!top) {
selectTimeDelta(nextNodeY + 1, 1);
- else
+ } else {
selectTimeDelta(prevNodeY + 1, 1);
+ }
setFocus(1);
} else if (_e.keyCode == SWT.ARROW_UP) {
selectTimeDelta(prevNodeY - 1, 2);
@@ -732,16 +921,20 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
super.keyPressedEvent(_e);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
+ */
@Override
protected void keyReleasedEvent(KeyEvent _e) {
super.keyReleasedEvent(_e);
}
/**
- * 0 no direction, 1 = down, 2 = up
+ * Selects the time delta for given delta y coordinate and direction.
*
- * @param dy
- * @param direction
+ * @param dy The delta in y coordinate.
+ * @param direction 0 no direction, 1 = down, 2 = up
*/
protected void selectTimeDelta(int dy, int direction) {
SDTimeEvent lastM1 = null;
@@ -757,8 +950,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
- if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null))
+ if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
continue;
+ }
}
}
@@ -766,25 +960,27 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
int y2 = ((GraphNode) m2.getGraphNode()).getY();
if (m1.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m1.getGraphNode();
- if (as.getEndTime() == m1.getTime())
+ if (as.getEndTime() == m1.getTime()) {
y1 += as.getHeight();
+ }
}
if (m2.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m2.getGraphNode();
- if (as.getEndTime() == m2.getTime())
+ if (as.getEndTime() == m2.getTime()) {
y2 += as.getHeight();
+ }
}
if (m1.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
- if (m1.getEvent() == eo.getEndOccurrence())
+ if (m1.getEvent() == eo.getEndOccurrence()) {
y1 += eo.getHeight();
+ }
if (m2.getGraphNode() instanceof ExecutionOccurrence) {
-
ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
- if (m2.getEvent() == eo2.getEndOccurrence())
+ if (m2.getEvent() == eo2.getEndOccurrence()) {
y2 += eo2.getHeight();
-
+ }
}
}
int m1Y = Math.round(y1 * zoomValue);
@@ -800,21 +996,23 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
done = true;
prevNodeY = m1Y;
nextNodeY = m2Y;
- TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
+ ITmfTimestamp minMaxdelta = max.getDelta(min);
double gr = (minMaxdelta.getValue()) / (double) 10;
- TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime()).getDelta(min);
+ ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
long absDelta = Math.abs(delta.getValue());
int colIndex = 0;
if (gr != 0) {
colIndex = Math.round((float) (absDelta / gr));
- if (colIndex >= col.length)
+ if (colIndex >= col.length) {
colIndex = col.length - 1;
- else if (colIndex < 0)
+ } else if (colIndex < 0) {
colIndex = 0;
- } else
+ }
+ } else {
colIndex = 0;
+ }
if (m1.getGraphNode() instanceof BaseMessage) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
if (mes1.getEndLifeline() != null) {
@@ -863,10 +1061,14 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
}
}
+ /**
+ * Creates a fake tool tip.
+ */
protected void createFakeTooltip() {
if (tooltip == null) {
tooltip = new DrawableToolTip(this);
}
+
if (frame != null) {
setFocus(0);
for (int i = 0; i < nodeList.size() - 1; i++) {
@@ -877,8 +1079,9 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
- if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null))
+ if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
continue;
+ }
}
}
@@ -887,31 +1090,34 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
if (m1.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m1.getGraphNode();
- if (as.getEndTime() == m1.getTime())
+ if (as.getEndTime() == m1.getTime()) {
y1 += as.getHeight();
+ }
}
if (m2.getGraphNode() instanceof AsyncMessage) {
AsyncMessage as = (AsyncMessage) m2.getGraphNode();
- if (as.getEndTime() == m2.getTime())
+ if (as.getEndTime() == m2.getTime()) {
y2 += as.getHeight();
+ }
}
if (m1.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
- if (m1.getEvent() == eo.getEndOccurrence())
+ if (m1.getEvent() == eo.getEndOccurrence()) {
y1 += eo.getHeight();
+ }
if (m2.getGraphNode() instanceof ExecutionOccurrence) {
ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
- if (m2.getEvent() == eo2.getEndOccurrence())
+ if (m2.getEvent() == eo2.getEndOccurrence()) {
y2 += eo2.getHeight();
-
+ }
}
}
int m1Y = Math.round(y1 * zoomValue);
int m2Y = Math.round(y2 * zoomValue);
if ((m1Y < prevNodeY + 1) && (m2Y >= prevNodeY + 1)) {
- TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
+ ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
tooltip.showToolTip(delta, min, max);
tooltip.hideToolTip();
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java
index 20c58fee29..4e8dc37d34 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessage.java
@@ -1,10 +1,9 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: AsyncMessage.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -17,7 +16,7 @@ import java.util.Comparator;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortAsyncForBackward;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortAsyncMessageComparator;
@@ -46,33 +45,57 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortAsyncMessageComparato
*
*
* @see Lifeline Lifeline for more event occurence details
+ * @version 1.0
* @author sveyrier
*
*/
public class AsyncMessage extends BaseMessage implements ITimeRange {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The grahNode ID constant
+ */
+ public static final String ASYNC_MESS_TAG = "AsyncMessage"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Flag whether message has time information or not.
+ */
protected boolean hasTime = false;
/**
* The time when the message begin
*/
protected ITmfTimestamp endTime = new TmfTimestamp();
-
/**
* The time when the message end
*/
protected ITmfTimestamp startTime = new TmfTimestamp();
-
/**
* The associated message.
*/
protected AsyncMessageReturn messageReturn = null;
- public static final String ASYNC_MESS_TAG = "AsyncMessage"; //$NON-NLS-1$
-
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public AsyncMessage() {
prefId = ISDPreferences.PREF_ASYNC_MESS;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getX()
+ */
@Override
public int getX() {
int x = super.getX(true);
@@ -86,7 +109,11 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
}
return x;
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getY()
+ */
@Override
public int getY() {
if ((startLifeline != null) && (endLifeline != null)) {
@@ -95,6 +122,10 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
return super.getY();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getWidth()
+ */
@Override
public int getWidth() {
int width = super.getWidth(true);
@@ -103,15 +134,21 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
activationWidth = -activationWidth;
}
- if (isMessageStartInActivation(startEventOccurrence))
+ if (isMessageStartInActivation(startEventOccurrence)) {
width = width - activationWidth;
+ }
- if (isMessageEndInActivation(endEventOccurrence))
+ if (isMessageEndInActivation(endEventOccurrence)) {
width = width - activationWidth;
+ }
return width;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getHeight()
+ */
@Override
public int getHeight() {
if ((startLifeline != null) && (endLifeline != null)) {
@@ -136,15 +173,22 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
*/
public void setEndOccurrence(int occurrence) {
endEventOccurrence = occurrence;
- if (getStartLifeline() == null)
+ if (getStartLifeline() == null) {
startEventOccurrence = occurrence;
+ }
informFrame(getEndLifeline(), occurrence);
}
+ /**
+ * Informs the given lifeline about the maximum occurrence if applicable.
+ *
+ * @param lifeLine
+ * @param occurrence
+ */
protected void informFrame(Lifeline lifeLine, int occurrence) {
- if ((lifeLine != null) && (lifeLine.getFrame() != null))
- if (lifeLine.getFrame().getMaxEventOccurrence() < occurrence)
- lifeLine.getFrame().setMaxEventOccurrence(occurrence);
+ if ((lifeLine != null) && (lifeLine.getFrame() != null) && (lifeLine.getFrame().getMaxEventOccurrence() < occurrence)) {
+ lifeLine.getFrame().setMaxEventOccurrence(occurrence);
+ }
}
/**
@@ -154,8 +198,9 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
*/
public void setStartOccurrence(int occurrence) {
startEventOccurrence = occurrence;
- if (getEndLifeline() == null)
+ if (getEndLifeline() == null) {
endEventOccurrence = startEventOccurrence;
+ }
informFrame(getStartLifeline(), occurrence);
}
@@ -181,23 +226,22 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
setEndLifeline(lifeline);
}
- /**
- * Set the lifeLine which has sent the message.
- *
- * @param lifeline the message sender
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#setStartLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
*/
@Override
public void setStartLifeline(Lifeline lifeline) {
super.setStartLifeline(lifeline);
setStartOccurrence(getStartLifeline().getEventOccurrence());
- if (getEndLifeline() == null)
+ if (getEndLifeline() == null) {
endEventOccurrence = startEventOccurrence;
+ }
}
- /**
- * Set the lifeLine which has received the message.
- *
- * @param lifeline the message receiver
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#setEndLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
*/
@Override
public void setEndLifeline(Lifeline lifeline) {
@@ -217,23 +261,32 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
* @return Return true if the point C is on the segment defined with the point A and B, else otherwise
*/
protected boolean isNearSegment(int xA, int yA, int xB, int yB, int xC, int yC) {
- if ((xA > xB) && (xC > xA))
+ if ((xA > xB) && (xC > xA)) {
return false;
- if ((xA < xB) && (xC > xB))
+ }
+ if ((xA < xB) && (xC > xB)) {
return false;
- if ((xA < xB) && (xC < xA))
+ }
+ if ((xA < xB) && (xC < xA)) {
return false;
- if ((xA > xB) && (xC < xB))
+ }
+ if ((xA > xB) && (xC < xB)) {
return false;
+ }
double distAB = Math.sqrt((xB - xA) * (xB - xA) + (yB - yA) * (yB - yA));
double scalar = ((xB - xA) * (xC - xA) + (yB - yA) * (yC - yA)) / distAB;
double distAC = Math.sqrt((xC - xA) * (xC - xA) + (yC - yA) * (yC - yA));
double distToSegment = Math.sqrt(Math.abs(distAC * distAC - scalar * scalar));
- if (distToSegment <= Metrics.MESSAGE_SELECTION_TOLERANCE)
+ if (distToSegment <= Metrics.MESSAGE_SELECTION_TOLERANCE) {
return true;
+ }
return false;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#contains(int, int)
+ */
@Override
public boolean contains(int x, int y) {
// Is it a self message?
@@ -245,15 +298,22 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
int messageMaxWidth = Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH;
int nameWidth = getName().length() * Metrics.getAverageCharWidth();
if (getName().length() * Metrics.getAverageCharWidth() > messageMaxWidth) {
- if (Frame.contains(getX(), getY() - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), messageMaxWidth, Metrics.getMessageFontHeigth(), x, y))
+ if (Frame.contains(getX(), getY() - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), messageMaxWidth, Metrics.getMessageFontHeigth(), x, y)) {
return true;
+ }
} else {
- if (Frame.contains(getX() + (messageMaxWidth - nameWidth) / 2, getY() + getHeight() / 2 - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), nameWidth, Metrics.getMessageFontHeigth(), x, y))
+ if (Frame.contains(getX() + (messageMaxWidth - nameWidth) / 2, getY() + getHeight() / 2 - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), nameWidth, Metrics.getMessageFontHeigth(), x, y)) {
return true;
+ }
}
return false;
}
+ /**
+ * Draws the asynchronous message using giving graphical context.
+ *
+ * @param context A graphical context to draw in.
+ */
protected void drawAsyncMessage(IGC context) {
if (startLifeline != null && endLifeline != null && startLifeline == endLifeline && (startEventOccurrence != endEventOccurrence)) {
int x = getX();
@@ -263,14 +323,17 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
boolean startInActivation = isMessageStartInActivation(startEventOccurrence);
boolean endInActivation = isMessageEndInActivation(endEventOccurrence);
- if (endInActivation && !startInActivation)
+ if (endInActivation && !startInActivation) {
tempx = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
- if (startInActivation && !endInActivation)
+ }
+ if (startInActivation && !endInActivation) {
tempx = -Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
+ }
int tempy = Metrics.INTERNAL_MESSAGE_WIDTH / 2;
- if (getHeight() <= Metrics.INTERNAL_MESSAGE_WIDTH)
+ if (getHeight() <= Metrics.INTERNAL_MESSAGE_WIDTH) {
tempy = getHeight() / 2;
+ }
context.drawLine(x, y, x + Metrics.INTERNAL_MESSAGE_WIDTH / 2, y);
context.drawLine(x + Metrics.INTERNAL_MESSAGE_WIDTH, y + tempy, x + Metrics.INTERNAL_MESSAGE_WIDTH, y + height - tempy);
@@ -286,17 +349,20 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
context.drawTextTruncated(getName(), x + Metrics.INTERNAL_MESSAGE_WIDTH + Metrics.INTERNAL_MESSAGE_V_MARGIN, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH + -Metrics.INTERNAL_MESSAGE_WIDTH,
+Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), !isSelected());
- } else
+ } else {
super.draw(context);
+ }
}
- /**
- * Draws the asynchronous message in the given GC
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
*/
@Override
public void draw(IGC context) {
- if (!isVisible())
+ if (!isVisible()) {
return;
+ }
// Draw it selected?
if (isSelected() && (startLifeline != null && endLifeline != null && startLifeline == endLifeline && (startEventOccurrence != endEventOccurrence))) {
/*
@@ -331,10 +397,11 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
public void setEndTime(ITmfTimestamp time) {
endTime = time.clone();
hasTime = true;
- if (getStartLifeline() != null && getStartLifeline().getFrame() != null)
+ if (getStartLifeline() != null && getStartLifeline().getFrame() != null) {
getStartLifeline().getFrame().setHasTimeInfo(true);
- else if (getEndLifeline() != null && getEndLifeline().getFrame() != null)
+ } else if (getEndLifeline() != null && getEndLifeline().getFrame() != null) {
getEndLifeline().getFrame().setHasTimeInfo(true);
+ }
}
/**
@@ -345,69 +412,95 @@ public class AsyncMessage extends BaseMessage implements ITimeRange {
public void setStartTime(ITmfTimestamp time) {
startTime = time.clone();
hasTime = true;
- if (getStartLifeline() != null && getStartLifeline().getFrame() != null)
+ if (getStartLifeline() != null && getStartLifeline().getFrame() != null) {
getStartLifeline().getFrame().setHasTimeInfo(true);
- else if (getEndLifeline() != null && getEndLifeline().getFrame() != null)
+ } else if (getEndLifeline() != null && getEndLifeline().getFrame() != null) {
getEndLifeline().getFrame().setHasTimeInfo(true);
+ }
}
- /**
- * Returns the time when the message begin
- *
- * @return the time
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getEndTime()
*/
@Override
public ITmfTimestamp getEndTime() {
return endTime;
}
- /**
- * Returns the time when the message end
- *
- * @return the time
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getStartTime()
*/
@Override
public ITmfTimestamp getStartTime() {
return startTime;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo()
+ */
@Override
public boolean hasTimeInfo() {
return hasTime;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#isVisible(int, int, int, int)
+ */
@Override
public boolean isVisible(int x, int y, int width, int height) {
int toDrawY = getY();
int toDrawHeight = getHeight();
- if ((toDrawY > y + height + Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()) && (toDrawY + toDrawHeight > y + height + Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()))
+ if ((toDrawY > y + height + Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()) && (toDrawY + toDrawHeight > y + height + Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth())) {
return false;
- if (toDrawY < y && (toDrawY + toDrawHeight < y))
+ }
+ if (toDrawY < y && (toDrawY + toDrawHeight < y)) {
return false;
+ }
return super.isVisible(x, y, width, height);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getComparator()
+ */
@Override
public Comparator getComparator() {
return new SortAsyncMessageComparator();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
+ */
@Override
public String getArrayId() {
return ASYNC_MESS_TAG;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getBackComparator()
+ */
@Override
public Comparator getBackComparator() {
return new SortAsyncForBackward();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#positiveDistanceToPoint(int, int)
+ */
@Override
public boolean positiveDistanceToPoint(int x, int y) {
int mY = getY();
int mH = getHeight();
- if ((mY > y) || (mY + mH > y))
+ if ((mY > y) || (mY + mH > y)) {
return true;
+ }
return false;
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessageReturn.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessageReturn.java
index c0627a25af..2abe67e38f 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessageReturn.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/AsyncMessageReturn.java
@@ -1,10 +1,9 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: AsyncMessageReturn.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,11 +12,11 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
* The message return graph node implementation.
- * This class differs on the AsynMessage class only on the drawing line style (dashed instead od plain line).
+ * This class differs on the AsynMessage class only on the drawing line style (dashed instead of plain line).
* Message return are generally associated to a message. This means, they are connected to the same lifelines than the
* associated message but in the opposite direction and for a different event occurrence.
*
@@ -26,19 +25,42 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
*
*
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage AsyncMessage for usage example
+ * @version 1.0
* @author sveyrier
*
*/
public class AsyncMessageReturn extends AsyncMessage {
- protected AsyncMessage message;
-
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The grahNode ID constant
+ */
public static final String ASYNC_MESS_RET_TAG = "AsyncMessageRet"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The corresponding asynchronous message.
+ */
+ protected AsyncMessage message;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor.
+ */
public AsyncMessageReturn() {
prefId = ISDPreferences.PREF_ASYNC_MESS_RET;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
* Set the associated message (the message it is the return).
* Setting the association will activate the navigation in the default sequence diagram implementation to the
@@ -50,10 +72,15 @@ public class AsyncMessageReturn extends AsyncMessage {
message = parentMessage;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
- if (!isVisible())
+ if (!isVisible()) {
return;
+ }
prefId = ISDPreferences.PREF_ASYNC_MESS_RET;
int oldStyle = context.getLineStyle();
// Message return are dashed
@@ -67,6 +94,10 @@ public class AsyncMessageReturn extends AsyncMessage {
context.setLineStyle(oldStyle);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getArrayId()
+ */
@Override
public String getArrayId() {
return ASYNC_MESS_RET_TAG;
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java
index 0e75899980..dbc497f45e 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BaseMessage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: BaseMessage.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -14,7 +15,7 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
* The base UML2 syncMessages implementation.
@@ -26,28 +27,44 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
*
*
* @see Lifeline Lifeline for more event occurence details
+ * @version 1.0
* @author sveyrier
*/
public abstract class BaseMessage extends GraphNode {
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
/**
* The lifeline which send the message
*/
protected Lifeline startLifeline = null;
-
/**
* The lifeline which receive the message
*/
protected Lifeline endLifeline = null;
-
+ /**
+ * The visiblitiy flag.
+ */
protected boolean visible = true;
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
+ */
@Override
public int getX() {
// returns the exact x coordinate
return getX(false);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
+ */
@Override
public int getY() {
/*
@@ -80,12 +97,20 @@ public abstract class BaseMessage extends GraphNode {
return 0;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
+ */
@Override
public int getWidth() {
// Returns the exact width
return getWidth(false);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
+ */
@Override
public int getHeight() {
return 0;
@@ -121,8 +146,9 @@ public abstract class BaseMessage extends GraphNode {
}
}
- if (quick)
+ if (quick) {
return x;
+ }
if ((startLifeline != null) && (endLifeline != null) && (startLifeline.getX() > endLifeline.getX())) {
activationWidth = -activationWidth;
@@ -154,10 +180,11 @@ public abstract class BaseMessage extends GraphNode {
int width = 0;
int activationWidth = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
if ((startLifeline != null) && (endLifeline != null)) {
- if (startLifeline == endLifeline)
+ if (startLifeline == endLifeline) {
width = Metrics.INTERNAL_MESSAGE_WIDTH + Metrics.EXECUTION_OCCURRENCE_WIDTH;
- else
+ } else {
width = endLifeline.getX() + Metrics.getLifelineWidth() / 2 - getX(true);
+ }
} else {
if (startLifeline != null) {
width = Metrics.swimmingLaneWidth() / 2;
@@ -167,42 +194,59 @@ public abstract class BaseMessage extends GraphNode {
}
}
- if (quick)
+ if (quick) {
return width;
+ }
if ((startLifeline != null) && (endLifeline != null) && (startLifeline.getX() > endLifeline.getX())) {
activationWidth = -activationWidth;
}
- if (isMessageStartInActivation(endEventOccurrence))
+ if (isMessageStartInActivation(endEventOccurrence)) {
width = width - activationWidth;
+ }
- if (isMessageEndInActivation(endEventOccurrence))
+ if (isMessageEndInActivation(endEventOccurrence)) {
width = width - activationWidth;
+ }
return width;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isVisible(int, int, int, int)
+ */
@Override
public boolean isVisible(int x, int y, int width, int height) {
// ***Common*** syncMessages visibility
// draw the message only if at least one end is visible
- if (endLifeline != null && (endLifeline.isVisible(x, y, width, height)) || (startLifeline != null && startLifeline.isVisible(x, y, width, height)))
+ if (endLifeline != null && (endLifeline.isVisible(x, y, width, height)) || (startLifeline != null && startLifeline.isVisible(x, y, width, height))) {
return true;
+ }
// In this case it can be a message which cross the whole visible area
else if (endLifeline != null && (!endLifeline.isVisible(x, y, width, height)) && (startLifeline != null && !startLifeline.isVisible(x, y, width, height))) {
- if (endLifeline.getX() > x + width && startLifeline.getX() < x)
+ if (endLifeline.getX() > x + width && startLifeline.getX() < x) {
return true;
- else if (startLifeline.getX() > x + width && endLifeline.getX() < x)
+ } else if (startLifeline.getX() > x + width && endLifeline.getX() < x) {
return true;
+ }
}
return false;
}
+ /**
+ * Sets the visibility value.
+ *
+ * @param value The visibility to set.
+ */
public void setVisible(boolean value) {
visible = value;
}
+ /**
+ * @return the visibility value.
+ */
public boolean isVisible() {
return visible;
}
@@ -282,12 +326,14 @@ public abstract class BaseMessage extends GraphNode {
int thisY = getY();
for (int i = 0; i < startLifeline.getExecutions().size(); i++) {
BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) startLifeline.getExecutions().get(i);
- if ((event >= toDraw.startEventOccurrence) && (event <= toDraw.endEventOccurrence))
+ if ((event >= toDraw.startEventOccurrence) && (event <= toDraw.endEventOccurrence)) {
inActivation = true;
+ }
// if we are outside the visible area we stop right now
// This works because execution occurrences are ordered along the Y axis
- if (toDraw.getY() > thisY)
+ if (toDraw.getY() > thisY) {
break;
+ }
}
}
return inActivation;
@@ -310,19 +356,22 @@ public abstract class BaseMessage extends GraphNode {
// for drawing speed reason with only search on the visivle subset
for (int i = 0; i < endLifeline.getExecutions().size(); i++) {
BasicExecutionOccurrence toDraw = (BasicExecutionOccurrence) endLifeline.getExecutions().get(i);
- if ((event >= toDraw.startEventOccurrence) && (event <= toDraw.endEventOccurrence))
+ if ((event >= toDraw.startEventOccurrence) && (event <= toDraw.endEventOccurrence)) {
inActivation = true;
+ }
// if we are outside the visible area we stop right now
// This works because execution occurrences are ordered along the Y axis
- if (toDraw.getY() > getY())
+ if (toDraw.getY() > getY()) {
break;
+ }
}
}
return inActivation;
}
- /**
- * Returns true if the message or the message label contains the point given in parameter
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
*/
@Override
public boolean contains(int _x, int _y) {
@@ -341,35 +390,46 @@ public abstract class BaseMessage extends GraphNode {
* rectangle width is negative.
*/
if (getName().length() * Metrics.getAverageCharWidth() > Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH) {
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH, Metrics.getMessageFontHeigth(), _x, _y))
+ if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2 + -Metrics.INTERNAL_MESSAGE_WIDTH, Metrics.getMessageFontHeigth(), _x, _y)) {
return true;
+ }
} else {
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, getName().length() * Metrics.getAverageCharWidth(), Metrics.getMessageFontHeigth(), _x, _y))
+ if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH + 10, y, getName().length() * Metrics.getAverageCharWidth(), Metrics.getMessageFontHeigth(), _x, _y)) {
return true;
+ }
}
// Test if the point is in part 1 of the self message
// see: "private void drawMessage (NGC context)" method for self message drawing schema
- if (Frame.contains(x, y - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, _x, _y))
+ if (Frame.contains(x, y - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, _x, _y)) {
return true;
+ }
// Test if the point is in part 3 of the self message
- if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, y, Metrics.MESSAGE_SELECTION_TOLERANCE, height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, _x, _y))
+ if (Frame.contains(x + Metrics.INTERNAL_MESSAGE_WIDTH - Metrics.MESSAGE_SELECTION_TOLERANCE / 2, y, Metrics.MESSAGE_SELECTION_TOLERANCE, height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, _x, _y)) {
return true;
+ }
// Test if the point is in part 5 of the self message
- if (Frame.contains(x, y + height - Metrics.MESSAGE_SELECTION_TOLERANCE / 2 + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, _x, _y))
+ if (Frame.contains(x, y + height - Metrics.MESSAGE_SELECTION_TOLERANCE / 2 + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, Metrics.INTERNAL_MESSAGE_WIDTH / 2, Metrics.MESSAGE_SELECTION_TOLERANCE, _x, _y)) {
return true;
+ }
// false otherwise
return false;
}
- if (Frame.contains(x, y - tempHeight, width, tempHeight, _x, _y))
+ if (Frame.contains(x, y - tempHeight, width, tempHeight, _x, _y)) {
return true;
+ }
// false otherwise
return false;
}
+ /**
+ * Method to draw the message using the graphical context.
+ *
+ * @param context A graphical context to draw in.
+ */
protected void drawMessage(IGC context) {
int fX, fY, fW, fH;
fX = fY = fW = fH = 0;
@@ -391,8 +451,9 @@ public abstract class BaseMessage extends GraphNode {
context.drawTextTruncatedCentred(getName(), x, y - Metrics.getMessageFontHeigth() - 2 * Metrics.MESSAGES_NAME_SPACING, width, 2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth(), !isSelected());
context.setForeground(temp);
int margin = 0;
- if (endLifeline == null)
+ if (endLifeline == null) {
margin = Metrics.MESSAGE_CIRCLE_RAY;
+ }
// Draw the message main line
context.drawLine(x, y, x + width, y + height);
@@ -421,12 +482,14 @@ public abstract class BaseMessage extends GraphNode {
// Draw a circle at the message end (endLifeline side)
int ray = Metrics.MESSAGE_CIRCLE_RAY;
- if (context.getLineWidth() != Metrics.NORMAL_LINE_WIDTH)
+ if (context.getLineWidth() != Metrics.NORMAL_LINE_WIDTH) {
ray = ray + Metrics.SELECTION_LINE_WIDTH - Metrics.NORMAL_LINE_WIDTH;
- if (startLifeline == null)
+ }
+ if (startLifeline == null) {
context.fillOval(x - ray, y - ray, ray * 2, ray * 2);
- else
+ } else {
context.fillOval(x + width - ray, y + height - ray, ray * 2, ray * 2);
+ }
context.setBackground(storedColor);
context.setForeground(Frame.getUserPref().getFontColor(prefId));
fX = x;
@@ -440,8 +503,9 @@ public abstract class BaseMessage extends GraphNode {
* Self syncMessages are drawn in 5 parts 1 -----------+ + 2 + | | | 3 | + 5 + 4 -----------+
*/
int tempy = Metrics.INTERNAL_MESSAGE_WIDTH / 2;
- if (Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT <= Metrics.INTERNAL_MESSAGE_WIDTH)
+ if (Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT <= Metrics.INTERNAL_MESSAGE_WIDTH) {
tempy = Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT / 2;
+ }
// Part 1
context.drawLine(x, y, x + Metrics.INTERNAL_MESSAGE_WIDTH / 2, y);
@@ -489,12 +553,13 @@ public abstract class BaseMessage extends GraphNode {
// the space available for the text is sorter if are drawing internal message on the last lifeline
context.setForeground(Frame.getUserPref().getFontColor(prefId));
- if (startLifeline.getIndex() == startLifeline.getFrame().getHorizontalIndex())
+ if (startLifeline.getIndex() == startLifeline.getFrame().getHorizontalIndex()) {
context.drawTextTruncated(getName(), x + width + Metrics.INTERNAL_MESSAGE_V_MARGIN / 2, y, Metrics.swimmingLaneWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH + -Metrics.INTERNAL_MESSAGE_WIDTH, +Metrics.MESSAGES_NAME_SPACING
- Metrics.getMessageFontHeigth(), !isSelected());
- else
+ } else {
context.drawTextTruncated(getName(), x + width + Metrics.INTERNAL_MESSAGE_V_MARGIN / 2, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH + -Metrics.INTERNAL_MESSAGE_WIDTH,
+Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), !isSelected());
+ }
}
// it is regular message
else if (startLifeline != null && endLifeline != null) {
@@ -508,8 +573,9 @@ public abstract class BaseMessage extends GraphNode {
double angle = Math.atan(a / b);
// Compute the coordinates of the two little lines which make the arrow part of the message
int sign = 1;
- if (spaceBTWStartEnd < 0)
+ if (spaceBTWStartEnd < 0) {
sign = -1;
+ }
Double x1 = new Double(sign * Math.cos(angle - 0.75) * 7);
Double y1 = new Double(sign * Math.sin(angle - 0.75) * 7);
Double x2 = new Double(sign * Math.cos(angle + 0.75) * 7);
@@ -552,17 +618,23 @@ public abstract class BaseMessage extends GraphNode {
// The label is truncated if it cannot fit between the two message end
// 2*Metrics.MESSAGES_NAME_SPACING = space above the label + space below the label
context.setForeground(Frame.getUserPref().getFontColor(prefId));
- if (spaceBTWStartEnd > 0)
+ if (spaceBTWStartEnd > 0) {
context.drawTextTruncatedCentred(getName(), x, y + height / 2 - (2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()), width, 2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth(), !isSelected());
- else
+ } else {
context.drawTextTruncatedCentred(getName(), x + width, y + height / 2 - (2 * Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()), -width, 2 * Metrics.MESSAGES_NAME_SPACING + +Metrics.getMessageFontHeigth(), !isSelected());
+ }
}
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNodee#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
- if (!isVisible())
+ if (!isVisible()) {
return;
+ }
// Draw it selected?*/
if (isSelected()) {
@@ -597,19 +669,33 @@ public abstract class BaseMessage extends GraphNode {
*
* @param message - the message to compare with
* @return true if identical false otherwise
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isSameAs(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode)
*/
@Override
public boolean isSameAs(GraphNode message) {
- if (message == null)
+ if (message == null) {
return false;
- if (!(message instanceof BaseMessage))
+ }
+ if (!(message instanceof BaseMessage)) {
return super.isSameAs(message);
- if (getX() == message.getX() && getY() == message.getY() && getWidth() == message.getWidth() && getHeight() == message.getHeight())
+ }
+ if (getX() == message.getX() && getY() == message.getY() && getWidth() == message.getWidth() && getHeight() == message.getHeight()) {
return true;
- else
+ } else {
return false;
+ }
}
+ /**
+ * Method drawRot.
+ *
+ * @param x A x coordinate
+ * @param y A y coordinate
+ * @param w A width
+ * @param h A height
+ * @param context A graphical context
+ */
public void drawRot(int x, int y, int w, int h, IGC context) {
double angleA = Math.atan2(getHeight(), getWidth());
double cosA = Math.cos(angleA);
@@ -638,6 +724,10 @@ public abstract class BaseMessage extends GraphNode {
context.drawPolygon(points);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#drawFocus(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void drawFocus(IGC context) {
if ((startLifeline != endLifeline) && (startEventOccurrence == endEventOccurrence)) {
@@ -654,7 +744,8 @@ public abstract class BaseMessage extends GraphNode {
context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
drawRot(getX(), getY() - 5, getWidth(), 10, context);
- } else
+ } else {
super.drawFocus(context);
+ }
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java
index c89253f42e..1c62621c2b 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicExecutionOccurrence.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: BasicExecutionOccurrence.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -14,54 +15,102 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
* BasicExecutionOccurrence is the UML2 execution occurrence graphical representation. It is attached to one Lifeline,
* the event occurrence "duration" along the lifeline is defined by two event occurrences
*
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
+ * @version 1.0
* @author sveyrier
*
*/
public class BasicExecutionOccurrence extends GraphNode {
- protected Lifeline lifeline = null;
-
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The grahNode ID constant
+ */
public static final String EXEC_OCC_TAG = "Execution_Occ"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The corresponding lifeline.
+ */
+ protected Lifeline lifeline = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructore
+ */
public BasicExecutionOccurrence() {
prefId = ISDPreferences.PREF_EXEC;
}
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
+ */
@Override
public int getX() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return lifeline.getX() + Metrics.getLifelineWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
+ */
@Override
public int getY() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return lifeline.getY() + lifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * startEventOccurrence;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
+ */
@Override
public int getWidth() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return Metrics.EXECUTION_OCCURRENCE_WIDTH;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
+ */
@Override
public int getHeight() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return ((Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing())) * (endEventOccurrence - startEventOccurrence);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
+ */
@Override
public boolean contains(int _x, int _y) {
int x = getX();
@@ -73,17 +122,23 @@ public class BasicExecutionOccurrence extends GraphNode {
return true;
}
- if (getNodeAt(_x, _y) != null)
+ if (getNodeAt(_x, _y) != null) {
return true;
+ }
return false;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getName()
+ */
@Override
public String getName() {
- if (super.getName() == null || super.getName().equals("")) //$NON-NLS-1$
+ if (super.getName() == null || super.getName().equals("")) { //$NON-NLS-1$
return lifeline.getToolTipText();
- else
+ } else {
return super.getName();
+ }
}
/**
@@ -142,6 +197,10 @@ public class BasicExecutionOccurrence extends GraphNode {
endEventOccurrence = occurrence;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
int x = getX();
@@ -158,10 +217,11 @@ public class BasicExecutionOccurrence extends GraphNode {
} else {
tempFillColor = setUnselectedFillColor(context);
}
- if (Frame.getUserPref().useGradienColor())
+ if (Frame.getUserPref().useGradienColor()) {
context.fillGradientRectangle(x, y, width, height, false);
- else
+ } else {
context.fillRectangle(x, y, width, height);
+ }
tempStrokeColor = setUnselectedStrokeColor(context);
context.drawRectangle(x, y, width, height);
if (tempFillColor != null) {
@@ -172,8 +232,9 @@ public class BasicExecutionOccurrence extends GraphNode {
tempStrokeColor.dispose();
tempStrokeColor = null;
}
- if (hasFocus())
+ if (hasFocus()) {
drawFocus(context);
+ }
super.drawChildenNodes(context);
}
@@ -187,8 +248,9 @@ public class BasicExecutionOccurrence extends GraphNode {
if (Frame.getUserPref().useGradienColor()) {
context.setGradientColor(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_EXEC));
context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_FRAME));
- } else
+ } else {
context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_EXEC));
+ }
return null;
}
@@ -203,29 +265,45 @@ public class BasicExecutionOccurrence extends GraphNode {
return null;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
+ */
@Override
public String getArrayId() {
return EXEC_OCC_TAG;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#positiveDistanceToPoint(int, int)
+ */
@Override
public boolean positiveDistanceToPoint(int x, int y) {
- if (getY() + getHeight() > y)
+ if (getY() + getHeight() > y) {
return true;
+ }
return false;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isVisible(int, int, int, int)
+ */
@Override
public boolean isVisible(int x, int y, int width, int height) {
if ((getLifeline() != null) && (getLifeline().isVisible(x, y, width, height))) {
int ly = getY();
int lh = getHeight();
- if (ly >= y && ly < y + height)
+ if (ly >= y && ly < y + height) {
return true;
- if (ly + lh > y && ly + lh <= y + height)
+ }
+ if (ly + lh > y && ly + lh <= y + height) {
return true;
- if ((ly < y) && (ly + lh > y + height))
+ }
+ if ((ly < y) && (ly + lh > y + height)) {
return true;
+ }
}
return false;
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java
index f2fd9df41c..775ddadbdd 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: BasicFrame.java,v 1.2 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -19,7 +20,7 @@ import java.util.List;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
/**
@@ -37,6 +38,18 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
*/
public class BasicFrame extends GraphNode {
+ // ------------------------------------------------------------------------
+ // Static Attributes/Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram reference.
+ */
+ protected static ISDPreferences userPref = null;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
* Contains the max elapsed time between two consecutive messages in the whole frame
*/
@@ -45,48 +58,68 @@ public class BasicFrame extends GraphNode {
* Contains the min elapsed time between two consecutive messages in the whole frame
*/
protected ITmfTimestamp minTime = new TmfTimestamp(0);
-
/**
* Indicate if the min and max elapsed time between two consecutive messages in the whole frame need to be computed
*/
protected boolean computeMinMax = true;
-
/**
* Store the preference set by the user regarding the external time. This flag is used determine if the min and max
* need to be recomputed in case this preference is changed.
*/
protected boolean lastExternalTimePref = SDViewPref.getInstance().excludeExternalTime();
-
/**
* The greater event occurrence created on graph nodes drawn in this Frame This directly impact the Frame height
*/
protected int verticalIndex = 0;
-
/**
* The index along the x axis where the next lifeline will is drawn This directly impact the Frame width
*/
protected int horizontalIndex = 0;
-
+ /**
+ * The information flag.
+ */
protected boolean timeInfo = false;
-
/**
- * The current Frame visible area
+ * The current Frame visible area - x coordinates
*/
protected int visibleAreaX;
+ /**
+ * The current Frame visible area - y coordinates
+ */
protected int visibleAreaY;
+ /**
+ * The current Frame visible area - width
+ */
protected int visibleAreaWidth;
+ /**
+ * The current Frame visible area - height
+ */
protected int visibleAreaHeight;
-
- static ISDPreferences userPref = null;
-
+ /**
+ * The event occurrence spacing (-1 for none)
+ */
protected int forceEventOccurrenceSpacing = -1;
-
+ /**
+ * Flag to indicate customized minumum and maximum.
+ */
protected boolean customMinMax = false;
-
+ /**
+ * The minimum time between messages of the sequence diagram frame.
+ */
protected ITmfTimestamp minSDTime = new TmfTimestamp();
+ /**
+ * The maximum time between messages of the sequence diagram frame.
+ */
protected ITmfTimestamp maxSDTime = new TmfTimestamp();
+ /**
+ * Flag to indicate that initial minimum has to be computed.
+ */
protected boolean initSDMin = true;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
* Creates an empty frame.
*/
@@ -94,6 +127,10 @@ public class BasicFrame extends GraphNode {
Metrics.setForcedEventSpacing(forceEventOccurrenceSpacing);
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
*
* Returns the greater event occurence known by the Frame
@@ -135,10 +172,9 @@ public class BasicFrame extends GraphNode {
return horizontalIndex;
}
- /**
- * Add a GraphNode into the frame
- *
- * @param nodeToAdd the node to add
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#addNode(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode)
*/
@Override
public void addNode(GraphNode nodeToAdd) {
@@ -146,8 +182,8 @@ public class BasicFrame extends GraphNode {
super.addNode(nodeToAdd);
}
- /**
- * @return the frame x axis value in the containing view
+ /*
+ * (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
*/
@Override
@@ -155,43 +191,43 @@ public class BasicFrame extends GraphNode {
return Metrics.FRAME_H_MARGIN;
}
- /**
- * @return the frame y axis value in the containing view
- * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
*/
@Override
public int getY() {
return Metrics.FRAME_V_MARGIN;
}
- /**
- * The frame width depends on the number of lifeline added in the frame
- *
- * @return the frame width
+ /*
+ * (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
*/
@Override
public int getWidth() {
- if (horizontalIndex == 0)
+ if (horizontalIndex == 0) {
return 3 * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 - Metrics.FRAME_H_MARGIN - Metrics.LIFELINE_SPACING / 2;
- else
+ } else {
return horizontalIndex * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 + 1 - Metrics.LIFELINE_SPACING;
+ }
}
- /**
- * The Frame height depends on the maximum number of messages added to a lifeline( Taking all lifelines into
- * account)
- *
- * @return the frame height
+ /*
+ * (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
*/
@Override
public int getHeight() {
- if (verticalIndex == 0)
+ // The Frame height depends on the maximum number of messages added to a lifeline
+ if (verticalIndex == 0) {
return 5 * (Metrics.getMessagesSpacing() + Metrics.getMessageFontHeigth()) + Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getFrameFontHeigth() + Metrics.LIFELINE_VT_MAGIN + Metrics.LIFELINE_VB_MAGIN
+ Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getLifelineFontHeigth() * 2;
- if (forceEventOccurrenceSpacing >= 0)
+ }
+ if (forceEventOccurrenceSpacing >= 0) {
Metrics.setForcedEventSpacing(forceEventOccurrenceSpacing);
+ }
return verticalIndex * (Metrics.getMessagesSpacing() + Metrics.getMessageFontHeigth()) + Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getFrameFontHeigth() + Metrics.LIFELINE_VT_MAGIN + Metrics.LIFELINE_VB_MAGIN
+ Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getLifelineFontHeigth() * 2;
}
@@ -206,27 +242,34 @@ public class BasicFrame extends GraphNode {
* @param list the list to search in
* @param fromIndex list browsing starting point
* @return the graph node containing the point given in parameter, null otherwise
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getNodeFromListAt(int, int, java.util.List, int)
*/
@Override
protected GraphNode getNodeFromListAt(int x, int y, List list, int fromIndex) {
- if (list == null)
+ if (list == null) {
return null;
+ }
for (int i = fromIndex; i < list.size(); i++) {
GraphNode node = (GraphNode) list.get(i);
// only lifeline list is x ordered
// Stop browsing the list if the node is outside the visible area
// all others nodes will be not visible
- if ((node instanceof Lifeline) && (node.getX() > visibleAreaX + visibleAreaWidth))
+ if ((node instanceof Lifeline) && (node.getX() > visibleAreaX + visibleAreaWidth)) {
break;
+ }
if (node.getHeight() < 0) {
- if (node.getY() + node.getHeight() > visibleAreaY + visibleAreaHeight)
+ if (node.getY() + node.getHeight() > visibleAreaY + visibleAreaHeight) {
break;
+ }
} else {
- if (node.getY() > visibleAreaY + visibleAreaHeight)
+ if (node.getY() > visibleAreaY + visibleAreaHeight) {
break;
+ }
}
- if (node.contains(x, y))
+ if (node.contains(x, y)) {
return node;
+ }
}
return null;
}
@@ -257,8 +300,9 @@ public class BasicFrame extends GraphNode {
int nameHeight = Metrics.getFrameFontHeigth() + +Metrics.FRAME_NAME_H_MARGIN * 2;
// Draw the frame name area
- if (nameWidth > w)
+ if (nameWidth > w) {
nameWidth = w;
+ }
int[] points = { x, y, x + nameWidth, y, x + nameWidth, y - 11 + nameHeight, x - 11 + nameWidth, y + nameHeight, x, y + nameHeight, x, y + nameHeight };
context.fillPolygon(points);
@@ -272,13 +316,9 @@ public class BasicFrame extends GraphNode {
context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_FRAME));
}
- /**
- * Draws the Frame on the given context.
- * This method start width GraphNodes ordering if needed.
- * After, depending on the visible area, only visible GraphNodes are drawn.
- *
- * @param context the context to draw to
- * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(IGC)
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
*/
@Override
public void draw(IGC context) {
@@ -300,23 +340,39 @@ public class BasicFrame extends GraphNode {
visibleAreaX = context.getContentsX();
visibleAreaY = context.getContentsY();
- if (forceEventOccurrenceSpacing >= 0)
+ if (forceEventOccurrenceSpacing >= 0) {
Metrics.setForcedEventSpacing(forceEventOccurrenceSpacing);
- else
+ } else {
Metrics.setForcedEventSpacing(-1);
- if (userPref == null)
+ }
+ if (userPref == null) {
return;
+ }
super.drawChildenNodes(context);
}
+ /**
+ * Sets the sequence diagram preferences.
+ *
+ * @param pref the preferences to set.
+ */
public static void setUserPref(ISDPreferences pref) {
userPref = pref;
}
+ /**
+ * Returns the sequence diagram preferences.
+ * @return the sequence diagram preferences.
+ */
public static ISDPreferences getUserPref() {
return userPref;
}
+ /**
+ * Sets the event occurrence spacing (-1 for none)
+ *
+ * @param space A spacing to set.
+ */
public void forceEventOccurrenceSpacing(int space) {
forceEventOccurrenceSpacing = space;
}
@@ -406,13 +462,18 @@ public class BasicFrame extends GraphNode {
return maxTime;
}
+ /**
+ * Computes the minimum and maximum time between consecutive messages within the frame.
+ */
protected void computeMaxMinTime() {
- if (!initSDMin)
+ if (!initSDMin) {
return;
+ }
List timeArray = buildTimeArray();
- if (timeArray == null)
+ if (timeArray == null) {
return;
+ }
for (int i = 0; i < timeArray.size(); i++) {
SDTimeEvent m = (SDTimeEvent) timeArray.get(i);
@@ -427,11 +488,21 @@ public class BasicFrame extends GraphNode {
}
}
+ /**
+ * Returns the minimum time between consecutive messages.
+ *
+ * @return the minimum time between consecutive messages
+ */
public ITmfTimestamp getSDMinTime() {
computeMaxMinTime();
return minSDTime;
}
+ /**
+ * Returns the maximum time between consecutive messages.
+ *
+ * @return the maximum time between consecutive messages
+ */
public ITmfTimestamp getSDMaxTime() {
computeMaxMinTime();
return maxSDTime;
@@ -442,17 +513,23 @@ public class BasicFrame extends GraphNode {
*/
protected void computeMinMax() {
List timeArray = buildTimeArray();
- if (timeArray == null)
+ if (timeArray == null) {
return;
+ }
for (int i = 0; i < timeArray.size() - 1; i++) {
SDTimeEvent m1 = (SDTimeEvent) timeArray.get(i);
SDTimeEvent m2 = (SDTimeEvent) timeArray.get(i + 1);
updateMinMax(m1, m2);
-
}
}
+ /**
+ * Updates the minimum and maximum time between consecutive message within the frame based on the given values.
+ *
+ * @param m1 A first SD time event.
+ * @param m2 A second SD time event.
+ */
protected void updateMinMax(SDTimeEvent m1, SDTimeEvent m2) {
ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
if (computeMinMax) {
@@ -473,9 +550,15 @@ public class BasicFrame extends GraphNode {
}
}
+ /**
+ * Builds the time array based on the list of graph nodes.
+ *
+ * @return the time array else null
.
+ */
protected List buildTimeArray() {
- if (!hasChilden)
+ if (!hasChilden) {
return null;
+ }
Iterator it = fSort.keySet().iterator();
List timeArray = new ArrayList();
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/EllipsisisMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/EllipsisMessage.java
similarity index 80%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/EllipsisisMessage.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/EllipsisMessage.java
index 5747530cb3..273570d599 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/EllipsisisMessage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/EllipsisMessage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: EllipsisisMessage.java,v 1.3 2008/01/24 02:29:19 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -14,31 +15,54 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
-public class EllipsisisMessage extends AsyncMessage implements ITimeRange {
+/**
+ * Class to draw Ellipsis Message.
+ *
+ * @version 1.0
+ * @author sveyrier
+ *
+ */
+public class EllipsisMessage extends AsyncMessage implements ITimeRange {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getX()
+ */
@Override
public int getX() {
- if (startLifeline == null)
+ if (startLifeline == null) {
return super.getX() + super.getWidth() - 16;
- else
- return super.getX();
+ }
+ return super.getX();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getY()
+ */
@Override
public int getY() {
return super.getY() + 3;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getWidth()
+ */
@Override
public int getWidth() {
return 16;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#drawMessage(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
protected void drawMessage(IGC context) {
- // temporay store the coordinates to avoid more methods calls
+ // temporary store the coordinates to avoid more methods calls
int x = super.getX();
int y = getY();
int width = super.getWidth();
@@ -90,14 +114,20 @@ public class EllipsisisMessage extends AsyncMessage implements ITimeRange {
context.setBackground(storedColor);
- } else
+ } else {
super.draw(context);
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
- if (!isVisible())
+ if (!isVisible()) {
return;
+ }
// Draw it selected?*/
if (isSelected()) {
/*
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java
index 2c165b3932..a7a1c7fdca 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ExecutionOccurrence.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ExecutionOccurrence.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -16,29 +17,57 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
* ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on
- * which you can customize fill and/or
+ * which you can customize fill and/or.
*
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
+ * @version 1.0
* @author sveyrier
*
*/
public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITimeRange {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
+ */
protected int[] fillRGB;
+ /**
+ * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
+ */
protected int[] strokeRGB;
- protected IImage image, ellipsesImage;
-
- protected ITmfTimestamp startTime, endTime;
+ /**
+ * The occurrence image.
+ */
+ protected IImage image;
+ /**
+ * The top ellipses image.
+ */
+ protected IImage ellipsesImage;
+ /**
+ * The start time stamp.
+ */
+ protected ITmfTimestamp startTime;
+ /**
+ * The end time stamp;
+ */
+ protected ITmfTimestamp endTime;
+ /**
+ * Flag to indicate whether time information is available or not.
+ */
protected boolean hasTime;
- /**
- * Set the lifeline on which the execution occurrence appears.
- *
- * @param theLifeline - the parent lifeline
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
*/
@Override
public void setLifeline(Lifeline theLifeline) {
@@ -52,11 +81,11 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
}
/**
- * Set the red, green and blue value of the optional color to be used for filling the execution occurrence
+ * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
*
- * @param _r
- * @param _g
- * @param _b
+ * @param _r A value for red.
+ * @param _g A green value for green.
+ * @param _b A value blue.
*/
public void setFillColor(int _r, int _g, int _b) {
fillRGB = new int[3];
@@ -68,9 +97,9 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
/**
* Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
*
- * @param _r
- * @param _g
- * @param _b
+ * @param _r A value for red.
+ * @param _g A green value for green.
+ * @param _b A value blue.
*/
public void setStrokeColor(int _r, int _g, int _b) {
strokeRGB = new int[3];
@@ -79,16 +108,26 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
strokeRGB[2] = _b;
}
+ /**
+ * Set the corresponding image.
+ *
+ * @param image_ A image to set.
+ */
public void setImage(IImage image_) {
image = image_;
}
+ /**
+ * Set the top ellipses image.
+ *
+ * @param image_ A image to set.
+ */
public void setTopEllipsesImage(IImage image_) {
ellipsesImage = image_;
}
/**
- * Set the time when the execution occurrence starts.
+ * Set the time when the execution occurrence starts.
*
* @param time the time when the execution occurrence starts
*/
@@ -101,7 +140,7 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
}
/**
- * Set the time when the execution occurrence ends.
+ * Set the time when the execution occurrence ends.
*
* @param time the time when the execution occurrence ends
*/
@@ -113,31 +152,37 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
}
}
- /**
- * Returns the time when the execution occurrence starts
- *
- * @return the time
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getStartTime()
*/
@Override
public ITmfTimestamp getStartTime() {
return startTime;
}
- /**
- * Returns the time when the execution occurrence ends
- *
- * @return the time
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getEndTime()
*/
@Override
public ITmfTimestamp getEndTime() {
return endTime;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo()
+ */
@Override
public boolean hasTimeInfo() {
return hasTime;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
super.draw(context);
@@ -153,11 +198,9 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
}
}
- /**
- * Extension in order to support customized fill colors
- *
- * @param context
- * @return IColor
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedFillColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
*/
@Override
protected IColor setUnselectedFillColor(IGC context) {
@@ -167,19 +210,18 @@ public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITi
context.setGradientColor(tempFillColor);
context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_EXEC));
context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_FRAME));
- } else
+ } else {
context.setBackground(tempFillColor);
+ }
return tempFillColor;
} else {
return super.setUnselectedFillColor(context);
}
}
- /**
- * Extension in order to support customized stroke colors
- *
- * @param context
- * @return IColor
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedStrokeColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
*/
@Override
protected IColor setUnselectedStrokeColor(IGC context) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java
index 2ecc7f0d02..950634036b 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Frame.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: Frame.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -38,15 +39,38 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.TimeEventComparator;
*/
public class Frame extends BasicFrame {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The lifeline that is current highlighted.
+ */
protected Lifeline highlightLifeline = null;
+ /**
+ * The value of the start event.
+ */
protected int startEvent = 0;
+ /**
+ * The nubmer of events in the frame.
+ */
protected int nbEvent = 0;
+ /**
+ * The color for highlighting.
+ */
protected IColor highlightColor = null;
-
+ /**
+ * The list of time events of the corresponding execution occurrences.
+ */
protected List executionOccurrencesWithTime;
-
+ /**
+ * The Array of lifeline categories.
+ */
protected LifelineCategories[] lifelineCategories = null;
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
* Returns a list of all lifelines known by this frame. Known lifelines are the only one which can be displayed on
* screen.
@@ -54,10 +78,10 @@ public class Frame extends BasicFrame {
* @return the lifelines list
*/
protected List getLifelines() {
- if (!hasChilden)
+ if (!hasChilden) {
return null;
- else
- return (List) nodes.get(Lifeline.LIFELINE_TAG);
+ }
+ return (List) nodes.get(Lifeline.LIFELINE_TAG);
}
/**
@@ -67,21 +91,22 @@ public class Frame extends BasicFrame {
*/
public int lifeLinesCount() {
List lifelines = getLifelines();
- if (lifelines != null)
+ if (lifelines != null) {
return lifelines.size();
- else
- return 0;
+ }
+ return 0;
}
/**
* Returns the lifeline at the given index in the lifelines array
*
* @param index the position in the lifeline array
- * @return the lifeline
+ * @return the lifeline or null
*/
public Lifeline getLifeline(int index) {
- if ((getLifelines() != null) && (index >= 0) && (index < lifeLinesCount()))
+ if ((getLifelines() != null) && (index >= 0) && (index < lifeLinesCount())) {
return (Lifeline) getLifelines().get(index);
+ }
return null;
}
@@ -92,10 +117,10 @@ public class Frame extends BasicFrame {
* @return the syncMessages list
*/
protected List getSyncMessages() {
- if (!hasChilden)
+ if (!hasChilden) {
return null;
- else
- return (List) nodes.get(SyncMessage.SYNC_MESS_TAG);
+ }
+ return (List) nodes.get(SyncMessage.SYNC_MESS_TAG);
}
/**
@@ -104,21 +129,22 @@ public class Frame extends BasicFrame {
* @return the number of syncMessage
*/
public int syncMessageCount() {
- if (getSyncMessages() != null)
+ if (getSyncMessages() != null) {
return getSyncMessages().size();
- else
- return 0;
+ }
+ return 0;
}
/**
* Returns the syncMessage at the given index in the syncMessages array
*
* @param index the position in the syncMessages array
- * @return the syncMessage
+ * @return the syncMessage or null
*/
public SyncMessage getSyncMessage(int index) {
- if ((getSyncMessages() != null) && (index >= 0) && (index < getSyncMessages().size()))
+ if ((getSyncMessages() != null) && (index >= 0) && (index < getSyncMessages().size())) {
return (SyncMessage) getSyncMessages().get(index);
+ }
return null;
}
@@ -126,13 +152,13 @@ public class Frame extends BasicFrame {
* Returns a list of asyncMessages known by this frame. Known asyncMessages are the only on which can be displayed
* on screen
*
- * @return the asyncMessages list
+ * @return the asyncMessages list or null
*/
protected List getAsyncMessages() {
- if (!hasChilden)
+ if (!hasChilden) {
return null;
- else
- return (List) nodes.get(AsyncMessage.ASYNC_MESS_TAG);
+ }
+ return (List) nodes.get(AsyncMessage.ASYNC_MESS_TAG);
}
/**
@@ -141,21 +167,22 @@ public class Frame extends BasicFrame {
* @return the number of asyncMessage
*/
public int asyncMessageCount() {
- if (getAsyncMessages() != null)
+ if (getAsyncMessages() != null) {
return getAsyncMessages().size();
- else
- return 0;
+ }
+ return 0;
}
/**
* Returns the asyncMessage at the given index in the asyncMessage array
*
* @param index the position in the asyncMessage array
- * @return the asyncMessage
+ * @return the asyncMessage or null
*/
public AsyncMessage getAsyncMessage(int index) {
- if ((getAsyncMessages() != null) && (index >= 0) && (index < getAsyncMessages().size()))
+ if ((getAsyncMessages() != null) && (index >= 0) && (index < getAsyncMessages().size())) {
return (AsyncMessage) getAsyncMessages().get(index);
+ }
return null;
}
@@ -163,13 +190,13 @@ public class Frame extends BasicFrame {
* Returns a list of syncMessages return known by this frame. Known syncMessages return are the only on which can be
* displayed on screen
*
- * @return the syncMessages return list
+ * @return the syncMessages return list or null
*/
protected List getSyncMessagesReturn() {
- if (!hasChilden)
+ if (!hasChilden) {
return null;
- else
- return (List) nodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG);
+ }
+ return (List) nodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG);
}
/**
@@ -178,21 +205,22 @@ public class Frame extends BasicFrame {
* @return the number of syncMessageReturn
*/
public int syncMessageReturnCount() {
- if (getSyncMessagesReturn() != null)
+ if (getSyncMessagesReturn() != null) {
return getSyncMessagesReturn().size();
- else
- return 0;
+ }
+ return 0;
}
/**
* Returns the syncMessageReturn at the given index in the syncMessageReturn array
*
* @param index the position in the syncMessageReturn array
- * @return the syncMessageReturn
+ * @return the syncMessageReturn or null
*/
public SyncMessageReturn getSyncMessageReturn(int index) {
- if ((getSyncMessagesReturn() != null) && (index >= 0) && (index < getSyncMessagesReturn().size()))
+ if ((getSyncMessagesReturn() != null) && (index >= 0) && (index < getSyncMessagesReturn().size())) {
return (SyncMessageReturn) getSyncMessagesReturn().get(index);
+ }
return null;
}
@@ -200,13 +228,13 @@ public class Frame extends BasicFrame {
* Returns a list of asyncMessageRetun known by this frame. Known asyncMessageRetun are the only on which can be
* displayed on screen
*
- * @return the asyncMessageRetun list
+ * @return the asyncMessageRetun list or null
*/
protected List getAsyncMessagesReturn() {
- if (!hasChilden)
+ if (!hasChilden) {
return null;
- else
- return (List) nodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG);
+ }
+ return (List) nodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG);
}
/**
@@ -215,21 +243,22 @@ public class Frame extends BasicFrame {
* @return the number of asyncMessageReturn
*/
public int asyncMessageReturnCount() {
- if (getAsyncMessagesReturn() != null)
+ if (getAsyncMessagesReturn() != null) {
return getAsyncMessagesReturn().size();
- else
- return 0;
+ }
+ return 0;
}
/**
* Returns the asyncMessageReturn at the given index in the asyncMessageReturn array
*
* @param index the position in the asyncMessageReturn array
- * @return the asyncMessageReturn
+ * @return the asyncMessageReturn or null
*/
public AsyncMessageReturn getAsyncMessageReturn(int index) {
- if ((getAsyncMessagesReturn() != null) && (index >= 0) && (index < getAsyncMessagesReturn().size()))
+ if ((getAsyncMessagesReturn() != null) && (index >= 0) && (index < getAsyncMessagesReturn().size())) {
return (AsyncMessageReturn) getAsyncMessagesReturn().get(index);
+ }
return null;
}
@@ -241,8 +270,9 @@ public class Frame extends BasicFrame {
*/
public void addLifeLine(Lifeline lifeline) {
computeMinMax = true;
- if (lifeline == null)
+ if (lifeline == null) {
return;
+ }
// set the lifeline parent frame
lifeline.setFrame(this);
// Increate the frame lifeline counter
@@ -261,12 +291,12 @@ public class Frame extends BasicFrame {
* @return the first visible lifeline index
*/
public int getFirstVisibleLifeline() {
- if (!hasChilden)
+ if (!hasChilden) {
return 0;
- else if (indexes.get(Lifeline.LIFELINE_TAG) != null)
+ } else if (indexes.get(Lifeline.LIFELINE_TAG) != null) {
return ((Integer) indexes.get(Lifeline.LIFELINE_TAG)).intValue();
- else
- return 0;
+ }
+ return 0;
}
/**
@@ -275,12 +305,12 @@ public class Frame extends BasicFrame {
* @return the first visible synchronous message index
*/
public int getFirstVisibleSyncMessage() {
- if (!hasChilden)
+ if (!hasChilden) {
return 0;
- else if (indexes.get(SyncMessage.SYNC_MESS_TAG) != null)
+ } else if (indexes.get(SyncMessage.SYNC_MESS_TAG) != null) {
return ((Integer) indexes.get(SyncMessage.SYNC_MESS_TAG)).intValue();
- else
- return 0;
+ }
+ return 0;
}
/**
@@ -289,12 +319,12 @@ public class Frame extends BasicFrame {
* @return the first visible synchronous message return index
*/
public int getFirstVisibleSyncMessageReturn() {
- if (!hasChilden)
+ if (!hasChilden) {
return 0;
- else if (indexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG) != null)
+ } else if (indexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG) != null) {
return ((Integer) indexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG)).intValue();
- else
- return 0;
+ }
+ return 0;
}
/**
@@ -303,12 +333,12 @@ public class Frame extends BasicFrame {
* @return the first visible synchronous message index
*/
public int getFirstVisibleAsyncMessage() {
- if (!hasChilden)
+ if (!hasChilden) {
return 0;
- else if (indexes.get(AsyncMessage.ASYNC_MESS_TAG) != null)
+ } else if (indexes.get(AsyncMessage.ASYNC_MESS_TAG) != null) {
return ((Integer) indexes.get(AsyncMessage.ASYNC_MESS_TAG)).intValue();
- else
- return 0;
+ }
+ return 0;
}
/**
@@ -317,37 +347,54 @@ public class Frame extends BasicFrame {
* @return the first visible synchronous message return index
*/
public int getFirstVisibleAsyncMessageReturn() {
- if (!hasChilden)
+ if (!hasChilden) {
return 0;
- else if (indexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG) != null)
+ } else if (indexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG) != null) {
return ((Integer) indexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG)).intValue();
- else
- return 0;
+ }
+ return 0;
}
+ /**
+ * Returns the list of execution occurrences.
+ *
+ * @return the list of execution occurrences
+ */
public List getExecutionOccurrencesWithTime() {
return executionOccurrencesWithTime;
}
+ /**
+ * Inserts a lifeline after a given lifeline.
+ *
+ * @param toInsert A lifeline to insert
+ * @param after A lifelife the toInsert-lifeline will be inserted after.
+ */
public void insertLifelineAfter(Lifeline toInsert, Lifeline after) {
- if ((toInsert == null))
+ if ((toInsert == null)) {
return;
- if (toInsert == after)
+ }
+ if (toInsert == after) {
return;
+ }
int insertPoint = 0;
- if (after != null)
+ if (after != null) {
insertPoint = after.getIndex();
+ }
int removePoint = toInsert.getIndex() - 1;
- if (removePoint >= insertPoint)
+ if (removePoint >= insertPoint) {
getLifelines().remove(removePoint);
+ }
getLifelines().add(insertPoint, toInsert);
- if (removePoint < insertPoint)
+ if (removePoint < insertPoint) {
getLifelines().remove(removePoint);
+ }
- if (removePoint >= insertPoint)
+ if (removePoint >= insertPoint) {
toInsert.setIndex(insertPoint + 1);
- else
+ } else {
toInsert.setIndex(insertPoint - 1);
+ }
insertPoint++;
if (removePoint >= insertPoint) {
@@ -361,25 +408,37 @@ public class Frame extends BasicFrame {
}
}
+ /**
+ * Inserts a lifeline before a given lifeline.
+ *
+ * @param toInsert A lifeline to insert
+ * @param after A lifelife the toInsert-lifeline will be inserted before.
+ */
public void insertLifelineBefore(Lifeline toInsert, Lifeline before) {
- if ((toInsert == null))
+ if ((toInsert == null)) {
return;
- if (toInsert == before)
+ }
+ if (toInsert == before) {
return;
+ }
int insertPoint = 0;
- if (before != null)
+ if (before != null) {
insertPoint = before.getIndex() - 1;
+ }
int removePoint = toInsert.getIndex() - 1;
- if (removePoint >= insertPoint)
+ if (removePoint >= insertPoint) {
getLifelines().remove(removePoint);
+ }
getLifelines().add(insertPoint, toInsert);
- if (removePoint < insertPoint)
+ if (removePoint < insertPoint) {
getLifelines().remove(removePoint);
+ }
- if (removePoint >= insertPoint)
+ if (removePoint >= insertPoint) {
toInsert.setIndex(insertPoint + 1);
- else
+ } else {
toInsert.setIndex(insertPoint - 1);
+ }
insertPoint++;
if (removePoint >= insertPoint) {
@@ -393,12 +452,20 @@ public class Frame extends BasicFrame {
}
}
+ /**
+ * Gets the closer life line to the given x-coordinate.
+ *
+ * @param x A x coordinate
+ * @return the closer lifeline
+ */
public Lifeline getCloserLifeline(int x) {
int index = (x - Metrics.FRAME_H_MARGIN + Metrics.LIFELINE_H_MAGIN) / Metrics.swimmingLaneWidth() - 1;
- if (index < 0)
+ if (index < 0) {
index = 0;
- if (index >= getLifelines().size())
+ }
+ if (index >= getLifelines().size()) {
index = getLifelines().size() - 1;
+ }
Lifeline node1, node2, node3;
int dist1, dist2, dist3;
node1 = node2 = node3 = getLifeline(index);
@@ -411,14 +478,19 @@ public class Frame extends BasicFrame {
node3 = getLifeline(index + 1);
dist3 = Math.abs(node3.getX() + node3.getWidth() / 2 - x);
}
- if (dist1 <= dist2 && dist1 <= dist3)
+ if (dist1 <= dist2 && dist1 <= dist3) {
return node1;
- else if (dist2 <= dist1 && dist2 <= dist3)
+ } else if (dist2 <= dist1 && dist2 <= dist3) {
return node2;
- else
- return node3;
+ }
+ return node3;
}
+ /**
+ * Re-orders the given list of lifelines.
+ *
+ * @param list A list of lifelines to reorder.
+ */
public void reorder(ArrayList> list) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof Lifeline[]) {
@@ -426,13 +498,17 @@ public class Frame extends BasicFrame {
if (temp.length == 2) {
if (temp[1] == null) {
insertLifelineAfter(temp[0], getLifeline(lifeLinesCount() - 1));
- } else
+ } else {
insertLifelineBefore(temp[0], temp[1]);
+ }
}
}
}
}
+ /**
+ * Resets the time compression information.
+ */
public void resetTimeCompression() {
highlightLifeline = null;
this.startEvent = 0;
@@ -440,11 +516,16 @@ public class Frame extends BasicFrame {
highlightColor = null;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicFrame#computeMinMax()
+ */
@Override
protected void computeMinMax() {
List timeArray = buildTimeArray();
- if (timeArray == null)
+ if (timeArray == null) {
return;
+ }
for (int i = 0; i < timeArray.size() - 1; i++) {
SDTimeEvent m1 = (SDTimeEvent) timeArray.get(i);
SDTimeEvent m2 = (SDTimeEvent) timeArray.get(i + 1);
@@ -452,8 +533,9 @@ public class Frame extends BasicFrame {
if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
- if ((mes2.startLifeline == null) || (mes1.endLifeline == null))
+ if ((mes2.startLifeline == null) || (mes1.endLifeline == null)) {
continue;
+ }
}
updateMinMax(m1, m2);
@@ -490,22 +572,31 @@ public class Frame extends BasicFrame {
return false;
}
+ /**
+ * Set whether time information is available or not
+ *
+ * @param value true
for has time information else false
+ */
protected void setHasTimeInfo(boolean value) {
timeInfo = value;
}
/**
- * @return true if frame has time info else false
+ * Returns whether frame has time info or not.
+ *
+ * @return true
whether frame has time info else false
*/
public boolean hasTimeInfo() {
return timeInfo;
}
/**
- * @param lifeline
- * @param startEvent
- * @param nbEvent
- * @param color
+ * Highlights the time compression.
+ *
+ * @param lifeline A lifeline to highlight
+ * @param startEvent A start event number
+ * @param nbEvent A number of events
+ * @param color A color for highlighting
*/
public void highlightTimeCompression(Lifeline lifeline, int startEvent, int nbEvent, IColor color) {
highlightLifeline = lifeline;
@@ -548,11 +639,16 @@ public class Frame extends BasicFrame {
addNode(message);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicFrame#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
drawFrame(context);
- if (!hasChilden)
+ if (!hasChilden) {
return;
+ }
if (highlightLifeline != null) {
IColor backupColor = context.getBackground();
@@ -563,26 +659,29 @@ public class Frame extends BasicFrame {
}
super.draw(context, false);
int lifelineArryStep = 1;
- if (Metrics.swimmingLaneWidth() * context.getZoom() < Metrics.LIFELINE_SIGNIFICANT_HSPACING)
+ if (Metrics.swimmingLaneWidth() * context.getZoom() < Metrics.LIFELINE_SIGNIFICANT_HSPACING) {
lifelineArryStep = Math.round(Metrics.LIFELINE_SIGNIFICANT_HSPACING / (Metrics.swimmingLaneWidth() * context.getZoom()));
- if (indexes.size() == 0)
+ }
+ if (indexes.size() == 0) {
return;
+ }
int lifeLineDrawIndex = ((Integer) indexes.get(Lifeline.LIFELINE_TAG)).intValue();
for (int i = lifeLineDrawIndex; i < ((List) nodes.get(Lifeline.LIFELINE_TAG)).size(); i = i + lifelineArryStep) {
Lifeline toDraw = (Lifeline) ((List) nodes.get(Lifeline.LIFELINE_TAG)).get(i);
- if (toDraw.getX() - Metrics.LIFELINE_SPACING / 2 > context.getContentsX() + context.getVisibleWidth())
+ if (toDraw.getX() - Metrics.LIFELINE_SPACING / 2 > context.getContentsX() + context.getVisibleWidth()) {
break;
+ }
toDraw.drawName(context);
if (highlightLifeline != null) {
- if (toDraw == highlightLifeline)
+ if (toDraw == highlightLifeline) {
toDraw.highlightExecOccurrenceRegion(context, startEvent, nbEvent, highlightColor);
- else if ((toDraw.getIndex() < highlightLifeline.getIndex()) || ((toDraw.getIndex() < highlightLifeline.getIndex()))) {
+ } else if ((toDraw.getIndex() < highlightLifeline.getIndex()) || ((toDraw.getIndex() < highlightLifeline.getIndex()))) {
int acIndex = toDraw.getExecOccurrenceDrawIndex();
// acIndex = first visible execution occurrence
// for drawing speed reason with only search on the visible subset
- if (toDraw.getExecutions() != null)
+ if (toDraw.getExecutions() != null) {
for (int index = acIndex; index < toDraw.getExecutions().size(); index++) {
BasicExecutionOccurrence exec = (BasicExecutionOccurrence) toDraw.getExecutions().get(index);
int tempEvent = startEvent;
@@ -594,22 +693,29 @@ public class Frame extends BasicFrame {
}
// if we are outside the visible area we stop right now
// This works because execution occurrences are ordered along the Y axis
- if (exec.getY() > getY())
+ if (exec.getY() > getY()) {
break;
+ }
}
+ }
}
}
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicFrame#buildTimeArray()
+ */
@Override
protected List buildTimeArray() {
- if (!hasChilden)
+ if (!hasChilden) {
return null;
+ }
try {
List timeArray = super.buildTimeArray();
executionOccurrencesWithTime = null;
- if (getLifelines() != null)
+ if (getLifelines() != null) {
for (int i = 0; i < ((List) nodes.get(Lifeline.LIFELINE_TAG)).size(); i++) {
Lifeline l = (Lifeline) ((List) nodes.get(Lifeline.LIFELINE_TAG)).get(i);
if (l.hasTimeInfo() && l.getExecutions() != null) {
@@ -636,6 +742,7 @@ public class Frame extends BasicFrame {
}
}
}
+ }
if (executionOccurrencesWithTime != null) {
SDTimeEvent[] temp = executionOccurrencesWithTime.toArray(new SDTimeEvent[0]);
@@ -653,65 +760,97 @@ public class Frame extends BasicFrame {
}
+ /**
+ * Get the closer leaving message.
+ *
+ * @param lifeline A lifeline reference
+ * @param message A message reference
+ * @param list A list of graph nodes
+ * @param smallerEvent A smaller event flag
+ * @return the closer leaving message.
+ */
protected GraphNode getCloserLeavingMessage(Lifeline lifeline, BaseMessage message, List list, boolean smallerEvent) {
- if (list == null)
+ if (list == null) {
return null;
+ }
+
if (smallerEvent == false) {
int event = 0;
- if (message != null)
+ if (message != null) {
event = message.getEventOccurrence();
+ }
for (int i = 0; i < list.size(); i++) {
GraphNode node = (GraphNode) list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
- if ((syncNode.getEventOccurrence() > event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message))
+ if ((syncNode.getEventOccurrence() > event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message)) {
return node;
+ }
} else if (node instanceof AsyncMessage) {
AsyncMessage asyncNode = (AsyncMessage) node;
- if ((asyncNode.getStartOccurrence() > event) && (asyncNode.getStartLifeline() == lifeline) && !asyncNode.isSameAs(message))
+ if ((asyncNode.getStartOccurrence() > event) && (asyncNode.getStartLifeline() == lifeline) && !asyncNode.isSameAs(message)) {
return node;
+ }
}
}
} else {
int event = getMaxEventOccurrence();
- if (message != null)
+ if (message != null) {
if (message instanceof AsyncMessage) {
event = ((AsyncMessage) message).getStartOccurrence();
- } else
+ } else {
event = message.getEventOccurrence();
+ }
+ }
for (int i = list.size() - 1; i >= 0; i--) {
GraphNode node = (GraphNode) list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
- if ((syncNode.getEventOccurrence() < event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message))
+ if ((syncNode.getEventOccurrence() < event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message)) {
return node;
+ }
} else if (node instanceof AsyncMessage) {
AsyncMessage asyncNode = (AsyncMessage) node;
- if ((asyncNode.getStartOccurrence() < event) && (asyncNode.getStartLifeline() == lifeline) && !asyncNode.isSameAs(message))
+ if ((asyncNode.getStartOccurrence() < event) && (asyncNode.getStartLifeline() == lifeline) && !asyncNode.isSameAs(message)) {
return node;
+ }
}
}
}
return null;
}
+
+ /**
+ * Get the closer entering message.
+ *
+ * @param lifeline A lifeline reference
+ * @param message A message reference
+ * @param list A list of graph nodes
+ * @param smallerEvent A smaller event flag
+ * @return the closer entering message.
+ */
protected GraphNode getCloserEnteringMessage(Lifeline lifeline, BaseMessage message, List list, boolean smallerEvent) {
- if (list == null)
+ if (list == null) {
return null;
+ }
if (smallerEvent == false) {
int event = 0;
- if (message != null)
+ if (message != null) {
event = message.getEventOccurrence();
+ }
for (int i = 0; i < list.size(); i++) {
GraphNode node = (GraphNode) list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
- if ((syncNode.getEventOccurrence() > event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message))
+ if ((syncNode.getEventOccurrence() > event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message)) {
return node;
+ }
} else if (node instanceof AsyncMessage) {
AsyncMessage asyncNode = (AsyncMessage) node;
- if ((asyncNode.getStartOccurrence() > event) && (asyncNode.getEndLifeline() == lifeline) && !asyncNode.isSameAs(message))
+ if ((asyncNode.getStartOccurrence() > event) && (asyncNode.getEndLifeline() == lifeline) && !asyncNode.isSameAs(message)) {
return node;
+ }
}
}
} else {
@@ -719,203 +858,299 @@ public class Frame extends BasicFrame {
if (message != null)
if (message instanceof AsyncMessage) {
event = ((AsyncMessage) message).getStartOccurrence();
- } else
+ } else {
event = message.getEventOccurrence();
+ }
for (int i = list.size() - 1; i >= 0; i--) {
GraphNode node = (GraphNode) list.get(i);
if (node instanceof SyncMessage) {
SyncMessage syncNode = (SyncMessage) node;
- if ((syncNode.getEventOccurrence() < event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message))
+ if ((syncNode.getEventOccurrence() < event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message)) {
return node;
+ }
} else if (node instanceof AsyncMessage) {
AsyncMessage asyncNode = (AsyncMessage) node;
- if ((asyncNode.getStartOccurrence() < event) && (asyncNode.getEndLifeline() == lifeline) && !asyncNode.isSameAs(message))
+ if ((asyncNode.getStartOccurrence() < event) && (asyncNode.getEndLifeline() == lifeline) && !asyncNode.isSameAs(message)) {
return node;
+ }
}
}
}
return null;
}
+ /**
+ * Get distance of given event from given graph node.
+ *
+ * @param node A graph node reference.
+ * @param event A event number to check.
+ * @return distance of event from graph node.
+ */
protected int distanceFromEvent(GraphNode node, int event) {
int distance = 0;
- if (node instanceof SyncMessage)
+ if (node instanceof SyncMessage) {
distance = ((SyncMessage) node).getEventOccurrence() - event;
- else if (node instanceof AsyncMessage) {
+ } else if (node instanceof AsyncMessage) {
int start = ((AsyncMessage) node).getStartOccurrence();
int end = ((AsyncMessage) node).getEndOccurrence();
- if ((start - event) < (end - event))
+ if ((start - event) < (end - event)) {
distance = start - event;
- else
+ } else {
distance = end - event;
+ }
}
return Math.abs(distance);
}
+ /**
+ * Get node from 2 given nodes that is close to event.
+ *
+ * @param node1 A first graph node
+ * @param node2 A second graph node
+ * @param event A event to check.
+ * @return graph node that is closer or null
+ */
protected GraphNode getCloserToEvent(GraphNode node1, GraphNode node2, int event) {
if ((node1 != null) && (node2 != null)) {
- if (distanceFromEvent(node1, event) < distanceFromEvent(node2, event))
+ if (distanceFromEvent(node1, event) < distanceFromEvent(node2, event)) {
return node1;
- else
+ } else {
return node2;
- } else if (node1 != null)
+ }
+ } else if (node1 != null) {
return node1;
- else if (node2 != null)
+ } else if (node2 != null) {
return node2;
- else
- return null;
+ }
+ return null;
}
- public GraphNode getCalledMessage(BaseMessage StartMessage) {
+ /**
+ * Get called message based on given start message.
+ *
+ * @param startMessage A start message to check.
+ * @return called message (graph node) or null
+ */
+ public GraphNode getCalledMessage(BaseMessage startMessage) {
int event = 0;
GraphNode result = null;
Lifeline lifeline = null;
- if (StartMessage != null) {
- event = ((BaseMessage) StartMessage).getEventOccurrence();
- lifeline = ((BaseMessage) StartMessage).getEndLifeline();
- if (lifeline == null)
- lifeline = ((BaseMessage) StartMessage).getStartLifeline();
+ if (startMessage != null) {
+ event = ((BaseMessage) startMessage).getEventOccurrence();
+ lifeline = ((BaseMessage) startMessage).getEndLifeline();
+ if (lifeline == null) {
+ lifeline = ((BaseMessage) startMessage).getStartLifeline();
+ }
}
- if (lifeline == null)
+ if (lifeline == null) {
return null;
- GraphNode message = getCloserLeavingMessage(lifeline, StartMessage, getSyncMessages(), false);
- GraphNode messageReturn = getCloserLeavingMessage(lifeline, StartMessage, getSyncMessagesReturn(), false);
+ }
+ GraphNode message = getCloserLeavingMessage(lifeline, startMessage, getSyncMessages(), false);
+ GraphNode messageReturn = getCloserLeavingMessage(lifeline, startMessage, getSyncMessagesReturn(), false);
result = getCloserToEvent(message, messageReturn, event);
- message = getCloserLeavingMessage(lifeline, StartMessage, getAsyncMessages(), false);
+ message = getCloserLeavingMessage(lifeline, startMessage, getAsyncMessages(), false);
result = getCloserToEvent(result, message, event);
- messageReturn = getCloserLeavingMessage(lifeline, StartMessage, getAsyncMessagesReturn(), false);
+ messageReturn = getCloserLeavingMessage(lifeline, startMessage, getAsyncMessagesReturn(), false);
result = getCloserToEvent(result, messageReturn, event);
return result;
}
- public GraphNode getCallerMessage(BaseMessage StartMessage) {
+ /**
+ * Get caller message based on given start message.
+ *
+ * @param startMessage A start message to check.
+ * @return called message (graph node) or null
+ */
+ public GraphNode getCallerMessage(BaseMessage startMessage) {
int event = getMaxEventOccurrence();
GraphNode result = null;
Lifeline lifeline = null;
- if (StartMessage != null) {
- event = ((BaseMessage) StartMessage).getEventOccurrence();
- lifeline = ((BaseMessage) StartMessage).getStartLifeline();
- if (lifeline == null)
- lifeline = ((BaseMessage) StartMessage).getEndLifeline();
+ if (startMessage != null) {
+ event = ((BaseMessage) startMessage).getEventOccurrence();
+ lifeline = ((BaseMessage) startMessage).getStartLifeline();
+ if (lifeline == null) {
+ lifeline = ((BaseMessage) startMessage).getEndLifeline();
+ }
}
- if (lifeline == null)
+ if (lifeline == null) {
return null;
- GraphNode message = getCloserEnteringMessage(lifeline, StartMessage, getSyncMessages(), true);
- GraphNode messageReturn = getCloserEnteringMessage(lifeline, StartMessage, getSyncMessagesReturn(), true);
+ }
+ GraphNode message = getCloserEnteringMessage(lifeline, startMessage, getSyncMessages(), true);
+ GraphNode messageReturn = getCloserEnteringMessage(lifeline, startMessage, getSyncMessagesReturn(), true);
result = getCloserToEvent(message, messageReturn, event);
- message = getCloserEnteringMessage(lifeline, StartMessage, getAsyncMessages(), true);
+ message = getCloserEnteringMessage(lifeline, startMessage, getAsyncMessages(), true);
result = getCloserToEvent(result, message, event);
- messageReturn = getCloserEnteringMessage(lifeline, StartMessage, getAsyncMessagesReturn(), true);
+ messageReturn = getCloserEnteringMessage(lifeline, startMessage, getAsyncMessagesReturn(), true);
result = getCloserToEvent(result, messageReturn, event);
return result;
}
- public GraphNode getNextLifelineMessage(Lifeline lifeline, BaseMessage StartMessage) {
+ /**
+ * Get next lifeline based on given message.
+ *
+ * @param lifeline A lifeline reference
+ * @param startMessage A start message to check
+ * @return next lifeline or null
+ */
+ public GraphNode getNextLifelineMessage(Lifeline lifeline, BaseMessage startMessage) {
int event = 0;
- if (StartMessage != null)
- event = ((BaseMessage) StartMessage).getEventOccurrence();
- if (lifeline == null)
+ if (startMessage != null) {
+ event = ((BaseMessage) startMessage).getEventOccurrence();
+ }
+ if (lifeline == null) {
return null;
- GraphNode message = getCloserLeavingMessage(lifeline, StartMessage, getSyncMessages(), false);
- GraphNode messageReturn = getCloserLeavingMessage(lifeline, StartMessage, getSyncMessagesReturn(), false);
+ }
+ GraphNode message = getCloserLeavingMessage(lifeline, startMessage, getSyncMessages(), false);
+ GraphNode messageReturn = getCloserLeavingMessage(lifeline, startMessage, getSyncMessagesReturn(), false);
GraphNode result = getCloserToEvent(message, messageReturn, event);
- message = getCloserLeavingMessage(lifeline, StartMessage, getAsyncMessages(), false);
+ message = getCloserLeavingMessage(lifeline, startMessage, getAsyncMessages(), false);
result = getCloserToEvent(result, message, event);
- messageReturn = getCloserLeavingMessage(lifeline, StartMessage, getAsyncMessagesReturn(), false);
+ messageReturn = getCloserLeavingMessage(lifeline, startMessage, getAsyncMessagesReturn(), false);
result = getCloserToEvent(result, messageReturn, event);
return result;
}
+ /**
+ * Get previous lifeline based on given message.
+ *
+ * @param lifeline A lifeline reference
+ * @param startMessage A start message to check.
+ * @return previous lifeline or null
+ */
+ public GraphNode getPrevLifelineMessage(Lifeline lifeline, BaseMessage startMessage) {
+ int event = getMaxEventOccurrence();
+ if (startMessage != null)
+ if (startMessage instanceof AsyncMessage) {
+ event = ((AsyncMessage) startMessage).getStartOccurrence();
+ } else {
+ event = startMessage.getEventOccurrence();
+ }
+ if (lifeline == null) {
+ return null;
+ }
+ GraphNode message = getCloserLeavingMessage(lifeline, startMessage, getSyncMessages(), true);
+ GraphNode messageReturn = getCloserLeavingMessage(lifeline, startMessage, getSyncMessagesReturn(), true);
+ GraphNode result = getCloserToEvent(message, messageReturn, event);
+ message = getCloserLeavingMessage(lifeline, startMessage, getAsyncMessages(), true);
+ result = getCloserToEvent(result, message, event);
+ messageReturn = getCloserLeavingMessage(lifeline, startMessage, getAsyncMessagesReturn(), true);
+ result = getCloserToEvent(result, messageReturn, event);
+ return result;
+ }
+
+ /**
+ * Get the first execution occurrence.
+ *
+ * @param lifeline A lifeline reference
+ * @return the first execution occurrence of lifeline or null
.
+ */
public BasicExecutionOccurrence getFirstExecution(Lifeline lifeline) {
- if (lifeline == null)
+ if (lifeline == null) {
return null;
+ }
List list = lifeline.getExecutions();
- if (list == null)
+ if (list == null) {
return null;
- if (list.size() == 0)
+ }
+ if (list.size() == 0) {
return null;
+ }
BasicExecutionOccurrence result = (BasicExecutionOccurrence) list.get(0);
for (int i = 0; i < list.size(); i++) {
BasicExecutionOccurrence e = (BasicExecutionOccurrence) list.get(i);
- if ((e.getStartOccurrence() < result.getEndOccurrence()))
+ if ((e.getStartOccurrence() < result.getEndOccurrence())) {
result = e;
+ }
}
return result;
}
-
+
+ /**
+ * Get the previous execution occurrence relative to a given execution occurrence.
+ *
+ * @param exec A execution occurrence reference.
+ * @return the previous execution occurrence of lifeline or null
.
+ */
public BasicExecutionOccurrence getPrevExecOccurrence(BasicExecutionOccurrence exec) {
- if (exec == null)
+ if (exec == null) {
return null;
+ }
Lifeline lifeline = exec.getLifeline();
- if (lifeline == null)
+ if (lifeline == null) {
return null;
+ }
List list = lifeline.getExecutions();
- if (list == null)
+ if (list == null) {
return null;
+ }
BasicExecutionOccurrence result = null;
for (int i = 0; i < list.size(); i++) {
BasicExecutionOccurrence e = (BasicExecutionOccurrence) list.get(i);
- if ((e.getStartOccurrence() < exec.startEventOccurrence) && (result == null))
+ if ((e.getStartOccurrence() < exec.startEventOccurrence) && (result == null)) {
result = e;
- if ((e.getStartOccurrence() < exec.startEventOccurrence) && (e.getStartOccurrence() >= result.getEndOccurrence()))
+ }
+ if ((e.getStartOccurrence() < exec.startEventOccurrence) && (e.getStartOccurrence() >= result.getEndOccurrence())) {
result = e;
+ }
}
return result;
}
+ /**
+ * Get the next execution occurrence relative to a given execution occurrence.
+ *
+ * @param exec A execution occurrence reference.
+ * @return the next execution occurrence of lifeline or null
.
+ */
public BasicExecutionOccurrence getNextExecOccurrence(BasicExecutionOccurrence exec) {
- if (exec == null)
+ if (exec == null) {
return null;
+ }
Lifeline lifeline = exec.getLifeline();
- if (lifeline == null)
+ if (lifeline == null) {
return null;
+ }
List list = lifeline.getExecutions();
- if (list == null)
+ if (list == null) {
return null;
+ }
BasicExecutionOccurrence result = null;
for (int i = 0; i < list.size(); i++) {
BasicExecutionOccurrence e = (BasicExecutionOccurrence) list.get(i);
- if ((e.getStartOccurrence() > exec.startEventOccurrence) && (result == null))
+ if ((e.getStartOccurrence() > exec.startEventOccurrence) && (result == null)) {
result = e;
- if ((e.getStartOccurrence() > exec.startEventOccurrence) && (e.getStartOccurrence() <= result.getEndOccurrence()))
+ }
+ if ((e.getStartOccurrence() > exec.startEventOccurrence) && (e.getStartOccurrence() <= result.getEndOccurrence())) {
result = e;
+ }
}
return result;
}
+ /**
+ * Get the last execution occurrence.
+ *
+ * @param lifeline A lifeline reference.
+ * @return the last execution occurrence of lifeline or null
.
+ */
public BasicExecutionOccurrence getLastExecOccurrence(Lifeline lifeline) {
- if (lifeline == null)
+ if (lifeline == null) {
return null;
+ }
List list = lifeline.getExecutions();
- if (list == null)
+ if (list == null) {
return null;
+ }
BasicExecutionOccurrence result = null;
for (int i = 0; i < list.size(); i++) {
BasicExecutionOccurrence e = (BasicExecutionOccurrence) list.get(i);
- if (result == null)
+ if (result == null) {
result = e;
- if (e.getStartOccurrence() > result.getEndOccurrence())
+ }
+ if (e.getStartOccurrence() > result.getEndOccurrence()) {
result = e;
+ }
}
return result;
}
-
- public GraphNode getPrevLifelineMessage(Lifeline lifeline, BaseMessage StartMessage) {
- int event = getMaxEventOccurrence();
- if (StartMessage != null)
- if (StartMessage instanceof AsyncMessage) {
- event = ((AsyncMessage) StartMessage).getStartOccurrence();
- } else
- event = StartMessage.getEventOccurrence();
- if (lifeline == null)
- return null;
- GraphNode message = getCloserLeavingMessage(lifeline, StartMessage, getSyncMessages(), true);
- GraphNode messageReturn = getCloserLeavingMessage(lifeline, StartMessage, getSyncMessagesReturn(), true);
- GraphNode result = getCloserToEvent(message, messageReturn, event);
- message = getCloserLeavingMessage(lifeline, StartMessage, getAsyncMessages(), true);
- result = getCloserToEvent(result, message, event);
- messageReturn = getCloserLeavingMessage(lifeline, StartMessage, getAsyncMessagesReturn(), true);
- result = getCloserToEvent(result, messageReturn, event);
- return result;
- }
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java
index 7a01f93a71..63d50522fd 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/GraphNode.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: GraphNode.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -21,7 +22,7 @@ import java.util.List;
import org.eclipse.linuxtools.internal.tmf.ui.TmfUiTracer;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
* The base class used for all UML2 graph nodes displayed in the Sequence Diagram SDWidget.
@@ -29,50 +30,76 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
* @author sveyrier
* @version 1.0
*/
-
public abstract class GraphNode {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The start event occurrence.
+ */
protected int startEventOccurrence = 0;
-
+ /**
+ * The event event occurrence.
+ */
protected int endEventOccurrence = 0;
-
/**
* Preference ColorId to use to draw font
*/
public String prefId = ISDPreferences.PREF_SYNC_MESS;
-
/**
* The selection state of the graph node.
*/
protected boolean selected = false;
-
/**
* The focus state of the graph node.
*/
protected boolean focused = false;
-
+ /**
+ * Flag to indicate whether node has children or not.
+ */
protected boolean hasChilden = false;
-
/**
* The graph node name used to label the graph node in the View.
*/
protected String name = ""; //$NON-NLS-1$
-
+ /**
+ * A map from node name to graph node.
+ */
protected HashMap> nodes;
+ /**
+ * A map from node name to graph node for forward sorting
+ */
protected HashMap> fnodes;
+ /**
+ * A map from node name to graph node for backwards sorting.
+ */
protected HashMap> bnodes;
-
+ /**
+ * A map from node name to index.
+ */
protected HashMap indexes;
+ /**
+ * A map from node name to index for forwards sorting.
+ */
protected HashMap fSort;
+ /**
+ * A map from node name to indexfor forwards sorting.
+ */
protected HashMap bSort;
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
* Reset the internal index of the first visible GraphNode for each ordered GraphNode lists
- *
*/
public void resetIndex() {
- if (!hasChilden)
+ if (!hasChilden) {
return;
+ }
+
Iterator it = indexes.keySet().iterator();
while (it.hasNext()) {
String nodeType = it.next();
@@ -97,8 +124,9 @@ public abstract class GraphNode {
}
// Nothing to add
- if (nodeToAdd == null)
+ if (nodeToAdd == null) {
return;
+ }
if (nodes.get(nodeToAdd.getArrayId()) == null) {
nodes.put(nodeToAdd.getArrayId(), new ArrayList(1));
@@ -113,8 +141,9 @@ public abstract class GraphNode {
List fNodeList = (List) fnodes.get(nodeToAdd.getArrayId());
List bNodeList = null;
- if (bnodes != null)
+ if (bnodes != null) {
bNodeList = (List) bnodes.get(nodeToAdd.getArrayId());
+ }
if (fNodeList != null && fNodeList.size() > 0) {
// check if the nodes are added y ordered
// if not, tag the list to sort it later (during draw)
@@ -195,7 +224,6 @@ public abstract class GraphNode {
* The returned value is used to highlight the graph node in the View.
*
* @return true if selected, false otherwise
- *
*/
public boolean isSelected() {
return selected;
@@ -206,7 +234,6 @@ public abstract class GraphNode {
* The returned value is used to highlight the graph node in the View.
*
* @return true if focued, false otherwise
- *
*/
public boolean hasFocus() {
return focused;
@@ -329,8 +356,9 @@ public abstract class GraphNode {
public GraphNode getNodeAt(int x, int y) {
GraphNode toReturn = null;
- if (!hasChilden)
+ if (!hasChilden) {
return null;
+ }
Iterator it = nodes.keySet().iterator();
GraphNode node = null;
@@ -339,20 +367,28 @@ public abstract class GraphNode {
List list = (List) nodes.get(nodeType);
int index = ((Integer) indexes.get(nodeType)).intValue();
node = getNodeFromListAt(x, y, list, index);
- if (toReturn == null)
+ if (toReturn == null) {
toReturn = node;
+ }
if (node != null) {
GraphNode internalNode = node.getNodeAt(x, y);
- if (internalNode != null)
+ if (internalNode != null) {
return internalNode;
- // else return node;
- else if (Math.abs(node.getWidth()) < Math.abs(toReturn.getWidth()) || Math.abs(node.getHeight()) < Math.abs(toReturn.getHeight()))
+ } else if (Math.abs(node.getWidth()) < Math.abs(toReturn.getWidth()) || Math.abs(node.getHeight()) < Math.abs(toReturn.getHeight())) {
toReturn = node;
+ }
}
}
return toReturn;
}
+ /**
+ * Gets node list from node A to node B
+
+ * @param from A from node
+ * @param to A to node
+ * @return the list of nodes
+ */
public ArrayList getNodeList(GraphNode from, GraphNode to) {
ArrayList result = new ArrayList();
@@ -362,39 +398,45 @@ public abstract class GraphNode {
result.add(to);
}
- if (from == null || to == null)
+ if (from == null || to == null) {
return result;
+ }
- if (from == to)
+ if (from == to) {
return result;
+ }
int startX = Math.min(from.getX(), Math.min(to.getX(), Math.min(from.getX() + from.getWidth(), to.getX() + to.getWidth())));
int endX = Math.max(from.getX(), Math.max(to.getX(), Math.max(from.getX() + from.getWidth(), to.getX() + to.getWidth())));
int startY = Math.min(from.getY(), Math.min(to.getY(), Math.min(from.getY() + from.getHeight(), to.getY() + to.getHeight())));
int endY = Math.max(from.getY(), Math.max(to.getY(), Math.max(from.getY() + from.getHeight(), to.getY() + to.getHeight())));
- if (!hasChilden)
+ if (!hasChilden) {
return result;
+ }
Iterator it = nodes.keySet().iterator();
while (it.hasNext()) {
Object nodeType = it.next();
List nodesList = (List) nodes.get(nodeType);
- if (nodesList == null || nodesList.isEmpty())
+ if (nodesList == null || nodesList.isEmpty()) {
return null;
+ }
for (int i = 0; i < nodesList.size(); i++) {
GraphNode node = (GraphNode) nodesList.get(i);
int nw = node.getWidth();
int nh = node.getHeight();
int nx = node.getX();
int ny = node.getY();
- if (contains(startX, startY, endX - startX, endY - startY, nx + 1, ny + 1) && contains(startX, startY, endX - startX, endY - startY, nx + nw - 2, ny + nh - 2))
+ if (contains(startX, startY, endX - startX, endY - startY, nx + 1, ny + 1) && contains(startX, startY, endX - startX, endY - startY, nx + nw - 2, ny + nh - 2)) {
result.add(node);
+ }
result.addAll(node.getNodeList(from, to));
}
}
- if ((to != null) && (!result.contains(to)))
+ if ((to != null) && (!result.contains(to))) {
result.add(to);
+ }
return result;
}
@@ -410,12 +452,14 @@ public abstract class GraphNode {
* @return the graph node containing the point given in parameter, null otherwise
*/
protected GraphNode getNodeFromListAt(int x, int y, List list, int fromIndex) {
- if (list == null)
+ if (list == null) {
return null;
+ }
for (int i = fromIndex; i < list.size(); i++) {
GraphNode node = (GraphNode) list.get(i);
- if (node.contains(x, y))
+ if (node.contains(x, y)) {
return node;
+ }
}
return null;
}
@@ -448,8 +492,9 @@ public abstract class GraphNode {
* @param height visible area height
*/
public void updateIndex(int x, int y, int width, int height) {
- if (!hasChilden)
+ if (!hasChilden) {
return;
+ }
if(TmfUiTracer.isIndexTraced()) {
TmfUiTracer.traceIndex("*****************************\n"); //$NON-NLS-1$
TmfUiTracer.traceIndex("Visible area position in virtual screen (x,y)= " + x + " " + y + "\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -464,11 +509,13 @@ public abstract class GraphNode {
* if (x==0) { drawIndex = 0; indexes.put(nodeType,new Integer(drawIndex)); }
*/
if ((nodes.get(nodeType) != null) && (((List) nodes.get(nodeType)).size() > 1)) {
- if (((GraphNode) ((List) nodes.get(nodeType)).get(drawIndex)).positiveDistanceToPoint(x, y))
+ if (((GraphNode) ((List) nodes.get(nodeType)).get(drawIndex)).positiveDistanceToPoint(x, y)) {
direction = -1;
+ }
- if (drawIndex == 0)
+ if (drawIndex == 0) {
direction = 1;
+ }
if ((direction == -1) && (bnodes.get(nodeType) != null)) {
GraphNode currentNode = (GraphNode) ((List) nodes.get(nodeType)).get(drawIndex);
@@ -477,8 +524,9 @@ public abstract class GraphNode {
if (drawIndex < 0) {
drawIndex = 0;
direction = 1;
- } else
+ } else {
nodes.put(nodeType, (List) bnodes.get(nodeType));
+ }
}
GraphNode prev = null;
@@ -488,8 +536,9 @@ public abstract class GraphNode {
GraphNode currentNode = (GraphNode) ((List) nodes.get(nodeType)).get(i);
- if (prev == null)
+ if (prev == null) {
prev = currentNode;
+ }
Comparator comp = currentNode.getComparator();
HashMap sort = fSort;
@@ -504,23 +553,28 @@ public abstract class GraphNode {
if (i < ((List) nodes.get(nodeType)).size() - 1) {
GraphNode next = (GraphNode) ((List) nodes.get(nodeType)).get(i + 1);
- if ((comp != null) && (comp.compare(currentNode, next) > 0))
+ if ((comp != null) && (comp.compare(currentNode, next) > 0)) {
sort.put(nodeType, Boolean.valueOf(true));
+ }
}
if (direction == 1) {
- if (((GraphNode) ((List) nodes.get(nodeType)).get(i)).positiveDistanceToPoint(x, y))
+ if (((GraphNode) ((List) nodes.get(nodeType)).get(i)).positiveDistanceToPoint(x, y)) {
break;
+ }
} else {
if (currentNode.getBackComparator() == null) {
if // (currentNode.isVisible(x,y,width,height)
- (!currentNode.positiveDistanceToPoint(x, y))
+ (!currentNode.positiveDistanceToPoint(x, y)) {
break;
+ }
} else {
if (currentNode.isVisible(x, y, width, height) && !currentNode.positiveDistanceToPoint(x, y)) {
- if ((comp != null) && (comp.compare(currentNode, prev) <= 0))
+ if ((comp != null) && (comp.compare(currentNode, prev) <= 0)) {
break;
- } else if ((comp != null) && (comp.compare(currentNode, prev) <= 0))
+ }
+ } else if ((comp != null) && (comp.compare(currentNode, prev) <= 0)) {
prev = currentNode;
+ }
}
}
}
@@ -534,8 +588,9 @@ public abstract class GraphNode {
GraphNode currentNode = (GraphNode) (backList.get(index));
if (index > 0) {
index = Arrays.binarySearch(list.toArray(new GraphNode[0]), backList.get(index), currentNode.getComparator());
- if (index < 0)
+ if (index < 0) {
index = 0;
+ }
indexes.put(nodeType, Integer.valueOf(index));
}
}
@@ -543,8 +598,9 @@ public abstract class GraphNode {
for (int i = drawIndex; i < ((List) nodes.get(nodeType)).size() && i >= 0; i++) {
GraphNode toDraw = (GraphNode) ((List) nodes.get(nodeType)).get(i);
toDraw.updateIndex(x, y, width, height);
- if (!toDraw.isVisible(x, y, width, height))
+ if (!toDraw.isVisible(x, y, width, height)) {
break;
+ }
}
}
if (TmfUiTracer.isIndexTraced()) {
@@ -568,8 +624,9 @@ public abstract class GraphNode {
*/
protected void drawChildenNodes(IGC context) {
- if (!hasChilden)
+ if (!hasChilden) {
return;
+ }
// If the nodes have not been added ordered, the array is ordered
Iterator it = fSort.keySet().iterator();
while (it.hasNext()) {
@@ -582,8 +639,9 @@ public abstract class GraphNode {
fSort.put(nodeType, Boolean.valueOf(false));
nodes.put(nodeType, Arrays.asList(temp));
fnodes.put(nodeType, Arrays.asList(temp));
- if (TmfUiTracer.isSortingTraced())
+ if (TmfUiTracer.isSortingTraced()) {
TmfUiTracer.traceSorting(nodeType + " array sorted\n"); //$NON-NLS-1$
+ }
}
}
@@ -597,8 +655,9 @@ public abstract class GraphNode {
Arrays.sort(temp, node.getBackComparator());
bSort.put(nodeType, Boolean.valueOf(false));
bnodes.put(nodeType, Arrays.asList(temp));
- if (TmfUiTracer.isSortingTraced())
+ if (TmfUiTracer.isSortingTraced()) {
TmfUiTracer.traceSorting(nodeType + " back array sorted\n"); //$NON-NLS-1$
+ }
}
}
@@ -607,8 +666,9 @@ public abstract class GraphNode {
}
int arrayStep = 1;
- if ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * context.getZoom() < Metrics.MESSAGE_SIGNIFICANT_VSPACING)
+ if ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * context.getZoom() < Metrics.MESSAGE_SIGNIFICANT_VSPACING) {
arrayStep = Math.round(Metrics.MESSAGE_SIGNIFICANT_VSPACING / ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * context.getZoom()));
+ }
int count = 0;
Iterator it3 = fSort.keySet().iterator();
@@ -619,8 +679,9 @@ public abstract class GraphNode {
context.setFont(Frame.getUserPref().getFont(node.prefId));
int index = ((Integer) indexes.get(nodeType)).intValue();
count = drawNodes(context, (List) nodes.get(nodeType), index, arrayStep);
- if (TmfUiTracer.isDisplayTraced())
+ if (TmfUiTracer.isDisplayTraced()) {
TmfUiTracer.traceDisplay(count + " " + nodeType + " drawn, starting from index " + index + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
}
if (TmfUiTracer.isDisplayTraced()) {
TmfUiTracer.traceDisplay("*****************************\n"); //$NON-NLS-1$
@@ -638,13 +699,15 @@ public abstract class GraphNode {
* @return the number of GraphNodes drawn
*/
protected int drawNodes(IGC context, List list, int startIndex, int step) {
- if (!hasChilden)
+ if (!hasChilden) {
return 0;
+ }
GraphNode last = null;
int nodesCount = 0;
- if (list.size() < 0)
+ if (list.size() < 0) {
return 0;
+ }
GraphNode node = (GraphNode) list.get(0);
context.setFont(Frame.getUserPref().getFont(node.prefId));
@@ -662,21 +725,27 @@ public abstract class GraphNode {
int cw = context.getVisibleWidth();
int ch = context.getVisibleHeight();
// The arrays should be ordered, no needs to continue for this one
- if (!toDraw.isVisible(cx, cy, cw, ch) && toDraw.positiveDistanceToPoint(cx + cw, cy + ch))
+ if (!toDraw.isVisible(cx, cy, cw, ch) && toDraw.positiveDistanceToPoint(cx + cw, cy + ch)) {
break;
+ }
// ***Common*** nodes visibility
if ((!toDraw.isSameAs(last) || toDraw.isSelected()) && (toDraw.isVisible(context.getContentsX(), context.getContentsY(), context.getVisibleWidth(), context.getVisibleHeight()))) {
nodesCount++;
toDraw.draw(context);
- if (hasFocus())
+ if (hasFocus()) {
toDraw.drawFocus(context);
+ }
}
last = toDraw;
}
return nodesCount;
}
+ /**
+ * Draws the focus within the graphical context.
+ * @param context
+ */
public void drawFocus(IGC context) {
context.drawFocus(getX(), getY(), getWidth(), getHeight());
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java
index 50c1089c2b..b6c6ac1f8b 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/HotSpot.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: HotSpot.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -14,61 +15,109 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
+ * Class to add a hot spot marker.
+ *
+ * @version 1.0
* @author sveyrier
*/
public class HotSpot extends GraphNode {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The grahNode ID constant
+ */
+ public static final String GLYPH = "Glyph"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The execution occurrence the hot spot marker is for.
+ */
protected BasicExecutionOccurrence execOcc = null;
+ /**
+ * The occurrence number.
+ */
protected int occurrence = 0;
+ /**
+ * The marker image to display.
+ */
protected IImage image = null;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
- * The grahNode ID constant
+ * Default constructor
*/
- public static final String GLYPH = "Glyph"; //$NON-NLS-1$
-
public HotSpot() {
prefId = ISDPreferences.PREF_EXEC;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Set the marker image.
+ *
+ * @param img A image to set
+ */
public void setImage(IImage img) {
image = img;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
+ */
@Override
public int getX() {
- if (execOcc != null)
+ if (execOcc != null) {
return execOcc.getX() - 3;
- else
- return 0;
-
+ }
+ return 0;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
+ */
@Override
public int getY() {
- if (execOcc != null)
+ if (execOcc != null){
return execOcc.getY();
- else
- return 0;
+ }
+ return 0;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
+ */
@Override
public int getWidth() {
- if (execOcc != null)
+ if (execOcc != null) {
return execOcc.getWidth() + 7;
- else
- return 0;
+ }
+ return 0;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
+ */
@Override
public int getHeight() {
- if (execOcc != null)
+ if (execOcc != null) {
return execOcc.getWidth() + 10;
- else
- return 0;
+ }
+ return 0;
}
/**
@@ -90,14 +139,28 @@ public class HotSpot extends GraphNode {
return execOcc;
}
+ /**
+ * Returns the occurrence number.
+ *
+ * @return the occurrence number.
+ */
public int getOccurrence() {
return occurrence;
}
+ /**
+ * Set the occurrence number.
+ *
+ * @param occ A number to set.
+ */
public void setOccurrence(int occ) {
occurrence = occ;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
@@ -113,16 +176,28 @@ public class HotSpot extends GraphNode {
context.drawImage(image, getX(), getY(), getWidth(), getHeight());
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
+ */
@Override
public String getArrayId() {
return GLYPH;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isVisible(int, int, int, int)
+ */
@Override
public boolean isVisible(int x, int y, int width, int height) {
return true;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
+ */
@Override
public boolean contains(int _x, int _y) {
int x = getX();
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ITimeRange.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ITimeRange.java
index 3a80f30802..4d1b491404 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ITimeRange.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/ITimeRange.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ITimeRange.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,14 +16,31 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
/**
+ * A interface for handling time ranges.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public interface ITimeRange {
+ /**
+ * Returns the time when the message began.
+ * @return the time when the message began
+ */
public ITmfTimestamp getStartTime();
+ /**
+ * Returns the time when the message ended.
+ *
+ * @return the time when the message ended
+ */
public ITmfTimestamp getEndTime();
+ /**
+ * Returns flag to indicate whether time information is available or not.
+ *
+ * @return flag to indicate whether time information is available or not
+ */
public boolean hasTimeInfo();
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java
index 2092ebd5bd..dec67b86b0 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Lifeline.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: Lifeline.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -18,7 +19,7 @@ import java.util.List;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
* Lifeline is the UML2 lifeline graphical representation.
@@ -28,47 +29,87 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
* occurrences are just integer index. The event occurrences with the same value on different lifelines will correspond
* the same y coordinate value.
*
+ * @version 1.0
* @author sveyrier
*
*/
public class Lifeline extends GraphNode {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The life line tag.
+ */
+ public static final String LIFELINE_TAG = "Lifeline"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attribute
+ // ------------------------------------------------------------------------
/**
* The lifeline position in the containing frame
*/
protected int indexInFrame = 0;
-
/**
* The frame where the lifeline is drawn
*/
protected Frame frame = null;
-
/**
* The current event occurrence created in the lifeline
*/
protected int eventOccurrence = 0;
-
- public static final String LIFELINE_TAG = "Lifeline"; //$NON-NLS-1$
-
+ /**
+ * The lifeline category.
+ */
protected int category = -1;
-
+ /**
+ * Flag whether lifeline has time information available or not
+ */
protected boolean hasTime = false;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
+ public Lifeline() {
+ prefId = ISDPreferences.PREF_LIFELINE;
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
+ */
@Override
public int getX() {
return Metrics.FRAME_H_MARGIN + Metrics.LIFELINE_H_MAGIN + (indexInFrame - 1) * Metrics.swimmingLaneWidth();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
+ */
@Override
public int getY() {
return 2 * Metrics.FRAME_NAME_H_MARGIN + Metrics.LIFELINE_VT_MAGIN / 2 + Metrics.getFrameFontHeigth() + Metrics.getLifelineHeaderFontHeigth() + Metrics.FRAME_V_MARGIN + 2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
+ */
@Override
public int getWidth() {
return Metrics.getLifelineWidth();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
+ */
@Override
public int getHeight() {
// Set room for two text lines
@@ -76,10 +117,6 @@ public class Lifeline extends GraphNode {
+ 2 * Metrics.LIFELINE_NAME_H_MARGIN;
}
- public Lifeline() {
- prefId = ISDPreferences.PREF_LIFELINE;
- }
-
/**
* Set the lifeline category for this lifeline.
*
@@ -101,10 +138,12 @@ public class Lifeline extends GraphNode {
LifelineCategories[] categories = frame.getLifelineCategories();
if (category < categories.length) {
return categories[category].getName() + " " + getName(); //$NON-NLS-1$
- } else
+ } else {
return ""; //$NON-NLS-1$
- } else
+ }
+ } else {
return ""; //$NON-NLS-1$
+ }
}
/**
@@ -114,12 +153,13 @@ public class Lifeline extends GraphNode {
* @return the first visible Execution Occurrence
*/
public int getExecOccurrenceDrawIndex() {
- if (!hasChilden)
+ if (!hasChilden) {
return 0;
- if (indexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG) != null)
+ }
+ if (indexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG) != null) {
return ((Integer) indexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG)).intValue();
- else
- return 0;
+ }
+ return 0;
}
/**
@@ -132,8 +172,9 @@ public class Lifeline extends GraphNode {
if (hasTime) {
frame.setHasTimeInfo(true);
}
- if (frame.getMaxEventOccurrence() < getEventOccurrence() + 1)
+ if (frame.getMaxEventOccurrence() < getEventOccurrence() + 1) {
frame.setMaxEventOccurrence(getEventOccurrence() + 1);
+ }
}
/**
@@ -150,7 +191,6 @@ public class Lifeline extends GraphNode {
*
* @param index the lifeline X position
*/
-
protected void setIndex(int index) {
indexInFrame = index;
}
@@ -173,8 +213,9 @@ public class Lifeline extends GraphNode {
* @param eventOcc the new current event occurrence
*/
public void setCurrentEventOccurrence(int eventOcc) {
- if ((frame != null) && (frame.getMaxEventOccurrence() < eventOcc))
+ if ((frame != null) && (frame.getMaxEventOccurrence() < eventOcc)) {
frame.setMaxEventOccurrence(eventOcc);
+ }
eventOccurrence = eventOcc;
}
@@ -206,17 +247,25 @@ public class Lifeline extends GraphNode {
public void addExecution(BasicExecutionOccurrence exec) {
exec.setLifeline(this);
addNode(exec);
- if ((frame != null) && (frame.getMaxEventOccurrence() < exec.endEventOccurrence))
+ if ((frame != null) && (frame.getMaxEventOccurrence() < exec.endEventOccurrence)) {
frame.setMaxEventOccurrence(exec.endEventOccurrence);
+ }
}
+ /**
+ * Set whether lifeline has time information available or not.
+ * @param value The value to set
+ */
protected void setTimeInfo(boolean value) {
hasTime = value;
- if ((frame != null) && (value == true))
+ if ((frame != null) && (value == true)) {
frame.setHasTimeInfo(value);
+ }
}
/**
+ * Returns true if at least one execution occurrence has time info.
+ *
* @return true if at least one execution occurrence has time info
*/
public boolean hasTimeInfo() {
@@ -224,17 +273,21 @@ public class Lifeline extends GraphNode {
}
/**
- * Returns the list of execution occurrence on this lifeline
+ * Returns the list of execution occurrence on this lifeline.
*
* @return the execution occurrence list
*/
public List getExecutions() {
- if (hasChilden)
+ if (hasChilden) {
return (List) nodes.get(BasicExecutionOccurrence.EXEC_OCC_TAG);
- else
- return new ArrayList();
+ }
+ return new ArrayList();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
+ */
@Override
public boolean contains(int _x, int _y) {
int x = getX();
@@ -242,8 +295,9 @@ public class Lifeline extends GraphNode {
int width = getWidth();
int height = getHeight();
- if (frame == null)
+ if (frame == null) {
return false;
+ }
if (Frame.contains(x, y, width, height, _x, _y)) {
return true;
}
@@ -257,36 +311,45 @@ public class Lifeline extends GraphNode {
if (hMargin >= 2) {
if (frame.getVisibleAreaY() < y - height - hMargin) {
- if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2, height + 1, _x, _y))
+ if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2, height + 1, _x, _y)) {
return true;
+ }
} else {
- if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, frame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2, height, _x, _y))
+ if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, frame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2, height, _x, _y)) {
return true;
+ }
}
}
- if (getNodeAt(_x, _y) != null)
+ if (getNodeAt(_x, _y) != null) {
return true;
+ }
return false;
}
/**
* Returns the lifeline visibility for the given visible area
*
- * @param vx
- * @param vy
- * @param vwidth
- * @param vheight
+ * @param vx The x coordinate of the visible area
+ * @param vy The y coordinate of the visible area
+ * @param vwidth The width of the visible area
+ * @param vheight The height of the visible area
* @return true if visible false otherwise
*/
@Override
public boolean isVisible(int vx, int vy, int vwidth, int vheight) {
int x = getX();
int width = getWidth();
- if (((x >= vx) && (x <= vx + vwidth)) || ((x + width >= vx) && (x <= vx)))
+ if (((x >= vx) && (x <= vx + vwidth)) || ((x + width >= vx) && (x <= vx))) {
return true;
+ }
return false;
}
+ /**
+ * Draws the name within the graphical context.
+ *
+ * @param context The graphical context.
+ */
protected void drawName(IGC context) {
int x = getX();
int y = getY();
@@ -332,8 +395,9 @@ public class Lifeline extends GraphNode {
if (Frame.getUserPref().useGradienColor()) {
context.setGradientColor(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_LIFELINE));
context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_FRAME));
- } else
+ } else {
context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_LIFELINE));
+ }
context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_LIFELINE));
}
// Store the lifeline coordinates to save some calls
@@ -345,16 +409,18 @@ public class Lifeline extends GraphNode {
context.fillGradientRectangle(x, y, width, height / 2 - 7, true);
context.fillRectangle(x, y + height / 2 - 8, width, +height / 2 - 5);
context.fillGradientRectangle(x, y + height, width, -height / 2 + 6, true);
- } else
+ } else {
context.fillRectangle(x, y, width, height);
+ }
context.drawRectangle(x, y, width, height);
if (category >= 0) {
LifelineCategories[] categories = frame.getLifelineCategories();
if (category < categories.length) {
IImage image = categories[category].getImage();
- if (image != null)
+ if (image != null) {
context.drawImage(image, x, y, width, height);
+ }
}
}
@@ -393,8 +459,9 @@ public class Lifeline extends GraphNode {
context.setLineStyle(context.getLineSolidStyle());
- if (hasFocus())
+ if (hasFocus()) {
drawFocus(context);
+ }
super.drawChildenNodes(context);
}
@@ -418,16 +485,28 @@ public class Lifeline extends GraphNode {
context.setBackground(backupColor);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
draw(context, getX(), getY());
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
+ */
@Override
public String getArrayId() {
return LIFELINE_TAG;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#positiveDistanceToPoint(int, int)
+ */
@Override
public boolean positiveDistanceToPoint(int x, int y) {
if (getX() > x - Metrics.swimmingLaneWidth())
@@ -435,6 +514,10 @@ public class Lifeline extends GraphNode {
return false;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getNodeAt(int, int)
+ */
@Override
public GraphNode getNodeAt(int x, int y) {
int vy = 0;
@@ -442,25 +525,29 @@ public class Lifeline extends GraphNode {
if (getFrame() != null) {
vy = getFrame().getVisibleAreaY();
vh = getFrame().getVisibleAreaHeight();
- } else
+ } else {
return null;
- if (getExecutions() == null)
+ }
+ if (getExecutions() == null) {
return null;
+ }
for (int i = getExecOccurrenceDrawIndex(); i < getExecutions().size(); i++) {
GraphNode node = (GraphNode) getExecutions().get(i);
if (node.getHeight() < 0) {
- if (node.getY() + node.getHeight() > vy + vh)
+ if (node.getY() + node.getHeight() > vy + vh) {
break;
+ }
} else {
- if (node.getY() > vy + vh)
+ if (node.getY() > vy + vh) {
break;
+ }
}
if (node.contains(x, y)) {
GraphNode internal = node.getNodeAt(x, y);
- if (internal != null)
+ if (internal != null) {
return internal;
- else
- return node;
+ }
+ return node;
}
}
return null;
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/LifelineCategories.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/LifelineCategories.java
index 0de1ae4e35..aec4753f3f 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/LifelineCategories.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/LifelineCategories.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: LifelineCategories.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,14 +16,23 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
/**
+ *
* LifelineCategories is used to assign additional description for
* lifelines of the same type. This consists in providing a type name and an icon.
* The icon will be displayed in the rectangle which contains the lifeline name.
* The category name is only display in the lifeline tooltip.
+ *
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public class LifelineCategories {
-
- /**
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
* The category name
*/
protected String name = null;
@@ -30,9 +40,14 @@ public class LifelineCategories {
* The category image
*/
protected IImage categoryImage = null;
-
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
- * Returns the category name
+ * Returns the category name.
+ *
* @return the category name
*/
public String getName() {
@@ -40,7 +55,8 @@ public class LifelineCategories {
}
/**
- * Set the category name
+ * Sets the category name.
+ *
* @param string the name
*/
public void setName(String string) {
@@ -48,20 +64,20 @@ public class LifelineCategories {
}
/**
- * Returns the category icon
+ * Returns the category icon.
+ *
* @return the category icon
*/
- public IImage getImage()
- {
+ public IImage getImage() {
return categoryImage;
}
/**
- * Set the category icon
+ * Sets the category icon.
+ *
* @param image the icon
*/
- public void setImage(IImage image)
- {
+ public void setImage(IImage image) {
categoryImage = image;
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Metrics.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Metrics.java
index 2beb3cd704..d57aaea37c 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Metrics.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Metrics.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: Metrics.java,v 1.3 2008/01/24 02:28:49 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -16,10 +17,14 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
* This class contains the metrics used to layout a sequence diagram on a view The class method are mostly used in
* combination with the preferences
*
+ * @version
* @author sveyrier
*
*/
public class Metrics {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
/**
* Space between the Frame and the top of the View This also represent the space between the frame and the bottom of
@@ -35,7 +40,6 @@ public class Metrics {
* Space between the Lifelines and the right of the Frame
*/
public static final int LIFELINE_H_MAGIN = 23;
-
/**
* Space between the Lifelines and the bottom of the Frame
*/
@@ -52,7 +56,7 @@ public class Metrics {
/**
* Vertical spacing between messages
*/
- protected static final int MESSAGES_SPACING = 30;
+ public static final int MESSAGES_SPACING = 30;
/**
* Vertical spacing between the message and its name
*/
@@ -89,10 +93,14 @@ public class Metrics {
* The square width which contains the Stop representation (a cross)
*/
public static final int STOP_WIDTH = 20;
-
+ /**
+ * The internal message width.
+ */
public static final int INTERNAL_MESSAGE_WIDTH = 20;
+ /**
+ * The internal sychrounous message height.
+ */
public static final int SYNC_INTERNAL_MESSAGE_HEIGHT = 10;
-
/**
* Line width used when drawing selected GraphNode
*/
@@ -101,6 +109,9 @@ public class Metrics {
* Line width used when drawing non selected GraphNode
*/
public static final int NORMAL_LINE_WIDTH = 1;
+ /**
+ * The internal vertical message margin
+ */
public static final int INTERNAL_MESSAGE_V_MARGIN = 10;
/**
@@ -113,20 +124,50 @@ public class Metrics {
* message are displayed to avoid message overlapping and mainly saving some execution time
*/
public static final int MESSAGE_SIGNIFICANT_VSPACING = 1;
-
- // Used for internal syncMessages only
+ /**
+ * Message selection tolerance. Used for internal syncMessages only
+ */
public static final int MESSAGE_SELECTION_TOLERANCE = 30;
-
+ /**
+ * The focus drawing margin.
+ */
public static final int FOCUS_DRAWING_MARGIN = 10;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The lifeline font height
+ */
+ private static int lifelineFontHeight = 0;
+ /**
+ * The message font height
+ */
+ private static int messageFontHeight = 0;
+ /**
+ * The frame font height
+ */
+ private static int frameFontHeight = 0;
+ /**
+ * The lifeline header font height
+ */
+ private static int lifelineHeaderFontHeight = 0;
+ /**
+ * The lifeline font widht
+ */
+ private static int lifelineFontWidth = 0;
+ /**
+ * The lifeline width
+ */
+ private static int lifeLineWidth = 119;
+ /**
+ * The (forced) event spacing
+ */
+ private static int forcedEventSpacing = -1;
- static private int lifelineFontHeight = 0;
- static private int messageFontHeight = 0;
- static private int frameFontHeight = 0;
- static private int lifelineHeaderFontHeight = 0;
- static private int lifelineFontWidth = 0;
- static private int lifeLineWidth = 119;
-
- static private int forcedEventSpacing = -1;
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
/**
* Set the character height used to draw the lifeline name
@@ -206,10 +247,10 @@ public class Metrics {
* @return the character height
*/
static public int getMessageFontHeigth() {
- if (forcedEventSpacing >= 0)
+ if (forcedEventSpacing >= 0) {
return 0;
- else
- return messageFontHeight;
+ }
+ return messageFontHeight;
}
/**
@@ -248,11 +289,16 @@ public class Metrics {
return lifelineFontWidth;
}
+ /**
+ * Returns the message spacing.
+ *
+ * @return the message spacing
+ */
static public int getMessagesSpacing() {
- if (forcedEventSpacing >= 0)
+ if (forcedEventSpacing >= 0) {
return forcedEventSpacing;
- else
- return MESSAGES_SPACING;
+ }
+ return MESSAGES_SPACING;
}
/**
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SDTimeEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SDTimeEvent.java
index 0c7fbf833c..7a01eef3a0 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SDTimeEvent.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SDTimeEvent.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: TimeEvent.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,29 +16,73 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
/**
+ * Class implementation of a sequence diagram time event.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class SDTimeEvent {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The time stamp of the event
+ */
protected ITmfTimestamp time;
+ /**
+ * The event index.
+ */
protected int event;
+ /**
+ * The time range implementing node.
+ */
protected ITimeRange node;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * The default constructor.
+ *
+ * @param _time The time stamp of the event.
+ * @param _event The event index.
+ * @param _node The time range implementing node.
+ */
public SDTimeEvent(ITmfTimestamp _time, int _event, ITimeRange _node) {
time = _time;
event = _event;
node = _node;
}
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Returns the timestamp of the event.
+ *
+ * @return the timestamp of the event.
+ */
public ITmfTimestamp getTime() {
return time;
}
+ /**
+ * Returns the event index.
+ *
+ * @return the event index.
+ */
public int getEvent() {
return event;
}
+ /**
+ * Returns the time range implementing node.
+ *
+ * @return the time range implementing node.
+ */
public ITimeRange getGraphNode() {
return node;
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Stop.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Stop.java
index 8b3f124b08..9273ab832d 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Stop.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/Stop.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: Stop.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,28 +14,35 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
- * It is the UML2 stop graphical representation in the sequence diagram viewer.
- * This draw a cross on the lifeline. The stop y coordinate depend on the event occurrence when it appears.
- * A stop is never drawn it is assigned to a lifeline.
- *
+ *
+ * It is the UML2 stop graphical representation in the sequence diagram viewer.
+ * This draw a cross on the lifeline. The stop y coordinate depend on the event occurrence when it appears.
+ * A stop is never drawn it is assigned to a lifeline.
+ *
*
+ * @version 1.0
* @author sveyrier
*/
public class Stop extends GraphNode {
- /**
- * The owning lifeline on which the stop appears
- */
- protected Lifeline lifeline = null;
-
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
/**
* The graphNode ID
*/
public static final String STOP = "STOP"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The owning lifeline on which the stop appears
+ */
+ protected Lifeline lifeline = null;
/**
* This basically represents the time when the stop occurs on the owning Lifeline
*
@@ -42,31 +50,55 @@ public class Stop extends GraphNode {
*/
protected int eventOccurrence = 0;
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
+ */
@Override
public int getX() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return lifeline.getX() + Metrics.getLifelineWidth() / 2 - Metrics.STOP_WIDTH / 2;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
+ */
@Override
public int getY() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return lifeline.getY() + lifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * eventOccurrence - Metrics.STOP_WIDTH / 2;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
+ */
@Override
public int getWidth() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return Metrics.STOP_WIDTH;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
+ */
@Override
public int getHeight() {
- if (lifeline == null)
+ if (lifeline == null) {
return 0;
+ }
return Metrics.STOP_WIDTH;
}
@@ -88,6 +120,10 @@ public class Stop extends GraphNode {
eventOccurrence = occurrence;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
// Set the appropriate color depending if the graph node if selected or not
@@ -131,7 +167,6 @@ public class Stop extends GraphNode {
*/
@Override
public boolean contains(int x, int y) {
- // TODO Auto-generated method stub
return false;
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessage.java
index e9ebbe463c..4ebc0688ac 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SyncMessage.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -17,7 +18,7 @@ import java.util.Comparator;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortSyncMessageComparator;
/**
@@ -46,39 +47,63 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortSyncMessageComparator
*
*
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
+ * @version 1.0
* @author sveyrier
*
*/
public class SyncMessage extends BaseMessage implements ITimeRange {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The graphNode ID
+ */
+ public static final String SYNC_MESS_TAG = "SyncMessage"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
* The associated message return
*/
protected SyncMessageReturn messageReturn;
-
/**
* The time when the message occurs
*/
protected ITmfTimestamp eventTime = new TmfTimestamp();
-
- public static final String SYNC_MESS_TAG = "SyncMessage"; //$NON-NLS-1$
-
+ /**
+ * Flag whether the message has time information available or not
+ */
protected boolean hasTime = false;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Default constructor
+ */
public SyncMessage() {
prefId = ISDPreferences.PREF_SYNC_MESS;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
* Ensure both lifelines have the same event occurrence (the greater found on each lifeline)
*/
protected void syncLifelinesEventOccurrence() {
if ((getStartLifeline() != null) && (getEndLifeline() != null)) {
int newIndex = 0;
- if (getStartLifeline().getEventOccurrence() > getEndLifeline().getEventOccurrence())
+ if (getStartLifeline().getEventOccurrence() > getEndLifeline().getEventOccurrence()) {
newIndex = getStartLifeline().getEventOccurrence();
- else
+ } else {
newIndex = getEndLifeline().getEventOccurrence();
+ }
getStartLifeline().setCurrentEventOccurrence(newIndex);
getEndLifeline().setCurrentEventOccurrence(newIndex);
setEventOccurrence(getStartLifeline().getEventOccurrence());
@@ -126,8 +151,9 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
super.setStartLifeline(lifeline);
if ((getEndLifeline() == null)) {
setEventOccurrence(getStartLifeline().getEventOccurrence());
- } else
+ } else {
syncLifelinesEventOccurrence();
+ }
}
/**
@@ -143,8 +169,9 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
super.setEndLifeline(lifeline);
if ((getStartLifeline() == null)) {
setEventOccurrence(getEndLifeline().getEventOccurrence());
- } else
+ } else {
syncLifelinesEventOccurrence();
+ }
}
/**
@@ -185,42 +212,49 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
public void setTime(ITmfTimestamp time) {
eventTime = time.clone();
hasTime = true;
- if (getStartLifeline() != null && getStartLifeline().getFrame() != null)
+ if (getStartLifeline() != null && getStartLifeline().getFrame() != null) {
getStartLifeline().getFrame().setHasTimeInfo(true);
- else if (getEndLifeline() != null && getEndLifeline().getFrame() != null)
+ } else if (getEndLifeline() != null && getEndLifeline().getFrame() != null) {
getEndLifeline().getFrame().setHasTimeInfo(true);
+ }
}
- /**
- * Returns the time when the message begin
- *
- * @return the time
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getEndTime()
*/
@Override
public ITmfTimestamp getEndTime() {
return eventTime;
}
- /**
- * Returns the time when the message end
- *
- * @return the time
- */
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getStartTime()
+ */
@Override
public ITmfTimestamp getStartTime() {
return eventTime;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo()
+ */
@Override
public boolean hasTimeInfo() {
return hasTime;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
if (!isVisible())
return;
- // Draw it selected?*/
+ // Draw it selected?
if (!isSelected()) {
context.setBackground(Frame.getUserPref().getBackGroundColor(prefId));
context.setForeground(Frame.getUserPref().getForeGroundColor(prefId));
@@ -228,37 +262,56 @@ public class SyncMessage extends BaseMessage implements ITimeRange {
super.draw(context);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#isVisible(int, int, int, int)
+ */
@Override
public boolean isVisible(int x, int y, int width, int height) {
if (getY() > y + height +
- // take into account the message name drawn above the arrow
- Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth())
+ // take into account the message name drawn above the arrow
+ Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()) {
return false;
+ }
// UML2 lost/found message visibility special case
// Others visibility cases are perform in the ***common*** case
if ((endLifeline == null && startLifeline != null) || (endLifeline != null && startLifeline == null)) {
- if (x + width > getX() + getWidth() && x < getX() + getWidth())
+ if (x + width > getX() + getWidth() && x < getX() + getWidth()) {
return true;
+ }
}
// ***Common*** syncMessages visibility
return super.isVisible(x, y, width, height);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getComparator()
+ */
@Override
public Comparator getComparator() {
return new SortSyncMessageComparator();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
+ */
@Override
public String getArrayId() {
return SYNC_MESS_TAG;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#positiveDistanceToPoint(int, int)
+ */
@Override
public boolean positiveDistanceToPoint(int x, int y) {
- if (getY() > y)
+ if (getY() > y) {
return true;
+ }
return false;
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessageReturn.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessageReturn.java
index d9e43712ce..0a41eb789c 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessageReturn.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/SyncMessageReturn.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SyncMessageReturn.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,7 +14,7 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
/**
* The message return graph node implementation.
@@ -26,22 +27,42 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
*
*
* @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage SyncMessage for usage example
+ * @version 1.0
* @author sveyrier
*
*/
public class SyncMessageReturn extends SyncMessage {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The graphNode ID
+ */
+ public static final String SYNC_MESS_RET_TAG = "SyncMessageRet"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
/**
* The associated message(the message it is the return).
*/
protected SyncMessage message = null;
- public static final String SYNC_MESS_RET_TAG = "SyncMessageRet"; //$NON-NLS-1$
-
+ // ------------------------------------------------------------------------
+ // Constractors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Default constructor
+ */
public SyncMessageReturn() {
prefId = ISDPreferences.PREF_SYNC_MESS_RET;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
/**
* Set the associated message (the message it is the return).
* Setting the association will activate the navigation in the default sequence diagram implementation to the
@@ -63,14 +84,19 @@ public class SyncMessageReturn extends SyncMessage {
return message;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
+ */
@Override
public void draw(IGC context) {
- if (!isVisible())
+ if (!isVisible()) {
return;
+ }
int oldStyle = context.getLineStyle();
// Message return are dashed
context.setLineStyle(context.getLineDotStyle());
- // Draw it selected?*/
+ // Draw it selected?
if (!isSelected()) {
context.setBackground(Frame.getUserPref().getBackGroundColor(prefId));
context.setForeground(Frame.getUserPref().getForeGroundColor(prefId));
@@ -80,6 +106,10 @@ public class SyncMessageReturn extends SyncMessage {
context.setLineStyle(oldStyle);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage#getArrayId()
+ */
@Override
public String getArrayId() {
return SYNC_MESS_RET_TAG;
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/Criteria.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/Criteria.java
similarity index 77%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/Criteria.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/Criteria.java
index 058982e175..65d804a890 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/Criteria.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/Criteria.java
@@ -1,16 +1,17 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: Criteria.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import java.util.ArrayList;
import java.util.Iterator;
@@ -23,21 +24,57 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNode
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
- * This class describe the Find or Filter criteria selected by the user in the Find or Filter dialog box
- *
+ * This class describes the find or filter criteria selected by the user in the find or filter dialog box
+ *
+ * @version 1.0
* @author sveyrier
+ * @author Bernd Hufmann
*/
public class Criteria {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Flag whether lifeline is selected or not.
+ */
protected boolean lifeLineSelected = false;
+ /**
+ * Flag whether synchronous message is selected or not.
+ */
protected boolean syncMessageSelected = false;
+ /**
+ * Flag whether synchronous message return is selected or not.
+ */
protected boolean syncMessageReturnSelected = false;
+ /**
+ * Flag whether asynchronous message is selected or not.
+ */
protected boolean asyncMessageSelected = false;
+ /**
+ * Flag whether asynchronous message return is selected or not.
+ */
protected boolean asyncMessageReturnSelected = false;
- private boolean caseSenstiveSelected = false;
+ /**
+ * Flag whether case sensitive find is required or not.
+ */
+ protected boolean caseSenstiveSelected = false;
+ /**
+ * Flag whether stop graph node is selected or not.
+ */
protected boolean stopSelected = false;
- private String expression = null;
- private Pattern pattern = null;
+ /**
+ * The find expression.
+ */
+ protected String expression = null;
+ /**
+ * The find pattern as regular expression.
+ */
+ protected Pattern pattern = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
/**
* Default constructor
@@ -47,6 +84,7 @@ public class Criteria {
/**
* Copy constructor
+ *
* @param other Criteria to create new criteria
*/
public Criteria (Criteria other) {
@@ -60,8 +98,12 @@ public class Criteria {
setExpression(other.expression);
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
- * Returns true if the AsyncMessageReturn is selected, false otherwise
+ * Returns true if the AsyncMessageReturn is selected, false otherwise.
*
* @return true if the AsyncMessageReturn is selected, false otherwise
*/
@@ -70,7 +112,7 @@ public class Criteria {
}
/**
- * Returns true if the AsyncMessage is selected, false otherwise
+ * Returns true if the AsyncMessage is selected, false otherwise.
*
* @return true if the AsyncMessage is selected, false otherwise
*/
@@ -79,30 +121,34 @@ public class Criteria {
}
/**
- * Returns the text enter by the user
+ * Returns the text enter by the user.
*
- * @return the text
+ * @return the expression text
*/
public String getExpression() {
return expression;
}
/**
- * @return pattern
+ * Returns the regular expression pattern.
+ *
+ * @return the regular expression pattern
*/
public Pattern getPattern() {
return pattern;
}
/**
- * @param pattern
+ * Sets the regular expression pattern.
+ *
+ * @param the pattern to set
*/
public void setPattern(Pattern pattern) {
this.pattern = pattern;
}
/**
- * Returns true if the LifeLine is selected, false otherwise
+ * Returns true if the LifeLine is selected, false otherwise.
*
* @return true if the LifeLine is selected, false otherwise
*/
@@ -111,7 +157,7 @@ public class Criteria {
}
/**
- * Returns true if the Stop is selected, false otherwise
+ * Returns true if the Stop is selected, false otherwise.
*
* @return true if the Stop is selected, false otherwise
*/
@@ -120,7 +166,7 @@ public class Criteria {
}
/**
- * Returns true if the SyncMessageReturn is selected, false otherwise
+ * Returns true if the SyncMessageReturn is selected, false otherwise.
*
* @return true if the SyncMessageReturn is selected, false otherwise
*/
@@ -129,7 +175,7 @@ public class Criteria {
}
/**
- * Returns true if the SyncMessage is selected, false otherwise
+ * Returns true if the SyncMessage is selected, false otherwise.
*
* @return true if the SyncMessage is selected, false otherwise
*/
@@ -138,7 +184,7 @@ public class Criteria {
}
/**
- * Set AsyncMessageReturn selection state
+ * Sets the AsyncMessageReturn selection state.
*
* @param b true if selected, false otherwise
*/
@@ -147,7 +193,7 @@ public class Criteria {
}
/**
- * Set AsyncMessage selection state
+ * Sets the AsyncMessage selection state.
*
* @param b true if selected, false otherwise
*/
@@ -156,14 +202,13 @@ public class Criteria {
}
/**
- * Set the text enter by the user
+ * Sets the text entered by the user and compiles the regular expression.
*
* @param string the text
*/
public void setExpression(String string) {
expression = string;
if (expression != null) {
-
try {
if (caseSenstiveSelected) {
pattern = Pattern.compile(string);
@@ -171,7 +216,6 @@ public class Criteria {
else {
pattern = Pattern.compile(string, Pattern.CASE_INSENSITIVE);
}
-
} catch (PatternSyntaxException e) {
pattern = null;
}
@@ -182,7 +226,7 @@ public class Criteria {
}
/**
- * Set Stop selection state
+ * Sets the Stop selection state.
*
* @param b true if selected, false otherwise
*/
@@ -191,7 +235,7 @@ public class Criteria {
}
/**
- * Set Stop selection state
+ * Set Stop selection state.
*
* @param b true if selected, false otherwise
*/
@@ -200,7 +244,7 @@ public class Criteria {
}
/**
- * Set SyncMessageReturn selection state
+ * Sets the SyncMessageReturn selection state.
*
* @param b true if selected, false otherwise
*/
@@ -209,7 +253,7 @@ public class Criteria {
}
/**
- * Set SyncMessage selection state
+ * Sets the SyncMessage selection state.
*
* @param b true if selected, false otherwise
*/
@@ -218,7 +262,7 @@ public class Criteria {
}
/**
- * Returns true if the case sensitive is selected, false otherwise
+ * Returns true if the case sensitive is selected, false otherwise.
*
* @return true if the case sensitive is selected, false otherwise
*/
@@ -227,7 +271,7 @@ public class Criteria {
}
/**
- * Set case sensitive selection state
+ * Set case sensitive selection state.
*
* @param b true if selected, false otherwise
*/
@@ -238,7 +282,9 @@ public class Criteria {
}
/**
- * @param to
+ * Compares this criteria with a given criteria.
+ *
+ * @param to The criteria to compare
* @return usual comparison result (< 0, 0, > 0)
*/
public boolean compareTo(Criteria to) {
@@ -253,7 +299,9 @@ public class Criteria {
}
/**
- * @param settings
+ * Saves current criteria attributes in the dialog settings.
+ *
+ * @param settings The dialog settings
*/
public void save(DialogSettings settings) {
settings.put("expression", getExpression()); //$NON-NLS-1$
@@ -267,7 +315,9 @@ public class Criteria {
}
/**
- * @param settings
+ * Loads the criteria with values of the dialog settings.
+ *
+ * @param settings The dialog settings
*/
public void load(DialogSettings settings) {
setExpression(settings.get("expression")); //$NON-NLS-1$
@@ -280,6 +330,13 @@ public class Criteria {
setSyncMessageSelected(settings.getBoolean("isSyncMessageSelected")); //$NON-NLS-1$
}
+ /**
+ * Gets the summary of supported graph nodes.
+ *
+ * @param provider A filter provider
+ * @param loaderClassName A class loader
+ * @return graph node summary
+ */
public String getGraphNodeSummary(ISDFilterProvider provider, String loaderClassName) {
ArrayList list = new ArrayList();
@@ -334,7 +391,9 @@ public class Criteria {
}
/**
- * @param stringToMatch
+ * Matches given string using compiled pattern based on user expression.
+ *
+ * @param stringToMatch A string to match
* @return true if string matches expression
*/
public boolean matches(String stringToMatch) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/FilterCriteria.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterCriteria.java
similarity index 58%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/FilterCriteria.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterCriteria.java
index 51e9d03f13..b9fc687604 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/FilterCriteria.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterCriteria.java
@@ -1,16 +1,17 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: FilterCriteria.java,v 1.3 2008/01/24 02:29:09 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import java.util.Iterator;
import java.util.List;
@@ -19,36 +20,58 @@ import org.eclipse.jface.dialogs.DialogSettings;
/**
* A filter criteria is a criteria that can be activated or not, positive or not.
+ *
+ * @version 1.0
+ * @author sveyrier
+ *
*/
public class FilterCriteria {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The filter state value for 'active'.
+ */
protected static final String ACTIVE = "active"; //$NON-NLS-1$
+ /**
+ * The property value for positive filter.
+ */
protected static final String POSITIVE = "positive"; //$NON-NLS-1$
+ /**
+ * The filter loader class name property.
+ */
protected static final String LOADERCLASSNAME = "loaderClassName"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The criteria reference.
+ */
protected Criteria criteria;
+ /**
+ * Flag whether this criteria is active or not
+ */
protected boolean active;
+ /**
+ * Flag whether this criteria is for positive filter or not
+ */
protected boolean positive;
+ /**
+ * The loader class name.
+ */
protected String loaderClassName;
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- sb.append(":"); //$NON-NLS-1$
- if (criteria != null) {
- sb.append(" expression=");sb.append(criteria.getExpression()); //$NON-NLS-1$
- sb.append(" active=");sb.append(active); //$NON-NLS-1$
- sb.append(" positive=");sb.append(positive); //$NON-NLS-1$
- } else {
- sb.append("empty criteria"); //$NON-NLS-1$
- }
- return sb.toString();
- }
-
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
/**
- * @param criteria_
- * @param active_
- * @param positive_
+ * Standard constructor
+ *
+ * @param criteria_ A criteria reference
+ * @param active_ true
if filter criteria is active else false
+ * @param positive_ true
for positive filter else false
*/
public FilterCriteria(Criteria criteria_, boolean active_, boolean positive_) {
setCriteria(criteria_);
@@ -57,10 +80,12 @@ public class FilterCriteria {
}
/**
- * @param criteria_
- * @param active_
- * @param positive_
- * @param loaderClassName_
+ * Constructor
+ *
+ * @param criteria_ A criteria reference
+ * @param active_ true
if filter criteria is active else false
+ * @param positive_ true
for positive filter else false
+ * @param loaderClassName_ A loader class name
*/
public FilterCriteria(Criteria criteria_, boolean active_, boolean positive_, String loaderClassName_) {
setCriteria(criteria_);
@@ -80,39 +105,80 @@ public class FilterCriteria {
this.loaderClassName = other.loaderClassName;
}
+ /**
+ * Default constructor
+ */
protected FilterCriteria() {
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append(":"); //$NON-NLS-1$
+ if (criteria != null) {
+ sb.append(" expression=");sb.append(criteria.getExpression()); //$NON-NLS-1$
+ sb.append(" active=");sb.append(active); //$NON-NLS-1$
+ sb.append(" positive=");sb.append(positive); //$NON-NLS-1$
+ } else {
+ sb.append("empty criteria"); //$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+
/**
- * @param criteria_
+ * Sets a criteria reference.
+ * @param criteria_ A criteria reference
*/
public void setCriteria(Criteria criteria_) {
criteria = criteria_;
}
+ /**
+ * Returns the criteria reference.
+ *
+ * @return the criteria reference
+ */
public Criteria getCriteria() {
return criteria;
}
/**
- * @param active_
+ * Sets the active flag.
+ *
+ * @param active_ A active value.
*/
public void setActive(boolean active_) {
active = active_;
}
+ /**
+ * Returns whether filter criteria is active or not.
+ *
+ * @return whether filter criteria is active or not.
+ */
public boolean isActive() {
return active;
}
/**
- * @param positive_ The positive to set.
+ * Sets filter is for positive filtering or not.
+ *
+ * @param positive_ The value to set.
*/
public void setPositive(boolean positive_) {
positive = positive_;
}
/**
+ * Returns whether the filter si for positive filtering or not.
+ *
* @return Returns the positive.
*/
public boolean isPositive() {
@@ -120,18 +186,30 @@ public class FilterCriteria {
}
/**
+ * Sets the loader class name for this filter.
+ *
+ * @param loaderClassName_ The loader class name to set
*/
public void setLoaderClassName(String loaderClassName_) {
loaderClassName = loaderClassName_;
}
/**
- * @return Returns the class loader name.
+ * Returns the class loader name.
+ *
+ * @return the class loader name.
*/
public String getLoaderClassName() {
return loaderClassName;
}
+ /**
+ * Finds a filter criteria within a list of criteria.
+ *
+ * @param what The filter to find
+ * @param list A list of filter criteria
+ * @return The found filter criteria or null
+ */
public static FilterCriteria find(FilterCriteria what, List list) {
if (what != null && list != null) {
try {
@@ -148,6 +226,12 @@ public class FilterCriteria {
return null;
}
+ /**
+ * Compares this filter criteria with a given criteria.
+ *
+ * @param to The filter criteria to compare.
+ * @return usual comparison result (< 0, 0, > 0)
+ */
public boolean compareTo(FilterCriteria to) {
if (isPositive() == to.isPositive() && getCriteria().compareTo(to.getCriteria())) {
if (getLoaderClassName() == null && to.getLoaderClassName() == null) {
@@ -160,6 +244,11 @@ public class FilterCriteria {
return false;
}
+ /**
+ * Saves current criteria attributes in the dialog settings.
+ *
+ * @param settings The dialog settings
+ */
public void save(DialogSettings settings) {
settings.put(ACTIVE, isActive());
settings.put(POSITIVE, isPositive());
@@ -168,19 +257,23 @@ public class FilterCriteria {
} else {
settings.put(LOADERCLASSNAME, ""); //$NON-NLS-1$
}
- if (criteria != null)
+ if (criteria != null) {
criteria.save(settings);
+ }
}
/**
- * @param settings
+ * Loads the criteria with values of the dialog settings.
+ *
+ * @param settings The dialog settings
*/
public void load(DialogSettings settings) {
setActive(settings.getBoolean(ACTIVE));
setPositive(settings.getBoolean(POSITIVE));
String loaderClassName_ = settings.get(LOADERCLASSNAME);
setLoaderClassName(loaderClassName_ != null && loaderClassName_.length() > 0 ? loaderClassName_ : null);
- if (criteria != null)
+ if (criteria != null) {
criteria.load(settings);
+ }
}
}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/FilterListDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterListDialog.java
similarity index 74%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/FilterListDialog.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterListDialog.java
index d3baf9c447..084624ddec 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/FilterListDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/FilterListDialog.java
@@ -1,16 +1,17 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: FilterListDialog.java,v 1.4 2008/01/24 02:29:09 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import java.util.ArrayList;
import java.util.Iterator;
@@ -38,87 +39,91 @@ import org.eclipse.ui.IViewPart;
/**
* This is the filters list dialog.
* It is associated to an SDView and to a ISDFilterProvider.
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public class FilterListDialog extends Dialog {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
protected static final String FILTERS_LIST_CRITERIA = "filtersListsCriteria"; //$NON-NLS-1$
protected static final String FILTERS_LIST_SIZE = "filtersListSize"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
- * viewer and provided are kept here as attributes
+ * The viewer and provided are kept here as attributes
*/
protected IViewPart viewer = null;
+ /**
+ * The filter provider implementation
+ */
protected ISDFilterProvider provider = null;
-
/**
- * filters are the result of editing this list
+ * The filters are the result of editing this list
*/
protected List filters;
-
/**
- * add, remove and edit buttons
+ * The add button.
*/
- protected Button add, remove, edit;
-
+ protected Button add;
/**
- * table
+ * The remove button.
*/
- protected Table table;
-
+ protected Button remove;
/**
- * A class to map TableItems that can be toggled active or inactive and Criterias
+ * The edit button.
*/
- protected class CriteriaTableItem {
-
- protected Criteria criteria;
- protected boolean positive;
- protected String loaderClassName;
- protected TableItem tableItem;
-
- public CriteriaTableItem(Table parent, boolean checked_, boolean positive_, String loaderClassName_) {
- tableItem = new TableItem(parent, SWT.NONE);
- tableItem.setData(this);
- tableItem.setChecked(checked_);
- positive = positive_;
- loaderClassName = loaderClassName_;
- }
-
- public CriteriaTableItem(Table parent, boolean checked_, boolean positive_, String loaderClassName_, int index) {
- tableItem = new TableItem(parent, SWT.NONE, index);
- tableItem.setChecked(checked_);
- positive = positive_;
- loaderClassName = loaderClassName_;
- }
-
- public void setCriteria(Criteria criteria_) {
- criteria = criteria_;
- tableItem.setText((positive ? SDMessages._59 : SDMessages._58) + " " + criteria.getExpression() + " " + criteria.getGraphNodeSummary(provider, loaderClassName)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public Criteria getCriteria() {
- return criteria;
- }
+ protected Button edit;
+ /**
+ * The table with list of filters.
+ */
+ protected Table table;
- public boolean getPositive() {
- return positive;
- }
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
- public String getLoaderClassName() {
- return loaderClassName;
- }
+ /**
+ * Standard constructor
+ *
+ * @param view_ The view reference
+ * @param loader_ The filter provider implementation
+ */
+ public FilterListDialog(IViewPart view_, ISDFilterProvider loader_) {
+ super(view_.getSite().getShell());
+ viewer = view_;
+ provider = loader_;
+ filters = null;
+ // filters = provider.getCurrentFilters();
+ setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
/**
- * @param c
- * @param checked
+ * Adds a criteria to the table
+ *
+ * @param criteria A criteria to add
+ * @param checked A flag whether criteria is checked (selected) or not
+ * @param positive A flag whether criteria is for positive filter or not
+ * @param loaderClassName A loader class name for the filters
*/
- protected void addCriteria(Criteria c, boolean checked, boolean positive, String loaderClassName) {
+ protected void addCriteria(Criteria criteria, boolean checked, boolean positive, String loaderClassName) {
CriteriaTableItem cti = new CriteriaTableItem(table, checked, positive, loaderClassName);
- cti.setCriteria(c);
+ cti.setCriteria(criteria);
}
/**
- * @param new_
+ * Replaces a selected criteria with a new criteria.
+ *
+ * @param new_ A new criteria.
*/
protected void replaceSelectedCriteria(Criteria new_) {
CriteriaTableItem cti = (CriteriaTableItem) table.getSelection()[0].getData();
@@ -126,7 +131,7 @@ public class FilterListDialog extends Dialog {
}
/**
- *
+ * Handles table selection count.
*/
protected void handleTableSelectionCount() {
int count = table.getSelectionCount();
@@ -134,7 +139,8 @@ public class FilterListDialog extends Dialog {
remove.setEnabled(count > 0);
}
- /**
+ /*
+ * (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
@@ -166,9 +172,9 @@ public class FilterListDialog extends Dialog {
public void widgetDefaultSelected(SelectionEvent e) {
int count = table.getSelectionCount();
if (count == 1) {
- Criteria c = openFilterDialog(((CriteriaTableItem) table.getSelection()[0].getData()).getCriteria(), SDMessages._63);
- if (c != null) {
- replaceSelectedCriteria(c);
+ Criteria criteria = openFilterDialog(((CriteriaTableItem) table.getSelection()[0].getData()).getCriteria(), SDMessages._63);
+ if (criteria != null) {
+ replaceSelectedCriteria(criteria);
}
}
}
@@ -286,21 +292,10 @@ public class FilterListDialog extends Dialog {
}
/**
- * @param view_
- * @param loader_
- */
- public FilterListDialog(IViewPart view_, ISDFilterProvider loader_) {
- super(view_.getSite().getShell());
- viewer = view_;
- provider = loader_;
- filters = null;
- // filters = provider.getCurrentFilters();
- setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- }
-
- /**
- * @param criteria
- * @param action between "Update" and "Create"
+ * Opens the filter dialog box with given parameter.
+ *
+ * @param criteria The criteria reference to pass
+ * @param action to distinguish between "Update" and "Create"
* @return the criteria that has been updated or created
*/
protected Criteria openFilterDialog(Criteria criteria, String action) {
@@ -312,8 +307,9 @@ public class FilterListDialog extends Dialog {
return filter.getCriteria();
}
- /**
- * Open the dialog box
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#open()
*/
@Override
public int open() {
@@ -324,8 +320,9 @@ public class FilterListDialog extends Dialog {
return super.open();
}
- /**
- * Called when the dialog box ok button is pressed
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
public void okPressed() {
@@ -351,19 +348,26 @@ public class FilterListDialog extends Dialog {
}
/**
- * @param filters_
+ * Sets the list of filters.
+ *
+ * @param filters_ The list of filters to set.
*/
public void setFilters(ArrayList filters_) {
filters = filters_;
}
/**
+ * Returns the filters list after editing.
+ *
* @return the filters list after editing
*/
public List getFilters() {
return filters;
}
+ /**
+ * Loads the filter criteria from global filters which are saved in the dialog settings.
+ */
protected void loadFiltersCriteria() {
List globalFilters = getGlobalFilters();
for (Iterator i = globalFilters.iterator(); i.hasNext();) {
@@ -372,6 +376,11 @@ public class FilterListDialog extends Dialog {
}
}
+ /**
+ * Returns the global filters which are saved in the dialog settings..
+ *
+ * @return the saved global filters
+ */
public static List getGlobalFilters() {
DialogSettings settings = (DialogSettings) TmfUiPlugin.getDefault().getDialogSettings().getSection(FILTERS_LIST_CRITERIA);
int i = 0;
@@ -400,6 +409,11 @@ public class FilterListDialog extends Dialog {
return globalFilters;
}
+ /**
+ * Saves the filter criteria in the dialog settings.
+ *
+ * @param globalFilters A list of filters to save.
+ */
public static void saveFiltersCriteria(List globalFilters) {
DialogSettings settings = (DialogSettings) TmfUiPlugin.getDefault().getDialogSettings();
DialogSettings section = (DialogSettings) settings.getSection(FILTERS_LIST_CRITERIA);
@@ -417,12 +431,13 @@ public class FilterListDialog extends Dialog {
FilterCriteria criteria;
for (int j = 0; j < globalFilters.size(); j++) {
- if (!(globalFilters.get(j) instanceof FilterCriteria))
+ if (!(globalFilters.get(j) instanceof FilterCriteria)) {
return;
+ }
criteria = (FilterCriteria) globalFilters.get(j);
DialogSettings subSection = (DialogSettings) section.getSection(FILTERS_LIST_CRITERIA + j);
- ;
+
if (subSection == null) {
subSection = (DialogSettings) section.addNewSection(FILTERS_LIST_CRITERIA + j);
}
@@ -430,6 +445,9 @@ public class FilterListDialog extends Dialog {
}
}
+ /**
+ * Deactivates the saved global filters.
+ */
public static void deactivateSavedGlobalFilters() {
// Deactivate all filters
List filters = getGlobalFilters();
@@ -440,4 +458,98 @@ public class FilterListDialog extends Dialog {
FilterListDialog.saveFiltersCriteria(filters);
}
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+ /**
+ * A class to map TableItems that can be toggled active or inactive and Criteria
+ */
+ protected class CriteriaTableItem {
+
+ /**
+ * The criteria reference
+ */
+ protected Criteria criteria;
+ /**
+ * The "positive" value.
+ */
+ protected boolean positive;
+ /**
+ * The loader class name
+ */
+ protected String loaderClassName;
+ /**
+ * The actual table item.
+ */
+ protected TableItem tableItem;
+
+ /**
+ * Constructor
+ *
+ * @param parent The parent table
+ * @param active_ true
if filter criteria is active else false
+ * @param positive_ true
for positive filter else false
+ * @param loaderClassName_ The loader class name
+ */
+ public CriteriaTableItem(Table parent, boolean active_, boolean positive_, String loaderClassName_) {
+ tableItem = new TableItem(parent, SWT.NONE);
+ tableItem.setData(this);
+ tableItem.setChecked(active_);
+ positive = positive_;
+ loaderClassName = loaderClassName_;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param parent The parent table
+ * @param active_ true
if filter criteria is active else false
+ * @param positive_ true
for positive filter else false
+ * @param loaderClassName_ The loader class name
+ * @param index The table item index
+ */
+ public CriteriaTableItem(Table parent, boolean checked_, boolean positive_, String loaderClassName_, int index) {
+ tableItem = new TableItem(parent, SWT.NONE, index);
+ tableItem.setChecked(checked_);
+ positive = positive_;
+ loaderClassName = loaderClassName_;
+ }
+
+ /**
+ * Sets the criteria.
+ *
+ * @param criteria_ The criteria to set
+ */
+ public void setCriteria(Criteria criteria_) {
+ criteria = criteria_;
+ tableItem.setText((positive ? SDMessages._59 : SDMessages._58) + " " + criteria.getExpression() + " " + criteria.getGraphNodeSummary(provider, loaderClassName)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Returns the criteria.
+ * @return the criteria
+ */
+ public Criteria getCriteria() {
+ return criteria;
+ }
+
+ /**
+ * Returns whether positive filtering is active or not.
+ *
+ * @return true
for positive filter else false
+ */
+ public boolean getPositive() {
+ return positive;
+ }
+
+ /**
+ * Returns the loader class name.
+ *
+ * @return the loader class name
+ */
+ public String getLoaderClassName() {
+ return loaderClassName;
+ }
+ }
+
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/MinMaxDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/MinMaxDialog.java
similarity index 68%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/MinMaxDialog.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/MinMaxDialog.java
index 812fa2f1a0..87ce865b41 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/MinMaxDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/MinMaxDialog.java
@@ -1,22 +1,24 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: MinMaxDialog.java,v 1.2 2008/01/24 02:28:51 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.util;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -30,40 +32,86 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
+ * Dialog box for entering minimum and maximum time range for time compression bar.
+ *
+ * @version 1.0
* @author sveyrier
+ * @author Bernd Hufmann
*
*/
public class MinMaxDialog extends Dialog {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Label for minimum.
+ */
protected Label minLabel;
-
+ /**
+ * Label for maximum.
+ */
protected Label maxLabel;
-
+ /**
+ * Label for scale
+ */
protected Label scaleLabel;
-
+ /**
+ * Label for precision.
+ */
protected Label precisionLabel;
-
+ /**
+ * Text field for minimum.
+ */
protected Text minText;
-
+ /**
+ * Text field for maximum.
+ */
protected Text maxText;
-
+ /**
+ * Text field for scale.
+ */
protected Text scaleText;
-
+ /**
+ * Text field for precision.
+ */
protected Text precisionText;
-
- SDWidget sdWidget;
-
- public MinMaxDialog(Shell s, SDWidget v) {
- super(s);
- sdWidget = v;
+ /**
+ * The sequence diagram widget reference.
+ */
+ protected SDWidget sdWidget;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+ /**
+ * Standard constructor.
+ * @param shell The shell
+ * @param viewer The sequence diagram widget reference.
+ */
+ public MinMaxDialog(Shell shell, SDWidget viewer) {
+ super(shell);
+ sdWidget = viewer;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /**
+ * Method to create a grid data base on horizontal span.
+ * @param span The horizontal span
+ * @return a grid data object
+ */
protected GridData newGridData(int span) {
GridData data = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
data.horizontalSpan = span;
return data;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
@Override
protected Control createDialogArea(Composite p) {
p.getShell().setText(SDMessages._123);
@@ -115,10 +163,12 @@ public class MinMaxDialog extends Dialog {
return parent;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
@Override
protected void okPressed() {
- // double min=0;
- // double max=0;
long min = 0;
long max = 0;
int scale = 0;
@@ -140,12 +190,19 @@ public class MinMaxDialog extends Dialog {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
createButton(parent, IDialogConstants.CLIENT_ID, SDMessages._126, false);
getButton(IDialogConstants.CLIENT_ID).addSelectionListener(new SelectionListener() {
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetSelected(SelectionEvent e) {
sdWidget.getFrame().resetCustomMinMax();
@@ -156,11 +213,14 @@ public class MinMaxDialog extends Dialog {
maxText.getParent().layout(true);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
-
+ // nothing to do
}
-
});
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/PagesDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/PagesDialog.java
similarity index 65%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/PagesDialog.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/PagesDialog.java
index 41b4acbddd..a9ec76505c 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/PagesDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/PagesDialog.java
@@ -1,16 +1,17 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: PagesDialog.java,v 1.4 2008/01/24 02:29:09 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import java.text.MessageFormat;
@@ -28,11 +29,19 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IViewPart;
/**
- * This is the filters list dialog.
- * It is associated to an SDView and to a ISDFilterProvider.
+ * Class implementation of the pages dialog.
+ *
+ * It is associated to an SDView and to a ISDAdvancedPagingProvider.
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public class PagesDialog extends Dialog {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
* viewer and provided are kept here as attributes
*/
@@ -40,62 +49,28 @@ public class PagesDialog extends Dialog {
protected TextArea currentPage;
protected Label totalPageComment;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
- * This is a Text Control that accepts only digits and ensures that bounds are respected
+ * Standard constructor
+ *
+ * @param view_ The sequence diagram view reference
+ * @param provider_ The paging provider reference
*/
- protected static class TextArea {
-
- protected Text text;
- int min, max;
-
- public TextArea(Composite parent) {
- text = new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.RIGHT);
- text.setTextLimit(10);
- }
-
- public void setValue(int v) {
- int value = Math.max(min, Math.min(max, v));
- text.setText(Integer.toString(value));
- }
-
- public int getValue() {
- int res;
- try {
- res = Integer.parseInt(text.getText());
- } catch (Exception e) {
- // ignored
- res = 0;
- }
- return Math.max(min, Math.min(max, res));
- }
-
- public void setBounds(int min_, int max_) {
- min = Math.max(0, min_);
- max = Math.max(min, max_);
- Integer tab[] = new Integer[2];
- tab[0] = Integer.valueOf(min);
- tab[1] = Integer.valueOf(max);
- text.setToolTipText(MessageFormat.format(SDMessages._69, (Object[]) tab));
- }
+ public PagesDialog(IViewPart view_, ISDAdvancedPagingProvider provider_) {
+ super(view_.getSite().getShell());
+ provider = provider_;
+ setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
}
- /**
- *
- */
- protected void updateComments() {
- int pages = Math.max(0, provider.pagesCount());
- String totalPageCommentText = SDMessages._70 + pages + " "; //$NON-NLS-1$
- if (pages == 0) {
- totalPageCommentText += SDMessages._71;
- } else if (pages == 1) {
- totalPageCommentText += SDMessages._72;
- } else {
- totalPageCommentText += SDMessages._73;
- }
- totalPageComment.setText(totalPageCommentText);
- }
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
- /**
+ /*
+ * (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
@@ -127,18 +102,9 @@ public class PagesDialog extends Dialog {
return ret;
}
- /**
- * @param view_
- * @param loader_
- */
- public PagesDialog(IViewPart view_, ISDAdvancedPagingProvider loader_) {
- super(view_.getSite().getShell());
- provider = loader_;
- setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Called when the dialog box ok button is pressed
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
public void okPressed() {
@@ -147,4 +113,93 @@ public class PagesDialog extends Dialog {
provider.pageNumberChanged(currentPageValue);
}
+ /**
+ * Updates the comments texts.
+ */
+ protected void updateComments() {
+ int pages = Math.max(0, provider.pagesCount());
+ String totalPageCommentText = SDMessages._70 + pages + " "; //$NON-NLS-1$
+ if (pages == 0) {
+ totalPageCommentText += SDMessages._71;
+ } else if (pages == 1) {
+ totalPageCommentText += SDMessages._72;
+ } else {
+ totalPageCommentText += SDMessages._73;
+ }
+ totalPageComment.setText(totalPageCommentText);
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+ /**
+ * This is a Text Control that accepts only digits and ensures that bounds are respected
+ */
+ protected static class TextArea {
+ /**
+ * The text field.
+ */
+ protected Text text;
+ /**
+ * The minimum page value
+ */
+ int min;
+ /**
+ * The maximum page value
+ */
+ int max;
+
+ /**
+ * Constructor
+ *
+ * @param parent The paren composite
+ */
+ public TextArea(Composite parent) {
+ text = new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.RIGHT);
+ text.setTextLimit(10);
+ }
+
+ /**
+ * Sets the page value.
+ *
+ * @param page The page value
+ */
+ public void setValue(int page) {
+ int value = Math.max(min, Math.min(max, page));
+ text.setText(Integer.toString(value));
+ }
+
+ /**
+ * Returns the page value.
+ *
+ * @return the page value
+ */
+ public int getValue() {
+ int res;
+ try {
+ res = Integer.parseInt(text.getText());
+ } catch (Exception e) {
+ // ignored
+ res = 0;
+ }
+ return Math.max(min, Math.min(max, res));
+ }
+
+ /**
+ * Sets the minimum and maximum page values.
+ *
+ * @param min_ A minimum page value
+ * @param max_ A maximum page value
+ */
+ public void setBounds(int min_, int max_) {
+ min = Math.max(0, min_);
+ max = Math.max(min, max_);
+ Integer tab[] = new Integer[2];
+ tab[0] = Integer.valueOf(min);
+ tab[1] = Integer.valueOf(max);
+ text.setToolTipText(MessageFormat.format(SDMessages._69, (Object[]) tab));
+ }
+ }
+
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDPrintDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialog.java
similarity index 58%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDPrintDialog.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialog.java
index 2b2a72ca53..d742a0ca1f 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDPrintDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialog.java
@@ -1,21 +1,23 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDPrintDialog.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.util;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -27,26 +29,61 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
/**
+ * This class implements a dialog box for collecting printing information.
+ *
+ * @version 1.0
* @author sveyrier
*/
public class SDPrintDialog extends Dialog {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence dialog widget reference.
+ */
protected SDWidget view;
-
+ /**
+ * Sequence dialog print dialog UI
+ */
protected SDPrintDialogUI dialogUI;
-
+ /**
+ * Error message to display.
+ */
protected String errorMessage = null;
+ /**
+ * A message label.
+ */
protected Label messageLabel = null;
+ /**
+ * Flag whether the page is complete or not
+ */
protected boolean isPageComplete = true;
- public SDPrintDialog(Shell s, SDWidget v) {
- super(s);
- view = v;
-
- dialogUI = new SDPrintDialogUI(s, view);
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Standard constructor
+ *
+ * @param shell Shell reference
+ * @param viewer Sequence diagram widget reference
+ */
+ public SDPrintDialog(Shell shell, SDWidget viewer) {
+ super(shell);
+ view = viewer;
+
+ dialogUI = new SDPrintDialogUI(shell, view);
dialogUI.setParentDialog(this);
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
@Override
protected Control createDialogArea(Composite p) {
p.getShell().setText(SDMessages._114);
@@ -54,7 +91,6 @@ public class SDPrintDialog extends Dialog {
dialogUI.createDialogArea(parent);
- // bug 195026
messageLabel = new Label(parent, SWT.NONE);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalSpan = 6;
@@ -63,7 +99,11 @@ public class SDPrintDialog extends Dialog {
return parent;
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
@Override
protected void okPressed() {
@@ -71,6 +111,10 @@ public class SDPrintDialog extends Dialog {
super.okPressed();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
@Override
protected void createButtonsForButtonBar(Composite parent) {
@@ -78,26 +122,39 @@ public class SDPrintDialog extends Dialog {
createButton(parent, IDialogConstants.CLIENT_ID, SDMessages._115, false);
getButton(IDialogConstants.CLIENT_ID).addSelectionListener(new SelectionListener() {
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetSelected(SelectionEvent e) {
dialogUI.printButtonSelected();
}
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
-
});
updateButtons();
}
+ /**
+ * @return the dialog UI
+ */
public SDPrintDialogUI getDialogUI() {
return dialogUI;
}
+ /**
+ * Sets the error message.
+ *
+ * @param message error message to set
+ */
public void setErrorMessage(String message) {
errorMessage = message;
if (messageLabel != null) {
@@ -109,11 +166,18 @@ public class SDPrintDialog extends Dialog {
}
}
+ /**
+ * Sets the page complete flag.
+ * @param complete whether page is complete or not
+ */
public void setPageComplete(boolean complete) {
isPageComplete = complete;
updateButtons();
}
+ /**
+ * Udates the button enable state.
+ */
public void updateButtons() {
Button okButton = getButton(IDialogConstants.OK_ID);
if (isPageComplete) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDPrintDialogUI.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java
similarity index 73%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDPrintDialogUI.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java
index 7297c9f24d..d537020798 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDPrintDialogUI.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java
@@ -1,16 +1,17 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDPrintDialogUI.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.util;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import java.text.MessageFormat;
import java.util.Arrays;
@@ -21,6 +22,7 @@ import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.GridUtil;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.DiagramToolTip;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.NGC;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
@@ -53,142 +55,268 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
+ * The class implements the actual print dialog UI for collecting printing data.
+ *
+ * @version 1.0
* @author sveyrier
*/
public class SDPrintDialogUI {
-
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The set horizontal pages number.
+ */
protected Button setHPagesNumber;
-
+ /**
+ * The set vertical pages number.
+ */
protected Button setVPagesNumber;
-
+ /**
+ * Flag whether to use current zoom or not.
+ */
protected Button useCurrentZoom;
-
+ /**
+ * Flag whether to print all pages or not
+ */
protected Button allPages;
-
+ /**
+ * Flag whether to print current page only
+ */
protected Button currentPage;
-
+ /**
+ * Button to select a page list.
+ */
protected Button pageList;
-
+ /**
+ * Button to select a page range.
+ */
protected Button pageRange;
-
+ /**
+ * Text field to enter from page.
+ */
protected Text fromPage;
-
+ /**
+ * Text field to enter to page.
+ */
protected Text toPage;
-
+ /**
+ * The sequence diagram widget reference.
+ */
protected SDWidget view;
-
+ /**
+ * Text field for number of horizontal pages
+ */
protected Text hPagesNum;
-
+ /**
+ * Text field for number of vertical pages
+ */
protected Text vPagesNum;
-
+ /**
+ * Text field for toal number of pages
+ */
protected Text totalPages;
-
+ /**
+ * A modify listener implementation to handle modifications.
+ */
protected ModifyListener modifyListener;
-
+ /**
+ * A selection listener implementation to handle selections.
+ */
protected SelectionListener selectionListener;
-
+ /**
+ * Local canvas displaying sequence diagram overview.
+ */
protected LocalSD overviewCanvas;
-
+ /**
+ * Number of pages
+ */
protected int nbPages = 0;
-
+ /**
+ * Number of selected pages.
+ */
protected int pageNum = -1;
-
+ /**
+ * Number of first page.
+ */
protected int firstPage = -1;
-
+ /**
+ * List of pages to print.
+ */
protected int pagesList[];
-
+ /**
+ * Values for dividing sequence diagram into pages.
+ */
protected float stepX, stepY, sTX, sTY;
-
- protected int from, to;
-
+ /**
+ * Page which to print from.
+ */
+ protected int from;
+ /**
+ * Page which to print to.
+ */
+ protected int to;
+ /**
+ * Flag for enabling multi-selection.
+ */
protected boolean multiSelection = false;
-
+ /**
+ * Flag for enabling area selection.
+ */
protected boolean areaSelection = false;
-
+ /**
+ * Flag for printing all.
+ */
protected boolean printAll;
+ /**
+ * Flag for printing current page only.
+ */
protected boolean printCurrent;
+ /**
+ * Flag for printing a selection of pages.
+ */
protected boolean printSelection;
+ /**
+ * Flag for printing a range of pages.
+ */
protected boolean printRange;
-
- protected int nbRows, nbLines;
-
+ /**
+ * Number of selected rows
+ */
+ protected int nbRows;
+ /**
+ * Number of selected lines
+ */
+ protected int nbLines;
+ /**
+ * The zoom factor.
+ */
protected float zoomFactor;
-
+ /**
+ * The printer data reference.
+ */
protected PrinterData printerData;
-
+ /**
+ * The diagram tooltip to show if necessary.
+ */
protected DiagramToolTip toolTip = null;
-
+ /**
+ * Label for current selection.
+ */
protected Label currentSelection;
-
+ /**
+ * The shell reference.
+ */
protected Shell shell;
-
+ /**
+ * Button to open printer dialog from OS.
+ */
protected Button printerDialog;
-
+ /**
+ * Flag for showoing print button.
+ */
protected boolean showPrintButton;
-
- int test = 3;
-
- // bug 195026
+ /**
+ * Test value
+ */
+ protected int test = 3;
+ /**
+ * Parent wizard page if used as wizard
+ */
protected WizardPage parentWizardPage = null;
+ /**
+ * Reference to parent print dialog.
+ */
protected SDPrintDialog parentDialog = null;
+ // ------------------------------------------------------------------------
+ // Helper Class
+ // ------------------------------------------------------------------------
+ /**
+ * Local sequence diagram widget used to display overview of sequence diagram to print.
+ * @version 1.0
+ */
protected class LocalSD extends SDWidget {
+ /**
+ * Constructor
+ * @param c Parent composite
+ * @param s Style bits
+ */
+ public LocalSD(Composite c, int s) {
+ super(c, s);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsHeight()
+ */
@Override
public int getContentsHeight() {
- if (view.getContentsHeight() > view.getContentsHeight())
+ if (view.getContentsHeight() > view.getContentsHeight()) {
return (int) (view.getVisibleHeight() / (float) test / view.zoomValue);
- else
- return (int) (super.getContentsHeight());
+ }
+ return (int) (super.getContentsHeight());
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#getContentsWidth()
+ */
@Override
public int getContentsWidth() {
- if (view.getVisibleWidth() > view.getContentsWidth())
+ if (view.getVisibleWidth() > view.getContentsWidth()) {
return (int) (view.getVisibleWidth() / (float) test / view.zoomValue);
- else
- return (int) (super.getContentsWidth());
- }
-
- public LocalSD(Composite c, int s) {
- super(c, s);
+ }
+ return (int) (super.getContentsWidth());
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
+ */
@Override
protected void contentsMouseHover(MouseEvent event) {
}
+ /**
+ * Creates page selection images.
+ *
+ * @param img - Overview image
+ * @param width -The width value
+ * @param stepX - Step X
+ * @param height - Height value
+ * @param stepY - Step Y
+ * @return new image
+ */
protected Image createPagesSelectionImages(Image img, int width, float stepX, int height, float stepY) {
Image over = new Image(super.getShell().getDisplay(), img.getImageData());
for (int pageIndex = 0; pageIndex < pagesList.length; pageIndex++) {
- /*
- * int line=pageNum/getPagesForSelection(); int row=pageNum%getPagesForSelection(); if (row!=0) line++;
- * else row=getPagesForSelection(); line--; row--; over=new
- * Image(super.getShell().getDisplay(),drawRegionSelected(img,new Rectangle(row*stepX,
- * line*stepY,stepX,stepY),new RGB(0,155,0)));
- */
int pageNum = pagesList[pageIndex];
+
if (getPagesForSelection() > 0 && pageNum > 0) {
int line = pageNum / getNbRow();
int row = pageNum % getNbRow();
- if (row != 0)
+ if (row != 0) {
line++;
- else
+ } else {
row = getNbRow();
+ }
line--;
row--;
Image toDel = over;
- if (overviewCanvas.isFocusControl())
+ if (overviewCanvas.isFocusControl()) {
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * overviewCanvas.zoomValue)), contentsToViewY((int) (line * stepY * overviewCanvas.zoomValue)),
((int) (stepX * overviewCanvas.zoomValue)), ((int) (stepY * overviewCanvas.zoomValue))), new RGB(0, 0, 128)));
- else
+ } else {
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * overviewCanvas.zoomValue)), contentsToViewY((int) (line * stepY * overviewCanvas.zoomValue)),
((int) (stepX * overviewCanvas.zoomValue)), ((int) (stepY * overviewCanvas.zoomValue))), new RGB(221, 208, 200)));
+ }
toDel.dispose();
}
}
@@ -199,10 +327,11 @@ public class SDPrintDialogUI {
if (getPagesForSelection() > 0 && pageNum > 0) {
int line = pageNum / getNbRow();
int row = pageNum % getNbRow();
- if (row != 0)
+ if (row != 0) {
line++;
- else
+ } else {
row = getNbRow();
+ }
line--;
row--;
@@ -216,36 +345,39 @@ public class SDPrintDialogUI {
GC imGC2 = new GC(over);
imGC2.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
NGC imGC = new NGC(overviewCanvas, imGC2);
- for (int i = 0, x = 0; x <= width && stepX > 0; i++, x = (int) (i * stepX))
+ for (int i = 0, x = 0; x <= width && stepX > 0; i++, x = (int) (i * stepX)) {
imGC.drawLine(x, 0, x, height);
+ }
- for (int j = 0, y = 0; y <= height && stepY > 0; j++, y = (int) (j * stepY))
+ for (int j = 0, y = 0; y <= height && stepY > 0; j++, y = (int) (j * stepY)) {
imGC.drawLine(0, y, width, y);
-
- // imGC2.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
- // // //imGC.drawLine(0, height, width, (int)(getVisibleHeight()/zoomValue));
- // imGC.fillRectangle(0,height,(int)(getVisibleWidth()/zoomValue),
- // (int)(getVisibleHeight()/zoomValue)-height);
+ }
imGC2.dispose();
imGC.dispose();
return over;
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
+ */
@Override
protected void drawContents(GC gc, int clipx, int clipy, int clipw, int cliph) {
- Image dbuffer = getDrawBuffer(gc);
+ Image dbuffer = getDrawBuffer();
computeStepXY();
Image d;
int lw = (int) (getContentsWidth() / zoomValue);
- if (getContentsWidth() < getVisibleWidth())
+ if (getContentsWidth() < getVisibleWidth()) {
lw = (int) (getVisibleWidth() / zoomValue);
+ }
int lh = (int) (getContentsHeight() / zoomValue);
- if (getContentsHeight() < getVisibleHeight())
+ if (getContentsHeight() < getVisibleHeight()) {
lh = (int) (getVisibleHeight() / zoomValue);
+ }
d = createPagesSelectionImages(dbuffer, lw, stepX, lh, stepY);
if (!isEnabled()) {
@@ -269,56 +401,74 @@ public class SDPrintDialogUI {
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
+ */
@Override
protected void keyPressedEvent(KeyEvent e) {
- if (e.keyCode == SWT.CTRL)
+ if (e.keyCode == SWT.CTRL) {
multiSelection = true;
- if (e.keyCode == SWT.SHIFT)
+ }
+ if (e.keyCode == SWT.SHIFT) {
areaSelection = true;
+ }
if (e.keyCode == SWT.ARROW_DOWN) {
- if (pageNum + getNbRow() <= maxNumOfPages())
+ if (pageNum + getNbRow() <= maxNumOfPages()) {
pageNum += getNbRow();
+ }
int line = pageNum / getNbRow();
int row = pageNum % getNbRow();
- if (row == 0)
+ if (row == 0) {
line--;
- if ((line + 1) * stepY > (overviewCanvas.getContentsY() + overviewCanvas.getVisibleHeight()) / overviewCanvas.zoomValue)
+ }
+ if ((line + 1) * stepY > (overviewCanvas.getContentsY() + overviewCanvas.getVisibleHeight()) / overviewCanvas.zoomValue) {
overviewCanvas.scrollBy(0, (int) (stepY * overviewCanvas.zoomValue));
+ }
}
if (e.keyCode == SWT.ARROW_UP) {
- if (pageNum - getNbRow() > 0)
+ if (pageNum - getNbRow() > 0) {
pageNum -= getNbRow();
+ }
int line = pageNum / getNbRow();
int row = pageNum % getNbRow();
- if (row == 0)
+ if (row == 0) {
line--;
- if ((line) * stepY <= overviewCanvas.getContentsY() / overviewCanvas.zoomValue)
+ }
+ if ((line) * stepY <= overviewCanvas.getContentsY() / overviewCanvas.zoomValue) {
overviewCanvas.scrollBy(0, -(int) (stepY * overviewCanvas.zoomValue));
+ }
}
if (e.keyCode == SWT.ARROW_LEFT) {
- if ((pageNum - 2) / getNbRow() == (pageNum - 1) / getNbRow() && pageNum > 1)
+ if ((pageNum - 2) / getNbRow() == (pageNum - 1) / getNbRow() && pageNum > 1) {
pageNum--;
+ }
int row = pageNum % getNbRow();
- if ((row - 1) * stepX < (overviewCanvas.getContentsX()) / overviewCanvas.zoomValue)
+ if ((row - 1) * stepX < (overviewCanvas.getContentsX()) / overviewCanvas.zoomValue) {
overviewCanvas.scrollBy(-(int) (stepX * overviewCanvas.zoomValue), 0);
+ }
}
if (e.keyCode == SWT.ARROW_RIGHT) {
- if ((pageNum - 1) / getNbRow() == pageNum / getNbRow())
+ if ((pageNum - 1) / getNbRow() == pageNum / getNbRow()) {
pageNum++;
+ }
int row = pageNum % getNbRow();
- if (row == 0)
+ if (row == 0) {
row = getNbRow();
- if ((row) * stepX > (overviewCanvas.getContentsX() + overviewCanvas.getVisibleWidth()) / overviewCanvas.zoomValue)
+ }
+ if ((row) * stepX > (overviewCanvas.getContentsX() + overviewCanvas.getVisibleWidth()) / overviewCanvas.zoomValue) {
overviewCanvas.scrollBy((int) (stepX * overviewCanvas.zoomValue), 0);
+ }
}
if (e.keyCode == 32 && pageNum > -1) {
Arrays.sort(pagesList);
int pos = Arrays.binarySearch(pagesList, pageNum);
- if (pos < 0)
+ if (pos < 0) {
addToPagesList(pageNum);
- else
+ } else {
removeFromPagesList(pageNum);
+ }
}
if (!areaSelection && !multiSelection) {
@@ -329,17 +479,19 @@ public class SDPrintDialogUI {
pagesList = new int[0];
int line1 = firstPage / getNbRow();
int row1 = firstPage % getNbRow();
- if (row1 != 0)
+ if (row1 != 0) {
line1++;
- else
+ } else {
row1 = getNbRow();
+ }
int line2 = pageNum / getNbRow();
int row2 = pageNum % getNbRow();
- if (row2 != 0)
+ if (row2 != 0) {
line2++;
- else
+ } else {
row2 = getNbRow();
+ }
int temp;
if (line1 > line2) {
@@ -354,23 +506,34 @@ public class SDPrintDialogUI {
row1 = temp;
}
- for (int i = row1 - 1; i < row2; i++)
- for (int j = line1 - 1; j < line2; j++)
+ for (int i = row1 - 1; i < row2; i++) {
+ for (int j = line1 - 1; j < line2; j++) {
addToPagesList(i + j * getNbRow() + 1);
-
+ }
+ }
}
displayPageNum();
overviewCanvas.redraw();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
+ */
@Override
protected void keyReleasedEvent(KeyEvent e) {
- if (e.keyCode == SWT.CTRL)
+ if (e.keyCode == SWT.CTRL) {
multiSelection = false;
- if (e.keyCode == SWT.SHIFT)
+ }
+ if (e.keyCode == SWT.SHIFT) {
areaSelection = false;
+ }
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget#contentsMouseDownEvent(org.eclipse.swt.events.MouseEvent)
+ */
@Override
protected void contentsMouseDownEvent(MouseEvent event) {
@@ -387,33 +550,37 @@ public class SDPrintDialogUI {
return;
}
- if (!areaSelection)
+ if (!areaSelection) {
firstPage = pageNum;
+ }
if ((pageNum != -1) && (multiSelection)) {
Arrays.sort(pagesList);
int pos = Arrays.binarySearch(pagesList, pageNum);
- if (pos < 0)
+ if (pos < 0) {
addToPagesList(pageNum);
- else
+ } else {
removeFromPagesList(pageNum);
+ }
} else if ((pageNum != -1) && (areaSelection) && (firstPage != -1)) {
pagesList = new int[0];
int line1 = firstPage / getNbRow();
int row1 = firstPage % getNbRow();
- if (row1 != 0)
+ if (row1 != 0) {
line1++;
- else
+ } else {
row1 = getNbRow();
+ }
int line2 = pageNum / getNbRow();
int row2 = pageNum % getNbRow();
- if (row2 != 0)
+ if (row2 != 0) {
line2++;
- else
+ } else {
row2 = getNbRow();
+ }
int temp;
if (line1 > line2) {
@@ -428,24 +595,35 @@ public class SDPrintDialogUI {
row1 = temp;
}
- for (int i = row1 - 1; i < row2; i++)
- for (int j = line1 - 1; j < line2; j++)
+ for (int i = row1 - 1; i < row2; i++) {
+ for (int j = line1 - 1; j < line2; j++) {
addToPagesList(i + j * getNbRow() + 1);
+ }
+ }
} else {
pagesList = new int[1];
pagesList[0] = pageNum;
}
- if ((event.stateMask & SWT.CTRL) != 0)
+ if ((event.stateMask & SWT.CTRL) != 0) {
multiSelection = true;
+ }
displayPageNum();
redraw();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
+ */
@Override
protected void contentsMouseMoveEvent(MouseEvent e) {
toolTip.hideToolTip();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#resizeContents(int, int)
+ */
@Override
public void resizeContents(int _w, int _h) {
super.resizeContents(_w, _h);
@@ -453,14 +631,27 @@ public class SDPrintDialogUI {
}
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param s The shell reference
+ * @param v The sequence diagram widget reference
+ */
public SDPrintDialogUI(Shell s, SDWidget v) {
-
this(s, v, false);
-
}
-
+
+ /**
+ * Constructor
+ *
+ * @param s The shell reference
+ * @param v The sequence diagram widget reference
+ * @param showPrintBtn Flag for showing print buttons
+ */
public SDPrintDialogUI(Shell s, SDWidget v, boolean showPrintBtn) {
-
setShell(s);
view = v;
showPrintButton = showPrintBtn;
@@ -487,8 +678,9 @@ public class SDPrintDialogUI {
currentPage.setSelection(false);
allPages.setSelection(true);
}
- if (hPagesNum.getText() == "") //$NON-NLS-1$
+ if (hPagesNum.getText() == "") { //$NON-NLS-1$
hPagesNum.setText("1"); //$NON-NLS-1$
+ }
}
if (setVPagesNumber.getSelection()) {
hPagesNum.setEnabled(false);
@@ -497,8 +689,9 @@ public class SDPrintDialogUI {
currentPage.setSelection(false);
allPages.setSelection(true);
}
- if (vPagesNum.getText() == "") //$NON-NLS-1$
+ if (vPagesNum.getText() == "") { //$NON-NLS-1$
vPagesNum.setText("1"); //$NON-NLS-1$
+ }
}
if (currentPage.getSelection() || allPages.getSelection() || pageList.getSelection()) {
fromPage.setEnabled(false);
@@ -529,6 +722,10 @@ public class SDPrintDialogUI {
overviewCanvas.update();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
pagesList = new int[0];
@@ -539,7 +736,10 @@ public class SDPrintDialogUI {
};
modifyListener = new ModifyListener() {
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
@Override
public void modifyText(ModifyEvent e) {
pagesList = new int[0];
@@ -551,12 +751,28 @@ public class SDPrintDialogUI {
};
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Creates new grid data object.
+ *
+ * @param span horizontal span.
+ * @return grid data
+ */
protected GridData newGridData(int span) {
GridData data = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
data.horizontalSpan = span;
return data;
}
+ /**
+ * Creates the dialog area.
+ *
+ * @param parent The parent composite
+ * @return dialog control
+ */
public Control createDialogArea(Composite parent) {
GridLayout parentLayout = new GridLayout();
@@ -621,10 +837,11 @@ public class SDPrintDialogUI {
// seqDiagLayoutData.horizontalAlignment=GridData.HORIZONTAL_ALIGN_FILL;
overviewCanvas.setLayoutData(seqDiagLayoutData);
// overviewCanvas.resizeContents(100,100);
- if (view.getContentsWidth() < view.getVisibleWidth() && view.getContentsHeight() < view.getVisibleHeight())
+ if (view.getContentsWidth() < view.getVisibleWidth() && view.getContentsHeight() < view.getVisibleHeight()) {
test = 3;
- else
+ } else {
test = 10;
+ }
overviewCanvas.setFrame(view.getFrame(), true);
overviewCanvas.zoomValue = (float) 1 / test;
overviewCanvas.setCornerControl(null);
@@ -633,17 +850,21 @@ public class SDPrintDialogUI {
if (view.getVisibleWidth() < view.getContentsWidth()) {
seqDiagLayoutData.widthHint = overviewCanvas.getContentsWidth() / test;
- if (seqDiagLayoutData.widthHint > Display.getDefault().getClientArea().width / 4)
+ if (seqDiagLayoutData.widthHint > Display.getDefault().getClientArea().width / 4) {
seqDiagLayoutData.widthHint = Display.getDefault().getClientArea().width / 4;
- } else
+ }
+ } else {
seqDiagLayoutData.widthHint = overviewCanvas.getFrame().getWidth() / test + 15;
+ }
if (view.getVisibleHeight() < view.getContentsHeight()) {
seqDiagLayoutData.heightHint = overviewCanvas.getContentsHeight() / test;
- if (seqDiagLayoutData.heightHint > Display.getDefault().getClientArea().width / 4)
+ if (seqDiagLayoutData.heightHint > Display.getDefault().getClientArea().width / 4) {
seqDiagLayoutData.heightHint = Display.getDefault().getClientArea().width / 4;
- } else
+ }
+ } else {
seqDiagLayoutData.heightHint = overviewCanvas.getFrame().getHeight() / test;
+ }
overviewCanvas.setEnabled(false);
@@ -689,24 +910,36 @@ public class SDPrintDialogUI {
toolTip = new DiagramToolTip(overviewCanvas);
overviewCanvas.getViewControl().addMouseTrackListener(new MouseTrackListener() {
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
+ */
@Override
public void mouseEnter(MouseEvent e) {
toolTip.hideToolTip();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
+ */
@Override
public void mouseExit(MouseEvent e) {
toolTip.hideToolTip();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
+ */
@Override
public void mouseHover(MouseEvent e) {
int x1 = (int) (overviewCanvas.viewToContentsX(e.x) / overviewCanvas.zoomValue / stepX);
int x2 = (int) (overviewCanvas.viewToContentsY(e.y) / overviewCanvas.zoomValue / stepY);
int num = x1 + x2 * getNbRow() + 1;
- if (num > maxNumOfPages())
+ if (num > maxNumOfPages()) {
return;
+ }
if (num > 0) {
toolTip.showToolTip(String.valueOf(num));
displayPageNum();
@@ -719,22 +952,32 @@ public class SDPrintDialogUI {
});
overviewCanvas.addTraverseListener(new TraverseListener() {
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
+ */
@Override
public void keyTraversed(TraverseEvent e) {
- if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))
+ if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
e.doit = true;
+ }
}
-
});
overviewCanvas.addFocusListener(new FocusListener() {
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
+ */
@Override
public void focusGained(FocusEvent e) {
overviewCanvas.redraw();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
@Override
public void focusLost(FocusEvent e) {
overviewCanvas.redraw();
@@ -757,12 +1000,20 @@ public class SDPrintDialogUI {
printerDialog.addSelectionListener(new SelectionListener() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetSelected(SelectionEvent e) {
printButtonSelected();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
@@ -775,6 +1026,10 @@ public class SDPrintDialogUI {
return parent;
}
+ /**
+ * Get number of pages for selection.
+ * @return number of pages for selection.
+ */
public int getPagesForSelection() {
return nbPages;
}
@@ -813,6 +1068,13 @@ public class SDPrintDialogUI {
return true;
}
+ /**
+ * Draws region that was selected
+ * @param img The corresponding image
+ * @param r The selected rectangle.
+ * @param color The color to use for selection
+ * @return
+ */
public ImageData drawRegionSelected(Image img, Rectangle r, RGB color) {
ImageData id = img.getImageData();
for (int a = 0; a < r.width && r.x + a < id.width; a++) {
@@ -826,15 +1088,24 @@ public class SDPrintDialogUI {
return id;
}
+ /**
+ * Combines two RGB colors.
+ * @param front The front color
+ * @param back The back color
+ * @return new RGB color
+ */
public static RGB combine(RGB front, RGB back) {
int _af = 128;
- if (_af == 1)
+ if (_af == 1) {
return front;
- if (_af == 0)
+ }
+ if (_af == 0) {
return back;
+ }
int _ab = 200;
- if (_ab == 0)
+ if (_ab == 0) {
return front;
+ }
double af = (_af) / 255.0;
double rf = front.red;
@@ -854,6 +1125,9 @@ public class SDPrintDialogUI {
return new RGB(r, g, b);
}
+ /**
+ * Computes value for X coordinates step and Y coordinates step.
+ */
protected void computeStepXY() {
float cw = overviewCanvas.getContentsWidth() / overviewCanvas.zoomValue;
float ch = overviewCanvas.getContentsHeight() / overviewCanvas.zoomValue;
@@ -882,8 +1156,9 @@ public class SDPrintDialogUI {
float z1 = view.getContentsWidth() / (cw);
stepX = ((float) view.getVisibleWidth() / z1);
nbPages = Math.round(cw / stepX);
- if (nbPages == 0)
+ if (nbPages == 0) {
nbPages = 1;
+ }
int pw = printer.getClientArea().width;
int ph = printer.getClientArea().height;
float z2 = pw / ((float) view.getContentsWidth() / nbPages);
@@ -897,15 +1172,23 @@ public class SDPrintDialogUI {
sTX = stepX * (view.getContentsWidth() / cw);
sTY = stepY * (view.getContentsHeight() / ch);
float rat = 1;
- if ((view.getVisibleWidth() > view.getContentsWidth()) && (setVPagesNumber.getSelection() || setHPagesNumber.getSelection()))
+ if ((view.getVisibleWidth() > view.getContentsWidth()) && (setVPagesNumber.getSelection() || setHPagesNumber.getSelection())) {
rat = (float) view.getVisibleWidth() / (float) view.getContentsWidth();
+ }
zoomFactor = (overviewCanvas.getContentsWidth() / cw) / overviewCanvas.getZoomFactor() * rat;// /view.getZoomFactor();
}
+ /**
+ * @return the pages list.
+ */
public int[] getPageList() {
return Arrays.copyOf(pagesList, pagesList.length);
}
+ /**
+ * Adds a page to pages list.
+ * @param num
+ */
public void addToPagesList(int num) {
int temp[] = new int[pagesList.length + 1];
System.arraycopy(pagesList, 0, temp, 0, pagesList.length);
@@ -914,6 +1197,10 @@ public class SDPrintDialogUI {
System.arraycopy(temp, 0, pagesList, 0, temp.length);
}
+ /**
+ * Removes a page from the pages list.
+ * @param num
+ */
public void removeFromPagesList(int num) {
int pos = Arrays.binarySearch(pagesList, num);
int temp[] = new int[pagesList.length - 1];
@@ -923,85 +1210,127 @@ public class SDPrintDialogUI {
System.arraycopy(temp, 0, pagesList, 0, temp.length);
}
+ /**
+ * @return maximum number of pages.
+ */
public int maxNumOfPages() {
int max = getNbRow() * getNbLines();
return max;
}
+ /**
+ * @return number of rows.
+ */
public int getNbRow() {
if (!setHPagesNumber.isDisposed()) {
int cw = (int) (overviewCanvas.getContentsWidth() / overviewCanvas.zoomValue);
int row = 1;
if (stepX != 0) {
row = (int) (cw / stepX);
- if (setHPagesNumber.getSelection())
+ if (setHPagesNumber.getSelection()) {
row = Math.round((float) cw / stepX);
- else if ((cw % stepX != 0))
+ } else if ((cw % stepX != 0)) {
row++;
+ }
}
nbRows = row;
}
return nbRows;
}
+ /**
+ * @return number of lines
+ */
public int getNbLines() {
if (!setVPagesNumber.isDisposed()) {
int ch = (int) (overviewCanvas.getContentsHeight() / overviewCanvas.zoomValue);
int line = 1;
if (stepY != 0) {
line = (int) (ch / stepY);
- if (setVPagesNumber.getSelection())
+ if (setVPagesNumber.getSelection()) {
line = Math.round((float) ch / stepY);
- else if (ch % stepY != 0)
+ } else if (ch % stepY != 0) {
line++;
+ }
}
nbLines = line;
}
return nbLines;
}
+ /**
+ * @return whether to print all pages or not.
+ */
public boolean printAll() {
return printAll;
}
+ /**
+ * @return whether to print only current page.
+ */
public boolean printCurrent() {
return printCurrent;
}
+ /**
+ * @return whether to print selected pages.
+ */
public boolean printSelection() {
return printSelection;
}
-
+
+ /**
+ * @return whether to print range of pages.
+ */
public boolean printRange() {
return printRange;
}
+ /**
+ * @return step in X direction
+ */
public float getStepX() {
return sTX;
}
+ /**
+ * @return step in Y direction
+ */
public float getStepY() {
return sTY;
}
+ /**
+ * @return zoom factor
+ */
public float getZoomFactor() {
return zoomFactor;
}
- // public abstract void createButtonsForButtonBar(Composite parent);
-
+ /**
+ * @return printer data reference
+ */
public PrinterData getPrinterData() {
return printerData;
}
+ /**
+ * @return page number to start printing from
+ */
public int getFrom() {
return from;
}
+ /**
+ * @return page number to print to
+ */
public int getTo() {
return to;
}
+ /**
+ * Displays current number of pages
+ */
protected void displayPageNum() {
if (pageNum > 0) {
String message = MessageFormat.format(SDMessages._117, new Object[] { Integer.valueOf(pageNum) });
@@ -1010,22 +1339,34 @@ public class SDPrintDialogUI {
}
}
+ /**
+ * @return the shell reference.
+ */
public Shell getShell() {
return shell;
}
+ /**
+ * @param shell The shell reference.
+ */
public void setShell(Shell shell) {
this.shell = shell;
}
+ /**
+ * Handle selection of print button.
+ */
public void printButtonSelected() {
PrintDialog printer = new PrintDialog(getShell());
- if (allPages.getSelection())
+ if (allPages.getSelection()) {
printer.setScope(PrinterData.ALL_PAGES);
- if (currentPage.getSelection())
+ }
+ if (currentPage.getSelection()) {
printer.setScope(PrinterData.SELECTION);
- if (pageList.getSelection())
+ }
+ if (pageList.getSelection()) {
printer.setScope(PrinterData.SELECTION);
+ }
if (pageRange.getSelection()) {
printer.setScope(PrinterData.PAGE_RANGE);
from = Integer.valueOf(fromPage.getText()).intValue();
@@ -1062,14 +1403,27 @@ public class SDPrintDialogUI {
overviewCanvas.redraw();
}
+ /**
+ * Sets parent wizard page
+ *
+ * @param parent The parent wizard page
+ */
public void setParentWizardPage(WizardPage parent) {
parentWizardPage = parent;
}
+ /**
+ * Sets the parent dialog box.
+ *
+ * @param parent The parent dialog box.
+ */
public void setParentDialog(SDPrintDialog parent) {
parentDialog = parent;
}
+ /**
+ * Updates the printer status
+ */
protected void updatePrinterStatus() {
if (parentWizardPage != null) {
// used in the wizard dialog
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/SearchFilterDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SearchFilterDialog.java
similarity index 79%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/SearchFilterDialog.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SearchFilterDialog.java
index 52b421202c..4b6f60c4c4 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/SearchFilterDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SearchFilterDialog.java
@@ -1,16 +1,17 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SearchFilterDialog.java,v 1.4 2008/01/24 02:29:09 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import java.util.ArrayList;
import java.util.List;
@@ -41,37 +42,67 @@ import org.eclipse.swt.widgets.TabFolder;
*/
public class SearchFilterDialog extends Dialog {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The find criteria property name
+ */
protected static final String FIND_CRITERIA = "findCriteria"; //$NON-NLS-1$
+ /**
+ * The find expression list property name
+ */
protected static final String FIND_EXPRESSION_LIST = "findExpressionList"; //$NON-NLS-1$
+ /**
+ * The filter criteria poperty name
+ */
protected static final String FILTER_CRITERIA = "filterCriteria"; //$NON-NLS-1$
+ /**
+ * The filter expression list property name
+ */
protected static final String FILTER_EXPRESSION_LIST = "filterExpressionList"; //$NON-NLS-1$
+ /**
+ * The maximum number of expressions stored.
+ */
protected static final int MAX_EXPRESSION_LIST = 7;
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
/**
- * viewer
+ * The sequence diagram view reference.
*/
protected SDView viewer = null;
/**
- * tab with the controls for a Criteria
+ * The tab with the controls for a Criteria
*/
protected TabFolder tab = null;
/**
- * Criteria updated by this dialog
+ * The Criteria updated by this dialog
*/
protected Criteria criteria = null;
/**
- * find/filter provider telling which graph nodes are supported
+ * The find/filter provider telling which graph nodes are supported
*/
protected ISDGraphNodeSupporter provider = null;
/**
- * okText is the text for the Ok button and title is the title of the dialog.
- * Both depend on the usage that is done of this dialog (find or filter).
+ * The okText is the text for the Ok button and title is the title of the dialog.
+ * Both depend (okText and title (below)) on the usage that is done of this dialog
+ * (find or filter).
*/
- protected String okText, title;
+ protected String okText;
+
+ /**
+ * The title is the title of the dialog.
+ * Both depend (okText and title) on the usage that is done of this dialog
+ * (find or filter).
+ */
+ protected String title;
/**
* List of string expressions that have been searched already
@@ -83,36 +114,46 @@ public class SearchFilterDialog extends Dialog {
*/
protected boolean find;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Standard constructor
+ *
+ * @param view_ A sequence diagram view reference
+ * @param provider_ A graph node supporter provider
+ * @param filter_ A flag to indicate filtering (true) or finding (false)
+ * @param style Style bits
+ */
+ public SearchFilterDialog(SDView view_, ISDGraphNodeSupporter provider_, boolean filter_, int style) {
+ super(view_.getSDWidget().getShell());
+ setShellStyle(SWT.DIALOG_TRIM | style);
+ provider = provider_;
+ viewer = view_;
+ find = !filter_;
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
public Control createDialogArea(Composite arg0) {
- if (find)
+ if (find) {
expressionList = TmfUiPlugin.getDefault().getDialogSettings().getArray(FIND_EXPRESSION_LIST);
- else
+ } else {
expressionList = TmfUiPlugin.getDefault().getDialogSettings().getArray(FILTER_EXPRESSION_LIST);
+ }
if (expressionList == null) {
expressionList = new String[0];
}
return new TabContents(arg0, provider, getButton(IDialogConstants.OK_ID), expressionList);
}
- /**
- * @param view_
- * @param provider_
- * @param filter_
- * @param style
- */
- public SearchFilterDialog(SDView view_, ISDGraphNodeSupporter provider_, boolean filter_, int style) {
- super(view_.getSDWidget().getShell());
- setShellStyle(SWT.DIALOG_TRIM | style);
- provider = provider_;
- viewer = view_;
- find = !filter_;
- }
-
/**
* Open the dialog box
*/
@@ -120,8 +161,10 @@ public class SearchFilterDialog extends Dialog {
public int open() {
create();
- if (criteria == null)
+ if (criteria == null) {
loadCriteria();
+ }
+
if (criteria == null) {
criteria = new Criteria();
criteria.setLifeLineSelected(provider.isNodeSupported(ISDGraphNodeSupporter.LIFELINE));
@@ -164,14 +207,15 @@ public class SearchFilterDialog extends Dialog {
}
/**
- *
+ * Loads criteria from the dialog settings which are saved in the workspace.
*/
@SuppressWarnings("rawtypes")
protected void loadCriteria() {
String CRITERIA = FIND_CRITERIA;
- if (!find)
+ if (!find) {
CRITERIA = FILTER_CRITERIA;
+ }
DialogSettings section = (DialogSettings) TmfUiPlugin.getDefault().getDialogSettings().getSection(CRITERIA);
List selection = viewer.getSDWidget().getSelection();
@@ -202,8 +246,10 @@ public class SearchFilterDialog extends Dialog {
}
/**
- * Called when the dialog box ok button is pressed and call back the appropriate action provider (ISDFilterProvider
- * or ISDFindProvider)
+ * Called when the dialog box ok button is pressed and calls back
+ * the appropriate action provider (ISDFilterProvider or ISDFindProvider).
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
public void okPressed() {
@@ -219,9 +265,10 @@ public class SearchFilterDialog extends Dialog {
}
}
- /**
- *
- */
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+ */
@Override
public void cancelPressed() {
if (find) {
@@ -235,7 +282,7 @@ public class SearchFilterDialog extends Dialog {
}
/**
- *
+ * Saves the criteria to the dialog settings within the workspace.
*/
public void saveCriteria() {
String CRITERIA = FIND_CRITERIA;
@@ -272,14 +319,18 @@ public class SearchFilterDialog extends Dialog {
}
/**
- *
+ * Returns the criteria
+ *
+ * @return the criteria
*/
public Criteria getCriteria() {
return criteria;
}
/**
- * @param criteria_
+ * Sets the criteria.
+ *
+ * @param criteria_ the criteria to set.
*/
public void setCriteria(Criteria criteria_) {
criteria = criteria_;
@@ -302,14 +353,17 @@ public class SearchFilterDialog extends Dialog {
}
/**
+ * Returns the tab content reference.
+ *
* @return the tab content
*/
protected TabContents getTabContents() {
TabContents content = null;
- if (tab == null)
+ if (tab == null) {
content = (TabContents) getDialogArea();
- else
+ } else {
content = (TabContents) tab.getSelection()[0].getControl();
+ }
return content;
}
@@ -317,7 +371,7 @@ public class SearchFilterDialog extends Dialog {
* Initialize the dialog with the settings of an existing Criteria
* Criteria must not be null and the TabContents must have been created
*
- * @param from
+ * @param from the criteria to copy from
*/
public void copyFromCriteria(Criteria from) {
TabContents content = getTabContents();
@@ -334,14 +388,18 @@ public class SearchFilterDialog extends Dialog {
}
/**
- * @param okText_
+ * Sets the text to be used for the ok button
+ *
+ * @param okText_ text to set
*/
public void setOkText(String okText_) {
okText = okText_;
}
/**
- * @param title_
+ * Sets the title to be used for the dialog box.
+ *
+ * @param title_ The title to set
*/
public void setTitle(String title_) {
title = title_;
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/TabContents.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/TabContents.java
similarity index 77%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/TabContents.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/TabContents.java
index 8dd468502b..1fe5e67879 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/widgets/TabContents.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/TabContents.java
@@ -1,16 +1,17 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: TabContents.java,v 1.3 2008/01/24 02:29:09 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
@@ -28,58 +29,73 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
/**
- * Here are the controls that allows to create or update a find or filter Criteria.
+ * Class implementation contains the controls that allows to create or update a find or filter Criteria.
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public class TabContents extends Composite {
- protected class GraphNodeTypeListener implements SelectionListener {
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // Nothing to do
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateOkButton();
- }
-
- }
-
- protected class ExpressionListener implements ModifyListener {
- /**
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- @Override
- public void modifyText(ModifyEvent e) {
- // System.err.println("modifyText: "+e.getSource());
- updateOkButton();
- }
- }
-
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * A graph node type listener implementation.
+ */
GraphNodeTypeListener graphNodeTypeListener = null;
+ /**
+ * A expression listener implementation.
+ */
ExpressionListener expressionListener = null;
-
+ /**
+ * The button for lifelines.
+ */
Button lifelineButton = null;
+ /**
+ * The button for stops.
+ */
Button stopButton = null;
+ /**
+ * The button for synchronous messages
+ */
Button synMessageButton = null;
+ /**
+ * The button for synchronous return messages
+ */
Button synMessageReturnButton = null;
+ /**
+ * The button for asynchronous messages
+ */
Button asynMessageButton = null;
+ /**
+ * The button for asynchronous return messages
+ */
Button asynMessageReturnButton = null;
-
+ /**
+ * The search text combo box.
+ */
Combo searchText = null;
+ /**
+ * The group for selection kind.
+ */
Group kindSelection = null;
+ /**
+ * The button for case sensitive expressions.
+ */
Button caseSensitive = null;
-
+ /**
+ * The label for the result string.
+ */
Label result = null;
-
+ /**
+ * The button for notifying parent about valid data.
+ */
Button parentOkButton = null;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
* Creates the dialog contents
*
@@ -88,8 +104,6 @@ public class TabContents extends Composite {
* @param okButton of the dialog (to be enabled/disabled)
* @param expressionList list of strings already searched for
*/
- /**
- */
public TabContents(Composite parent, ISDGraphNodeSupporter provider, Button okButton, String[] expressionList) {
super(parent, SWT.NONE);
setOkButton(okButton);
@@ -140,10 +154,11 @@ public class TabContents extends Composite {
if (provider != null && provider.isNodeSupported(ISDGraphNodeSupporter.LIFELINE)) {
lifelineButton = new Button(kindSelection, SWT.CHECK);
String nodeName = provider.getNodeName(ISDGraphNodeSupporter.LIFELINE, null);
- if (nodeName != null)
+ if (nodeName != null) {
lifelineButton.setText(nodeName);
- else
+ } else {
lifelineButton.setText(SDMessages._28);
+ }
lifelineButton.setEnabled(true);
lifelineButton.addSelectionListener(graphNodeTypeListener);
}
@@ -152,10 +167,12 @@ public class TabContents extends Composite {
// Create the stop check button
stopButton = new Button(kindSelection, SWT.CHECK);
String nodeName = provider.getNodeName(ISDGraphNodeSupporter.STOP, null);
- if (nodeName != null)
+ if (nodeName != null) {
stopButton.setText(nodeName);
- else
+ } else {
stopButton.setText(SDMessages._29);
+ }
+
stopButton.setEnabled(true);
stopButton.addSelectionListener(graphNodeTypeListener);
}
@@ -164,10 +181,11 @@ public class TabContents extends Composite {
// Create the synchronous message check button
synMessageButton = new Button(kindSelection, SWT.CHECK);
String nodeName = provider.getNodeName(ISDGraphNodeSupporter.SYNCMESSAGE, null);
- if (nodeName != null)
+ if (nodeName != null) {
synMessageButton.setText(nodeName);
- else
+ } else {
synMessageButton.setText(SDMessages._30);
+ }
synMessageButton.setEnabled(true);
synMessageButton.addSelectionListener(graphNodeTypeListener);
}
@@ -176,10 +194,11 @@ public class TabContents extends Composite {
// Create the synchronous message return check button
synMessageReturnButton = new Button(kindSelection, SWT.CHECK);
String nodeName = provider.getNodeName(ISDGraphNodeSupporter.SYNCMESSAGERETURN, null);
- if (nodeName != null)
+ if (nodeName != null) {
synMessageReturnButton.setText(nodeName);
- else
+ } else {
synMessageReturnButton.setText(SDMessages._31);
+ }
synMessageReturnButton.setEnabled(true);
synMessageReturnButton.addSelectionListener(graphNodeTypeListener);
}
@@ -188,10 +207,11 @@ public class TabContents extends Composite {
// Create the asynchronous message check button
asynMessageButton = new Button(kindSelection, SWT.CHECK);
String nodeName = provider.getNodeName(ISDGraphNodeSupporter.ASYNCMESSAGE, null);
- if (nodeName != null)
+ if (nodeName != null) {
asynMessageButton.setText(nodeName);
- else
+ } else {
asynMessageButton.setText(SDMessages._32);
+ }
asynMessageButton.setEnabled(true);
asynMessageButton.addSelectionListener(graphNodeTypeListener);
}
@@ -200,10 +220,11 @@ public class TabContents extends Composite {
// Create the asynchronous message return check button
asynMessageReturnButton = new Button(kindSelection, SWT.CHECK);
String nodeName = provider.getNodeName(ISDGraphNodeSupporter.ASYNCMESSAGERETURN, null);
- if (nodeName != null)
+ if (nodeName != null) {
asynMessageReturnButton.setText(nodeName);
- else
+ } else {
asynMessageReturnButton.setText(SDMessages._33);
+ }
asynMessageReturnButton.setEnabled(true);
asynMessageReturnButton.addSelectionListener(graphNodeTypeListener);
}
@@ -213,15 +234,20 @@ public class TabContents extends Composite {
result.setVisible(false);
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
- * @param found
+ * Set result text visibility
+ * @param found true
for found (enable visibility) else false
*/
public void setResult(boolean found) {
result.setVisible(!found);
}
/**
- *
+ * Updates parent OK button based on input data.
*/
public void updateOkButton() {
if (parentOkButton == null) {
@@ -233,7 +259,9 @@ public class TabContents extends Composite {
}
/**
- * @param okButton
+ * Sets the parent OK button reference.
+ *
+ * @param okButton The parent OK button
*/
public void setOkButton(Button okButton) {
parentOkButton = okButton;
@@ -245,10 +273,10 @@ public class TabContents extends Composite {
* @return true if check, false otherwise
*/
public boolean getAsynMessageButtonSelection() {
- if (asynMessageButton != null)
+ if (asynMessageButton != null) {
return asynMessageButton.getSelection();
- else
- return false;
+ }
+ return false;
}
/**
@@ -257,10 +285,10 @@ public class TabContents extends Composite {
* @return true if check, false otherwise
*/
public boolean getAsynMessageReturnButtonSelection() {
- if (asynMessageReturnButton != null)
+ if (asynMessageReturnButton != null) {
return asynMessageReturnButton.getSelection();
- else
- return false;
+ }
+ return false;
}
/**
@@ -269,10 +297,10 @@ public class TabContents extends Composite {
* @return true if check, false otherwise
*/
public boolean getCaseSensitiveSelection() {
- if (caseSensitive != null)
+ if (caseSensitive != null) {
return caseSensitive.getSelection();
- else
- return false;
+ }
+ return false;
}
/**
@@ -281,10 +309,10 @@ public class TabContents extends Composite {
* @return true if check, false otherwise
*/
public boolean getLifelineButtonSelection() {
- if (lifelineButton != null)
+ if (lifelineButton != null) {
return lifelineButton.getSelection();
- else
- return false;
+ }
+ return false;
}
/**
@@ -302,10 +330,10 @@ public class TabContents extends Composite {
* @return true if check, false otherwise
*/
public boolean getStopButtonSelection() {
- if (stopButton != null)
+ if (stopButton != null) {
return stopButton.getSelection();
- else
- return false;
+ }
+ return false;
}
/**
@@ -314,10 +342,10 @@ public class TabContents extends Composite {
* @return true if check, false otherwise
*/
public boolean getSynMessageButtonSelection() {
- if (synMessageButton != null)
+ if (synMessageButton != null) {
return synMessageButton.getSelection();
- else
- return false;
+ }
+ return false;
}
/**
@@ -326,42 +354,46 @@ public class TabContents extends Composite {
* @return true if check, false otherwise
*/
public boolean getSynMessageReturnButtonSelection() {
- if (synMessageReturnButton != null)
+ if (synMessageReturnButton != null) {
return synMessageReturnButton.getSelection();
- else
- return false;
+ }
+ return false;
}
/**
* Set the asynchronous message check button state
*/
public void setAsynMessageButtonSelection(boolean state) {
- if (asynMessageButton != null)
+ if (asynMessageButton != null) {
asynMessageButton.setSelection(state);
+ }
}
/**
* Set the asynchronous message return check button state
*/
public void setAsynMessageReturnButtonSelection(boolean state) {
- if (asynMessageReturnButton != null)
+ if (asynMessageReturnButton != null) {
asynMessageReturnButton.setSelection(state);
+ }
}
/**
* Set the case sensitive check button state
*/
public void setCaseSensitiveSelection(boolean state) {
- if (caseSensitive != null)
+ if (caseSensitive != null) {
caseSensitive.setSelection(state);
+ }
}
/**
* Set the lifeline check button state
*/
public void setLifelineButtonSelection(boolean state) {
- if (lifelineButton != null)
+ if (lifelineButton != null) {
lifelineButton.setSelection(state);
+ }
}
/**
@@ -375,24 +407,72 @@ public class TabContents extends Composite {
* Set the stop check button state
*/
public void setStopButtonSelection(boolean state) {
- if (stopButton != null)
+ if (stopButton != null) {
stopButton.setSelection(state);
+ }
}
/**
* Set the synchronous message check button state
*/
public void setSynMessageButtonSelection(boolean state) {
- if (synMessageButton != null)
+ if (synMessageButton != null) {
synMessageButton.setSelection(state);
+ }
}
/**
* Set the synchronous message return check button state
*/
public void setSynMessageReturnButtonSelection(boolean state) {
- if (synMessageReturnButton != null)
+ if (synMessageReturnButton != null) {
synMessageReturnButton.setSelection(state);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+
+ /**
+ * Selection listener implementation for graph node types.
+ * @version 1.0
+ */
+ protected class GraphNodeTypeListener implements SelectionListener {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing to do
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateOkButton();
+ }
+ }
+
+ /**
+ * Modify listener implementation for the expression field.
+ *
+ * @version 1.0
+ */
+ protected class ExpressionListener implements ModifyListener {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText(ModifyEvent e) {
+ updateOkButton();
+ }
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IColor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IColor.java
index 3798c8d5d9..b1b8fea45a 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IColor.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IColor.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: IColor.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,6 +14,9 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings;
/**
+ * Interface for handling a color resource.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IFont.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IFont.java
index 175f285312..d4d34ee8cd 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IFont.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IFont.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: IFont.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,6 +14,9 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings;
/**
+ * Interface for handling a font resource.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IGC.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IGC.java
index 32079bba3e..9307c0e361 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IGC.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IGC.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: IGC.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,6 +14,9 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings;
/**
+ * Interface for a graphical context.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
@@ -362,5 +366,10 @@ public interface IGC {
*/
public abstract float getZoom();
+ /**
+ * Draws text with focus style.
+ *
+ * @param focus true
if item has focus else false
+ */
public abstract void setDrawTextWithFocusStyle(boolean focus);
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IImage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IImage.java
index a3ff871900..6888157cc6 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IImage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/IImage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: IImage.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,6 +14,9 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings;
/**
+ * Interface for handling a image resource.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ColorImpl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ColorImpl.java
index 1fe71f46fb..34b56cf778 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ColorImpl.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ColorImpl.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ColorImpl.java,v 1.3 2008/01/24 02:28:50 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -17,36 +18,83 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
/**
+ * Default implementation of the IColor interface.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class ColorImpl implements IColor {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The color object.
+ */
protected Color col = null;
+ /**
+ * Flag to indicate that this object is managing the resource.
+ */
protected boolean manageColor = true;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param display The display to use
+ * @param r A value for red
+ * @param g A value for green
+ * @param b A value for blue
+ */
public ColorImpl(Display display, int r, int g, int b) {
col = new Color(display, r, g, b);
}
+ /**
+ * Copy constructor
+ *
+ * @param A color to copy
+ */
protected ColorImpl(Color color) {
col = color;
manageColor = false;
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns a system color.
+ *
+ * @param color The color ID
+ * @return a system color
+ */
public static ColorImpl getSystemColor(int color) {
return new ColorImpl(Display.getDefault().getSystemColor(color));
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor#getColor()
+ */
@Override
public Object getColor() {
return col;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor#dispose()
+ */
@Override
public void dispose() {
- if ((col != null) && (manageColor))
+ if ((col != null) && (manageColor)) {
col.dispose();
+ }
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/FontImpl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/FontImpl.java
index 272b6c5d4b..0c2dac1326 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/FontImpl.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/FontImpl.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: FontImpl.java,v 1.3 2008/01/24 02:28:50 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -18,36 +19,79 @@ import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display;
/**
+ * Default implementation of the IFont interface.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class FontImpl implements IFont {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The font object
+ */
protected Font font = null;
+ /**
+ * Flag to indicate that this object is managing the resource.
+ */
protected boolean manageFont = true;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor.
+ *
+ * @param display The display to use
+ * @param data A font data
+ */
public FontImpl(Display display, FontData data) {
font = new Font(display, data);
}
+ /**
+ * Copy constructor
+ *
+ * @param value A font to copy.
+ */
protected FontImpl(Font value) {
font = value;
manageFont = false;
}
- @Override
- public Object getFont() {
- return font;
- }
-
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /**
+ * Returns a font implementation based system font.
+ *
+ * @return a font implementation based system font.
+ */
public static FontImpl getSystemFont() {
return new FontImpl(Display.getDefault().getSystemFont());
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont#getFont()
+ */
+ @Override
+ public Object getFont() {
+ return font;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont#dispose()
+ */
@Override
public void dispose() {
- if (font != null)
+ if (font != null) {
font.dispose();
+ }
}
-
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java
index 1463eaa275..a5002366b0 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/impl/ImageImpl.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ImageImpl.java,v 1.3 2008/01/24 02:28:50 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,46 +16,87 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl;
import java.net.MalformedURLException;
import java.net.URL;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
import org.eclipse.swt.graphics.Image;
/**
+ * Default implementation of the IImage interface.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class ImageImpl implements IImage {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
protected Image img = null;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor.
+ *
+ * @param file A file name of image file.
+ */
public ImageImpl(String file) {
img = getResourceImage(file);
}
+ /**
+ * Copy constructor
+ *
+ * @param img_ THe image to copy
+ */
public ImageImpl(Image img_) {
img = img_;
}
-
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /**
+ * Returns Image object from file name.
+ *
+ * @param _name File name of image file
+ * @return image object or null
+ */
public Image getResourceImage(String _name) {
try {
URL BASIC_URL = new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
URL url = new URL(BASIC_URL, "plugin/org.eclipse.linuxtools.tmf.ui/icons/" + _name);//$NON-NLS-1$
ImageDescriptor img = ImageDescriptor.createFromURL(url);
return img.createImage();
- } catch (MalformedURLException E) {
- System.err.println(E);
+ } catch (MalformedURLException e) {
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, "Error opening image file", e)); //$NON-NLS-1$
}
return null;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage#getImage()
+ */
@Override
public Object getImage() {
return img;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage#dispose()
+ */
@Override
public void dispose() {
- if (img != null)
+ if (img != null) {
img.dispose();
+ }
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ConfigureMinMax.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ConfigureMinMax.java
index 0bee489f95..aed06c6b2f 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ConfigureMinMax.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ConfigureMinMax.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ConfigureMinMax.java,v 1.1 2006/08/16 21:15:28 amehregani Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -14,19 +15,35 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers;
import org.eclipse.jface.action.Action;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.MinMaxDialog;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.MinMaxDialog;
import org.eclipse.ui.IViewPart;
/**
+ * Action class implementation to configure minimum and maximum time range values.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class ConfigureMinMax extends Action {
- protected SDWidget viewer = null;
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The corresponding sequence diagram view reference.
+ */
protected SDView view = null;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Standard constructor.
+ *
+ * @param _view The sequence diagram view for the action
+ */
public ConfigureMinMax(IViewPart _view) {
super();
if (_view instanceof SDView) {
@@ -34,9 +51,17 @@ public class ConfigureMinMax extends Action {
}
}
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
@Override
public void run() {
- if (view != null && view.getSDWidget() != null) {
+ if ((view != null) && (view.getSDWidget() != null)) {
MinMaxDialog minMax = new MinMaxDialog(view.getSite().getShell(), view.getSDWidget());
minMax.open();
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/FirstPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/FirstPage.java
index 324a514157..25ef8102a1 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/FirstPage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/FirstPage.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 2012 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -18,20 +18,37 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
- * Moves the focus on the first page in the sequence diagram view.
+ * Action class implementation to move the focus to the first page of the whole sequence diagram.
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
*/
public class FirstPage extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.firstpage"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ *
+ * @param theView the view reference
+ */
public FirstPage(SDView theView) {
super();
fView = theView;
@@ -42,7 +59,7 @@ public class FirstPage extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/KeyBindingsManager.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/KeyBindingsManager.java
index 3251d1964d..1578fcc760 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/KeyBindingsManager.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/KeyBindingsManager.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 2012 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -26,50 +26,91 @@ import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.handlers.IHandlerService;
/**
- * KeyBindingsManager
*
* Singleton class that manages key-bindings for certain commands across multiple sequence
* diagram view instances.
*
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
+ *
*/
public class KeyBindingsManager {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- // The instance
- private final static KeyBindingsManager fInstance = new KeyBindingsManager();
- // Storage of views
+ /**
+ * The singleton instance.
+ */
+ private final static KeyBindingsManager fInstance = new KeyBindingsManager();
+ /**
+ * The list of view names.
+ */
private Set fViews = new HashSet();
-
- // Activations to store
+ /**
+ * The list of activations Activations to store
+ */
private List fHandlerActivations = new Vector();
-
- // Actions for the keys bindings
+ /**
+ * The action reference for moving to a message in view.
+ */
private MoveToMessage fGoToMessageForKeyBinding;
+ /**
+ * The action reference for opening the find dialog.
+ */
private OpenSDFindDialog fFindForKeyBinding;
+ /**
+ * The action reference for moving up in view.
+ */
private MoveSDUp fMoveUpForKeyBinding;
+ /**
+ * The action reference for moving down in view.
+ */
private MoveSDDown fMoveDownForKeyBinding;
+ /**
+ * The action reference for moving left in view.
+ */
private MoveSDLeft fMoveLeftForKeyBinding;
+ /**
+ * The action reference for moving right in view.
+ */
private MoveSDRight fMoveRightForKeyBinding;
+ /**
+ * The action reference for showing node start.
+ */
private ShowNodeStart fShowNodeStartForKeyBinding;
+ /**
+ * The action reference for showing node end.
+ */
private ShowNodeEnd fShowNodeEndForKeyBinding;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
+
+ /**
+ * Private constructor
+ */
private KeyBindingsManager() {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
- public static KeyBindingsManager getInstance() {
+ /**
+ * Returns the KeyBindingsManager singleton instance.
+ *
+ * @return the KeyBindingsManager singleton instance
+ */
+ public synchronized static KeyBindingsManager getInstance() {
return fInstance;
}
/**
+ * Adds a view list of managed view list.
+ *
* @param viewId Id of SD view to add and to manage
*/
public void add(String viewId) {
@@ -84,6 +125,8 @@ public class KeyBindingsManager {
}
/**
+ * Removes a view from managed view list
+ *
* @param viewId Id of SD view to remove
*/
public void remove(String viewId) {
@@ -95,6 +138,9 @@ public class KeyBindingsManager {
}
}
+ /*
+ * Initialized the KeyBindingsManager.
+ */
private void initialize() {
fGoToMessageForKeyBinding = new MoveToMessage();
IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IHandlerService.class);
@@ -197,6 +243,9 @@ public class KeyBindingsManager {
}
+ /*
+ * Disposes the KeyBindingsManager
+ */
private void dispose() {
IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IHandlerService.class);
for(IHandlerActivation activation : fHandlerActivations) {
@@ -214,6 +263,8 @@ public class KeyBindingsManager {
}
/**
+ * Set the view in all supported actions
+ *
* @param view to set in global actions
*/
public void setSdView(SDView view) {
@@ -231,7 +282,8 @@ public class KeyBindingsManager {
/**
* Enable / disable find action
- * @param enabled
+ *
+ * @param enabled true
for enabling else false
*/
public void setFindEnabled(boolean enabled) {
if (fFindForKeyBinding != null) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/LastPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/LastPage.java
index 6b4aebeed4..c397a8040c 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/LastPage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/LastPage.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 2012 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -18,20 +18,37 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
- * Moves the focus on the last page in the sequence diagram view.
+ * Action class implementation to move the focus to the last page of the whole sequence diagram.
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
*/
public class LastPage extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.lastpage"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Standard constructor
+ *
+ * @param theView the view reference
+ */
public LastPage(SDView theView) {
super();
fView = theView;
@@ -42,7 +59,7 @@ public class LastPage extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDDown.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDDown.java
index 5faa723007..960a174f04 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDDown.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDDown.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: MoveSDDown.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -17,25 +18,45 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
/**
+ * Action class implementation to move down in the sequence diagram view within a page.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class MoveSDDown extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDDown"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public MoveSDDown() {
this(null);
}
+ /**
+ * Constructor
+ *
+ * @param view a sequence diagram view reference
+ */
public MoveSDDown(SDView view) {
super();
setId(ID);
@@ -44,7 +65,7 @@ public class MoveSDDown extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -55,6 +76,7 @@ public class MoveSDDown extends Action {
if (fView == null) {
return;
}
+
SDWidget viewer = fView.getSDWidget();
if (viewer != null) {
viewer.scrollBy(0, +viewer.getVisibleHeight());
@@ -63,6 +85,7 @@ public class MoveSDDown extends Action {
/**
* Sets the active SD view.
+ *
* @param view The SD view.
*/
public void setView(SDView view) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDLeft.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDLeft.java
index 30211b2d73..1ccf3b0278 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDLeft.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDLeft.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: MoveSDLeft.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -17,25 +18,45 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
/**
+ * Action class implementation to move left in the sequence diagram view within a page.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class MoveSDLeft extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDLeft"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public MoveSDLeft(){
this(null);
}
+ /**
+ * Constructor
+ *
+ * @param view a sequence diagram view reference
+ */
public MoveSDLeft(SDView view) {
super();
setId(ID);
@@ -49,7 +70,8 @@ public class MoveSDLeft extends Action {
/*
* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
- */ @Override
+ */
+ @Override
public void run() {
if (fView == null) {
@@ -64,6 +86,7 @@ public class MoveSDLeft extends Action {
/**
* Sets the active SD view.
+ *
* @param view The SD view.
*/
public void setView(SDView view) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDRight.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDRight.java
index b871150a34..628d3a3aab 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDRight.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDRight.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: MoveSDRight.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -17,6 +18,9 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
/**
+ * Action class implementation to move right in the sequence diagram view within a page.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
@@ -24,19 +28,36 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
public class MoveSDRight extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
- public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDRight"; //$NON-NLS-1$
+ /**
+ * The action ID.
+ */
+ public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDRight"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public MoveSDRight() {
this(null);
}
-
+
+ /**
+ * Constructor
+ *
+ * @param view a sequence diagram view reference
+ */
public MoveSDRight(SDView view) {
super();
setId(ID);
@@ -45,7 +66,7 @@ public class MoveSDRight extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -59,12 +80,14 @@ public class MoveSDRight extends Action {
}
SDWidget viewer = fView.getSDWidget();
- if (viewer != null)
+ if (viewer != null) {
viewer.scrollBy(+viewer.getVisibleWidth(), 0);
+ }
}
-
+
/**
* Sets the active SD view.
+ *
* @param view The SD view.
*/
public void setView(SDView view) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java
index 514fc73a99..85b0cbd218 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveSDUp.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: MoveSDUp.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -23,19 +24,36 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
public class MoveSDUp extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDUp"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public MoveSDUp() {
this(null);
}
+ /**
+ * Constructor
+ *
+ * @param view a sequence diagram view reference
+ */
public MoveSDUp(SDView view) {
super();
setId(ID);
@@ -44,7 +62,7 @@ public class MoveSDUp extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -56,6 +74,7 @@ public class MoveSDUp extends Action {
return;
}
SDWidget viewer = ((SDView) fView).getSDWidget();
+
if (viewer != null) {
viewer.scrollBy(0, -viewer.getVisibleHeight());
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveToMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveToMessage.java
index 45c66987a0..8351d8b632 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveToMessage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/MoveToMessage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: MoveToMessage.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -28,25 +29,45 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessageReturn;
/**
+ * Action Class implementation to move to selected message
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class MoveToMessage extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.GoToMessage"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default Constructor
+ */
public MoveToMessage() {
this(null);
}
+ /**
+ * Constructor
+ *
+ * @param view a sequence diagram view reference
+ */
public MoveToMessage(SDView view) {
super();
setId(ID);
@@ -56,7 +77,7 @@ public class MoveToMessage extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
@@ -86,8 +107,10 @@ public class MoveToMessage extends Action {
selectedNode = node;
}
}
- if (selectedNode == null)
+
+ if (selectedNode == null) {
return;
+ }
if (selectedNode instanceof SyncMessageReturn) {
GraphNode node = ((SyncMessageReturn) selectedNode).getMessage();
@@ -108,6 +131,7 @@ public class MoveToMessage extends Action {
/**
* Sets the active SD view.
+ *
* @param view The SD view.
*/
public void setView(SDView view) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/NextPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/NextPage.java
index 33c660319d..0eef050945 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/NextPage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/NextPage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: NextPage.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -19,21 +20,38 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
+ * Action class implementation to move the focus to the next page of the whole sequence diagram.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class NextPage extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.nextpage"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ *
+ * @param theView the view reference
+ */
public NextPage(SDView theView) {
super();
fView = theView;
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFiltersDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFiltersDialog.java
index 6269867227..2a127117c9 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFiltersDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFiltersDialog.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: OpenSDFiltersDialog.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -16,28 +17,46 @@ import org.eclipse.jface.action.Action;
import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterListDialog;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets.FilterListDialog;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
- * Action delegate for 'Filter' on a message
+ * Action class implementation for 'Filtering' of messages/lifelines.
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public class OpenSDFiltersDialog extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.sdFilters"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
protected SDView fView;
+
+ /**
+ * The filter provider reference
+ */
protected ISDFilterProvider fProvider;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
- * @param view_
+ * Constructor
+ *
+ * @param theView The view reference
*/
public OpenSDFiltersDialog(SDView view_, ISDFilterProvider provider_) {
super(SDMessages._43);
@@ -49,7 +68,7 @@ public class OpenSDFiltersDialog extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFindDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFindDialog.java
index 02392bfd9f..fa5f3b121c 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFindDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDFindDialog.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: OpenSDFindDialog.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -16,31 +17,54 @@ import org.eclipse.jface.action.Action;
import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets.SearchFilterDialog;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.SearchFilterDialog;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
import org.eclipse.swt.SWT;
/**
+ * Action class implementation for 'Finding' of messages/lifelines.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class OpenSDFindDialog extends Action {
-
+
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.sdFind"; //$NON-NLS-1$
+ /**
+ * The action definition ID.
+ */
public final static String ACTION_DEFINITION_ID = "org.eclipse.ui.edit.findReplace"; //$NON-NLS-1$
-
- protected SDView fView = null;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
+ protected SDView fView;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public OpenSDFindDialog() {
this(null);
}
-
+
+ /**
+ * Constructor
+ *
+ * @param theView The view reference
+ */
public OpenSDFindDialog(SDView theView) {
super(SDMessages._41);
setImageDescriptor(TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ));
@@ -51,7 +75,7 @@ public class OpenSDFindDialog extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -73,8 +97,7 @@ public class OpenSDFindDialog extends Action {
SearchFilterDialog dialog = new SearchFilterDialog(fView, fView.getSDFindProvider(), false, SWT.NORMAL);
dialog.open();
}
- }
- finally {
+ } finally {
// Enable action after finishing the search
this.setEnabled(true);
}
@@ -82,6 +105,7 @@ public class OpenSDFindDialog extends Action {
/**
* Sets the active SD view.
+ *
* @param view The SD view.
*/
public void setView(SDView view) {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDPagesDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDPagesDialog.java
index d916095c01..87a728926f 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDPagesDialog.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/OpenSDPagesDialog.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: OpenSDPagesDialog.java,v 1.4 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -16,28 +17,42 @@ import org.eclipse.jface.action.Action;
import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.PagesDialog;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets.PagesDialog;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
- * Action delegate for 'Filter' on a message
+ * Action class implementation for paging.
*/
public class OpenSDPagesDialog extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.sdPaging"; //$NON-NLS-1$
-
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
protected SDView fView;
+ /**
+ * The advanced paging provider reference.
+ */
protected ISDAdvancedPagingProvider fProvider;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
- * @param view_
+ * Constructor
+ *
+ * @param view_ The view reference
*/
public OpenSDPagesDialog(SDView view_, ISDAdvancedPagingProvider provider_) {
super(SDMessages._44);
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/PrevPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/PrevPage.java
index b09a019503..612a53297b 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/PrevPage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/PrevPage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: PrevPage.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -19,21 +20,41 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
+ * Action class implementation to move the focus to the previous page of the whole sequence diagram.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class PrevPage extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+
+ /**
+ * The action ID.
+ */
public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.prevpage"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView view = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+
+ /**
+ * Default constructor
+ *
+ * @param theView the view reference
+ */
public PrevPage(SDView theView) {
super();
view = theView;
@@ -44,7 +65,7 @@ public class PrevPage extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Print.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Print.java
index badef00a26..1de25cfa8e 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Print.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Print.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: Print.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,18 +16,38 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers;
import org.eclipse.jface.action.Action;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
+/**
+ * Action class implementation for 'Printing'.
+ *
+ * @version 1.0
+ * @author sveyrier
+ */
public class Print extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The action ID.
+ */
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.print"; //$NON-NLS-1$
- SDView fView;
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
+ private SDView fView;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param view The view reference
+ */
public Print(SDView view) {
super();
setId(ID);
@@ -34,7 +55,7 @@ public class Print extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -42,10 +63,10 @@ public class Print extends Action {
*/
@Override
public void run() {
- if (fView == null)
- return;
- if (fView.getSDWidget() == null)
+ if ((fView == null) || fView.getSDWidget() == null){
return;
+ }
+
fView.getSDWidget().print();
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeEnd.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeEnd.java
index 1aee61c338..992d97b7d3 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeEnd.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeEnd.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ShowNodeEnd.java,v 1.3 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -26,6 +27,9 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.ui.IViewPart;
/**
+ * Action class implementation to show end of a graph node.
+ *
+ * @version 1.0
* @author sveyrier
*/
public class ShowNodeEnd extends Action {
@@ -33,16 +37,27 @@ public class ShowNodeEnd extends Action {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- protected SDView fView = null;
+ /**
+ * The sequence diagram view reference
+ */
+ protected SDView fView = null;
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- public ShowNodeEnd() {
- this(null);
- }
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
+ public ShowNodeEnd() {
+ this(null);
+ }
- public ShowNodeEnd(IViewPart _view) {
+ /**
+ * Constructor
+ *
+ * @param _view The sequence diagram view reference
+ */
+ public ShowNodeEnd(IViewPart _view) {
super();
if (_view instanceof SDView) {
fView = (SDView)_view;
@@ -60,31 +75,41 @@ public class ShowNodeEnd extends Action {
@Override
@SuppressWarnings("rawtypes")
public void run() {
- if (fView == null)
+ if (fView == null) {
return;
+ }
SDWidget sdWidget = fView.getSDWidget();
if (sdWidget == null) {
return;
}
-
+
ISelectionProvider selProvider = sdWidget.getSelectionProvider();
ISelection sel = selProvider.getSelection();
Object selectedNode = null;
+
Iterator it = ((StructuredSelection) sel).iterator();
- while (it.hasNext())
+ while (it.hasNext()) {
selectedNode = it.next();
+ }
+
if (selectedNode != null) {
GraphNode node = (GraphNode) selectedNode;
- if ((node.getX() + node.getWidth()) * sdWidget.getZoomFactor() < sdWidget.getContentsX() + sdWidget.getVisibleWidth() / 2)
+ if ((node.getX() + node.getWidth()) * sdWidget.getZoomFactor() < sdWidget.getContentsX() + sdWidget.getVisibleWidth() / 2) {
sdWidget.ensureVisible(Math.round((node.getX() + node.getWidth()) * sdWidget.getZoomFactor()) - sdWidget.getVisibleWidth() / 2, Math.round((node.getY() + node.getHeight()) * sdWidget.getZoomFactor()));
- else
+ } else {
sdWidget.ensureVisible(Math.round((node.getX() + node.getWidth()) * sdWidget.getZoomFactor() + sdWidget.getVisibleWidth() / (float) 2), Math.round((node.getY() + node.getHeight()) * sdWidget.getZoomFactor()));
+ }
}
}
- public void setView(SDView view) {
+ /**
+ * Sets the active SD view.
+ *
+ * @param view The SD view.
+ */
+ public void setView(SDView view) {
fView = view;
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeStart.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeStart.java
index dba63a3e4a..04ce3a8f53 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeStart.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/ShowNodeStart.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ShowNodeStart.java,v 1.3 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -26,6 +27,9 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.ui.IViewPart;
/**
+ * Action class implementation to show end of a graph node.
+ *
+ * @version 1.0
* @author sveyrier
*/
public class ShowNodeStart extends Action {
@@ -33,15 +37,26 @@ public class ShowNodeStart extends Action {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
protected SDView fView = null;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public ShowNodeStart() {
this(null);
}
-
+
+ /**
+ * Constructor
+ *
+ * @param _view The sequence diagram view reference
+ */
public ShowNodeStart(IViewPart _view) {
super();
if (_view instanceof SDView) {
@@ -51,7 +66,7 @@ public class ShowNodeStart extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -60,30 +75,39 @@ public class ShowNodeStart extends Action {
@Override
@SuppressWarnings("rawtypes")
public void run() {
- if (fView == null)
+ if (fView == null) {
return;
+ }
+
SDWidget sdWidget = fView.getSDWidget();
if (sdWidget == null) {
return;
}
-
+
ISelectionProvider selProvider = sdWidget.getSelectionProvider();
ISelection sel = selProvider.getSelection();
Object selectedNode = null;
Iterator it = ((StructuredSelection) sel).iterator();
- while (it.hasNext())
+ while (it.hasNext()) {
selectedNode = it.next();
+ }
if (selectedNode != null) {
GraphNode node = (GraphNode) selectedNode;
- if (node.getX() * sdWidget.getZoomFactor() < sdWidget.getContentsX() + sdWidget.getVisibleWidth() / 2)
+ if (node.getX() * sdWidget.getZoomFactor() < sdWidget.getContentsX() + sdWidget.getVisibleWidth() / 2) {
sdWidget.ensureVisible(Math.round(node.getX() * sdWidget.getZoomFactor() - sdWidget.getVisibleWidth() / (float) 2), Math.round(node.getY() * sdWidget.getZoomFactor()));
- else
+ } else {
sdWidget.ensureVisible(Math.round(node.getX() * sdWidget.getZoomFactor() + sdWidget.getVisibleWidth() / (float) 2), Math.round(node.getY() * sdWidget.getZoomFactor()));
+ }
}
}
- public void setView(SDView view) {
+ /**
+ * Sets the active SD view.
+ *
+ * @param view The SD view.
+ */
+ public void setView(SDView view) {
fView = view;
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Zoom.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Zoom.java
index 8b109b3181..5766d11b7b 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Zoom.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/Zoom.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: Zoom.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -28,25 +29,60 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
/**
+ * Action class implementation for zooming in, out or reset of zoom.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public class Zoom extends Action {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * The Action ID for zooming in.
+ */
public final static String ZOOM_IN_ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ZoomInCoolBar"; //$NON-NLS-1$
+ /**
+ * The Action ID for zooming out.
+ */
public final static String ZOOM_OUT_ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ZoomOutCoolBar"; //$NON-NLS-1$
+ /**
+ * The Action ID for reset zooming.
+ */
public final static String RESET_ZOOM_ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ResetZoom"; //$NON-NLS-1$
+ /**
+ * The Action ID for no zoominf.
+ */
public final static String NO_ZOOM_ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.NoZoom"; //$NON-NLS-1$
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram view reference
+ */
protected SDView fView = null;
+ /**
+ * Flag to indicate last zoom in.
+ */
protected boolean fLastZoomIn = false;
+ /**
+ * Flag to indicate last zoom out.
+ */
protected boolean fLastZoomOut = false;
+ /**
+ * Flag to indicate last zoom.
+ */
protected boolean fLastZoom = true;
-
+ /**
+ * The cursor used when zooming in.
+ */
private static Cursor fZoomInCursor;
+ /**
+ * The cursor used when zooming out.
+ */
private static Cursor fZoomOutCursor;
public static enum ZoomType {
@@ -56,6 +92,12 @@ public class Zoom extends Action {
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param _view The view reference
+ * @param type The type of zoom.
+ */
public Zoom(SDView _view, ZoomType type) {
super("", AS_RADIO_BUTTON);//$NON-NLS-1$
@@ -64,6 +106,7 @@ public class Zoom extends Action {
if ((fZoomInCursor != null) && (!fZoomInCursor.isDisposed())) {
fZoomInCursor.dispose();
}
+
if ((fZoomOutCursor != null) && (!fZoomOutCursor.isDisposed())) {
fZoomOutCursor.dispose();
}
@@ -72,7 +115,7 @@ public class Zoom extends Action {
fZoomInCursor = new Cursor(Display.getCurrent(),
TmfUiPlugin.getDefault().getImageFromImageRegistry(ITmfImageConstants.IMG_UI_ZOOM_IN).getImageData(),
TmfUiPlugin.getDefault().getImageFromImageRegistry(ITmfImageConstants.IMG_UI_ZOOM).getImageData(), 0, 0);
-
+
fZoomOutCursor = new Cursor(Display.getCurrent(),
TmfUiPlugin.getDefault().getImageFromImageRegistry(ITmfImageConstants.IMG_UI_ZOOM_OUT).getImageData(),
TmfUiPlugin.getDefault().getImageFromImageRegistry(ITmfImageConstants.IMG_UI_ZOOM).getImageData(), 0, 0);
@@ -110,7 +153,7 @@ public class Zoom extends Action {
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
@@ -176,6 +219,7 @@ public class Zoom extends Action {
/**
* Set action check state of a view action for a given action ID.
+ *
* @param id The action ID
* @param checked true to check the action, false to uncheck the action
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFilterProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFilterProvider.java
index 0effcdcf86..8f33e94d9d 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFilterProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFilterProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: IExtendedFilterProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,11 +16,23 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
import org.eclipse.jface.action.Action;
/**
+ * Interface for providing an extended filter provider.
+ *
+ * Sequence Diagram loaders which implement this interface provide the action for filtering the sequence diagram.
+ *
+ * Action provider are associated to a Sequence Diagram view by calling SDView.setExtendedFilterProvider
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public interface IExtendedFilterProvider {
+ /**
+ * Returns a filter action implementation.
+ *
+ * @return a filter action implementation
+ */
public Action getFilterAction();
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFindProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFindProvider.java
index 7890adec0b..6b42e916ec 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFindProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/IExtendedFindProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: IExtendedFindProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,11 +16,24 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
import org.eclipse.jface.action.Action;
/**
+ * Interface for providing an extended find provider.
+ *
+ * Sequence Diagram loaders which implement this interface provide an action for finding in the sequence diagram.
+ *
+ * Action provider are associated to a Sequence Diagram view by calling SDView.setExtendedFindProvider()
.
+ *
+ * Note that either provider implementing ISDFindProvider or IExtendedFindProvider can be active in the SDView.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
public interface IExtendedFindProvider {
+ /**
+ * Returns an extended find action.
+ *
+ * @return an extended find action
+ */
public Action getFindAction();
-
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDAdvancedPagingProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDAdvancedPagingProvider.java
index d241a4c485..bf1d8b6ba0 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDAdvancedPagingProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDAdvancedPagingProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDAdvancedPagingProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,27 +14,36 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
/**
+ * Interface for providing an extended find provider.
+ *
* An advanced paging provider is able to compute number of pages, and to display the number of items it treats on each
* page and for total counts.
* An item can be a message, a node or anything meaningful from loader standpoint.
* Items are only here for information to the user.
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public interface ISDAdvancedPagingProvider extends ISDPagingProvider {
/**
- * @return the current page the loader is dealing with Note that first page has the 0 index (indexes are from
+ * Returns the current page.
+ *
+ * @return the current page the loader is dealing with. Note that first page has the 0 index (indexes are from
* 0 to pagesCount()-1).
*/
public int currentPage();
/**
+ * Returns the number of pages.
+ *
* @return number of pages the loader is dealing with
*/
public int pagesCount();
/**
* Instructs a load of the <pageNumber_>th page.
- * Note that first page has the index 0 (indexes are from 0 to pagesCount()-1).
+ * Note that first page has the index 0 (indexes are from 0 to pagesCount()-1).
*
* @param pageNumber_ index of the page to load
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDCollapseProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDCollapseProvider.java
index 6de9365f13..649cfc8cc5 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDCollapseProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDCollapseProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDCollapseProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,9 +16,12 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
/**
+ * Interface for providing a collapse provider.
+ *
* Sequence diagram loaders which want to support Drag and Drop collapsing in the sequence diagram must implement this
- * interface and register this implementation using SDViewer.setCollapsingProvider();
+ * interface and register this implementation using SDView.setCollapsingProvider();
*
+ * @version 1.0
* @author sveyrier
*/
public interface ISDCollapseProvider {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDExtendedActionBarProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDExtendedActionBarProvider.java
index 4e4c7df8b4..0d8975054b 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDExtendedActionBarProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDExtendedActionBarProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDExtendedActionBarProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,10 +16,14 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
import org.eclipse.ui.IActionBars;
/**
+ * Interface for providing an extended action bar provider.
+ *
* Sequence Diagram loaders which implement this interface provide their own action to the action bar.
*
* Action provider are associated to a Sequence Diagram SDWidget calling SDViewer.setExtendedActionBarProvider()
*
+ * @version 1.0
+ * @author sveyrier
*/
public interface ISDExtendedActionBarProvider {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFilterProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFilterProvider.java
index 2bbcce0247..566f13ff58 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFilterProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFilterProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDFilterProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,13 +16,18 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
import java.util.List;
/**
+ * Interface for providing a filter provider.
+ *
* Sequence Diagram loaders which implement this class provide the actions filtering the sequence diagram.
* This interface also allow the implementor to set which graph nodes are supporting filtering (thanks to
* ISDGraphNodeSupporter extension).
*
- * Action provider are associated to a Sequence Diagram SDWidget calling SDViewer.setSDFilterProvider
+ * Action provider are associated to a Sequence Diagram view by calling SDView.setSDFilterProvider
*
* Filters to be applied to be managed by the loader in an ArrayList of FilterCriteria.
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public interface ISDFilterProvider extends ISDGraphNodeSupporter {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFindProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFindProvider.java
index 3a62ceeb66..c69bd83889 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFindProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDFindProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDFindProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -12,14 +13,19 @@
**********************************************************************/
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets.Criteria;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
/**
+ * Interface for providing a find provider.
+ *
* Sequence Diagram loaders which implement this class provide the actions for finding the sequence diagram. This
- * interface also allow the implementor to set which action/feature are supported
+ * interface also allow the implementor to set which action/feature are supported.
+ *
+ * Action provider are associated to a Sequence Diagram view by calling SDView.setSDFindProvider()
.
*
- * Action provider are associated to a Sequence Diagram SDWidget calling SDViewer.setSDFindProvider()
+ * Note that either provider implementing ISDFindProvider or IExtendedFindProvider can be active in the SDView.
*
+ * @version 1.0
* @author sveyrier
*
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDGraphNodeSupporter.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDGraphNodeSupporter.java
index 879800b033..100d6d5a03 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDGraphNodeSupporter.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDGraphNodeSupporter.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDGraphNodeSupporter.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,24 +14,53 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
/**
+ * Interface for providing a graph node supporter.
+ *
* Sequence Diagram loaders which implement this class provide the actions for finding or filtering the sequence
* diagram. This interface also allow the implementor to set which action/feature are supported
*
- * Action provider are associated to a Sequence Diagram SDWidget calling SDViewer.setSDFindProvider() or
- * SDViewer.setSDFilterProvider
+ * Action provider are associated to a Sequence Diagram SDWidget calling SDViewer.setSDFindProvider()
or
+ * SDViewer.setSDFilterProvider()
.
*
+ * @version 1.0
* @author sveyrier
*
*/
public abstract interface ISDGraphNodeSupporter {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Lifeline support ID
+ */
public static int LIFELINE = 0;
+ /**
+ * Synchronous message support ID
+ */
public static int SYNCMESSAGE = 1;
+ /**
+ * Synchronous message return support ID
+ */
public static int SYNCMESSAGERETURN = 2;
+ /**
+ * Asynchronous message support ID
+ */
public static int ASYNCMESSAGE = 3;
+ /**
+ * Asynchronous message return support ID
+ */
public static int ASYNCMESSAGERETURN = 4;
+ /**
+ * Stop support ID
+ */
public static int STOP = 5;
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
/**
* Return true to enable this options, false otherwise
*
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPagingProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPagingProvider.java
index 6c225c892c..bd2eb0140c 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPagingProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPagingProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDPagingProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -13,10 +14,13 @@
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
/**
- * Sequence Diagram loaders which implement this class provide the actions for sequence diagram page navigation.
+ * Paging provider interface.
+ *
+ * Sequence Diagram loaders which implement this class provide the actions for sequence diagram page navigation.
*
- * Action provider are associated to a Sequence Diagram SDWidget calling SDViewer.setSDPagingProvider()
+ * Action provider are associated to a Sequence Diagram view by calling SDView.setSDPagingProvider()
.
*
+ * @version 1.0
* @author sveyrier
*
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPropertiesProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPropertiesProvider.java
index b4c5260caa..377612feb2 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPropertiesProvider.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/handlers/provider/ISDPropertiesProvider.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDPropertiesProvider.java,v 1.2 2006/09/20 20:56:26 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,7 +16,13 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider;
import org.eclipse.ui.views.properties.IPropertySheetPage;
/**
- * Contract for loaders that want to provide information in the properties view
+ * Interface for providing sequence diagram property.
+ *
+ * Contract for loaders that want to provide information in the properties view.
+ *
+ * @version 1.0
+ * @author sveyrier
+
*/
public interface ISDPropertiesProvider {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/IUml2SDLoader.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/IUml2SDLoader.java
index a3e5928631..490a1ecf1c 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/IUml2SDLoader.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/IUml2SDLoader.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: IUml2SDLoader.java,v 1.2 2006/09/20 20:56:28 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -15,18 +16,23 @@ package org.eclipse.linuxtools.tmf.ui.views.uml2sd.load;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
/**
- * The interface all UML2SD loaders must implement
+ * The interface all UML2SD loaders must implement.
+ *
+ * @version 1.0
+ * @author sveyrier
*/
public interface IUml2SDLoader {
/**
* Set the viewer object to the loader that has been reloaded at the beginning
* of a new workbench session
+ *
+ * @param viewer The sequence diagram view
*/
public void setViewer(SDView viewer);
/**
- * Title string for the UML2SD View when this loader is the one
+ * Returns title string for the UML2SD View when this loader is the one
*
* @return the string convenient for this loader
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java
index e869bf257b..b096705d23 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/load/LoadersManager.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: LoadersManager.java,v 1.5 2008/01/24 02:29:16 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -21,31 +22,52 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
-import org.eclipse.linuxtools.internal.tmf.ui.TmfUiTracer;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
/**
* Manager class for the UML2SD extension point.
+ *
+ * @version 1.0
+ * @author sveyrier
+ * @author Bernd Hufmann
*/
public class LoadersManager {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
-
+ /**
+ * The loader tag for the extension point.
+ */
public static final String LOADER_TAG = "uml2SDLoader"; //$NON-NLS-1$
+ /**
+ * The loader prefix.
+ */
public static final String LOADER_PREFIX = LOADER_TAG + "."; //$NON-NLS-1$
- // The instance
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The LoadersManager singleton instance.
+ */
private static LoadersManager loadersManager;
- // Maps for caching information
+ /**
+ * Map for caching information (view ID to loader class)
+ */
protected HashMap fViewLoaderMap = new HashMap();
+ /**
+ * Map for caching information (view ID to list of configuration elements)
+ */
protected HashMap> fViewLoadersList = new HashMap>();
// ------------------------------------------------------------------------
@@ -65,7 +87,7 @@ public class LoadersManager {
*
* @return the manager instance
*/
- public static LoadersManager getInstance() {
+ public synchronized static LoadersManager getInstance() {
if (loadersManager == null) {
loadersManager = new LoadersManager();
}
@@ -167,9 +189,7 @@ public class LoadersManager {
return loader;
} catch (Exception e) {
- if (TmfUiTracer.isErrorTraced()) {
- TmfUiTracer.traceError("Exception during getCurrentLoder(): " + e); //$NON-NLS-1$
- }
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, "Error getting loader class", e)); //$NON-NLS-1$
}
return null;
}
@@ -224,7 +244,7 @@ public class LoadersManager {
}
} catch (Exception e) {
- e.printStackTrace();
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, "Error setting current loader class", e)); //$NON-NLS-1$
}
}
// The old loader is going to be kicked
@@ -273,6 +293,7 @@ public class LoadersManager {
if (list != null) {
return list;
}
+
ArrayList ret = new ArrayList();
IExtensionPoint iep = Platform.getExtensionRegistry().getExtensionPoint(TmfUiPlugin.PLUGIN_ID, LOADER_TAG);
if (iep == null) {
@@ -338,6 +359,7 @@ public class LoadersManager {
/**
* Creates an instance of the loader class for a given extension point configuration element and
* also sets it as current loader for the given view.
+ *
* @param viewId The view ID.
* @param ce The extension point configuration element
*/
@@ -349,10 +371,9 @@ public class LoadersManager {
setCurrentLoader(l, viewId);
}
} catch (CoreException e4) {
- System.err.println("Error 'uml2SDLoader' Extension point :" + e4); //$NON-NLS-1$
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, "Error 'uml2SDLoader' Extension point", e4)); //$NON-NLS-1$
} catch (Exception e5) {
- e5.printStackTrace();
- System.err.println("Error 'uml2SDLoader' Extension point :" + e5); //$NON-NLS-1$
+ TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, "Error 'uml2SDLoader' Extension point", e5)); //$NON-NLS-1$
}
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/Messages.java
similarity index 90%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/Messages.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/Messages.java
index d184229560..2a4950d15f 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/Messages.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Ericsson.
+ * Copyright (c) 2011, 2012 Ericsson.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,12 +8,12 @@
* Contributors:
* Bernd Hufmann - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl.messages"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.messages"; //$NON-NLS-1$
public static String TmfUml2SDSyncLoader_ViewName;
public static String TmfUml2SDSyncLoader_CategoryLifeline;
public static String TmfUml2SDSyncLoader_CategoryMessage;
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfAsyncMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfAsyncMessage.java
similarity index 83%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfAsyncMessage.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfAsyncMessage.java
index cf141b9bee..0056114722 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfAsyncMessage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfAsyncMessage.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 2012 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -9,27 +9,38 @@
* Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader;
+
+import org.eclipse.linuxtools.tmf.core.uml2sd.ITmfAsyncSequenceDiagramEvent;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage;
/**
- * TmfAsyncMessage
*
* Extends AsyncMessage class to provide additional information about the trace event.
*
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
*/
-import org.eclipse.linuxtools.tmf.core.uml2sd.ITmfAsyncSequenceDiagramEvent;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage;
-
public class TmfAsyncMessage extends AsyncMessage implements ITmfAsyncSequenceDiagramEvent {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
+ /**
+ * A asynchronous sequence diagram event implementation
+ */
protected ITmfAsyncSequenceDiagramEvent fSdEvent;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Standard constructor
+ *
+ * @param sdEvent The asynchronous sequence diagram event implementation
+ * @param eventOccurrence The event index
+ */
public TmfAsyncMessage(ITmfAsyncSequenceDiagramEvent sdEvent, int eventOccurrence) {
this.fSdEvent = sdEvent;
setEventOccurrence(eventOccurrence);
@@ -39,7 +50,7 @@ public class TmfAsyncMessage extends AsyncMessage implements ITmfAsyncSequenceDi
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
/*
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfSyncMessage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfSyncMessage.java
similarity index 80%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfSyncMessage.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfSyncMessage.java
index 2c6a5a823d..63a2acd275 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfSyncMessage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfSyncMessage.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 2012 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -9,27 +9,39 @@
* Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader;
+
+import org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
+
/**
- * TmfSyncMessages
*
- * Extends AsyncMessage class to provide additional information about the trace event.
+ * Extends SyncMessage class to provide additional information about the trace event.
*
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
*/
-import org.eclipse.linuxtools.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
-
public class TmfSyncMessage extends SyncMessage implements ITmfSyncSequenceDiagramEvent {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
+ /**
+ * A synchronous sequence diagram event implementation
+ */
protected ITmfSyncSequenceDiagramEvent fSdEvent;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Standard constructor
+ *
+ * @param sdEvent The synchronous sequence diagram event implementation
+ * @param eventOccurrence The event index
+ */
public TmfSyncMessage(ITmfSyncSequenceDiagramEvent sdEvent, int eventOccurrence) {
this.fSdEvent = sdEvent;
setEventOccurrence(eventOccurrence);
@@ -38,9 +50,8 @@ public class TmfSyncMessage extends SyncMessage implements ITmfSyncSequenceDiagr
}
// ------------------------------------------------------------------------
- // Operations
+ // Methods
// ------------------------------------------------------------------------
-
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.ust.examples.event.ISequenceDiagramEvent#getSender()
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java
similarity index 89%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java
index 5e6732b96d..8f5181df24 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java
@@ -1,15 +1,15 @@
/**********************************************************************
- * Copyright (c) 2011 Ericsson
- *
+ * Copyright (c) 2011, 2012 Ericsson
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader;
import java.util.ArrayList;
import java.util.HashMap;
@@ -28,7 +28,6 @@ import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
@@ -48,13 +47,13 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterCriteria;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterListDialog;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFindProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets.Criteria;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets.FilterCriteria;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.widgets.FilterListDialog;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISelectionListener;
@@ -63,61 +62,154 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressConstants;
/**
- * TmfUml2SDSyncLoader
*
- * Implementation of the org.eclipse.linuxtools.tmf.ui.Uml2SDLoader extension point to provide
- * a Sequence Diagram loader for a UST trace with specific trace content for sending and
- * receiving signals between components. Includes default implementation for the TmfEvent parsing.
+ * This class is a reference implementation of the org.eclipse.linuxtools.tmf.ui.Uml2SDLoader
extension point. It provides
+ * a Sequence Diagram loader for a user space trace with specific trace content for sending and
+ * receiving signals between components. I also includes a default implementation for the ITmfEvent
parsing.
*
+ *
+ * The class TmfUml2SDSyncLoader
analyzes events from type ITmfEvent
and creates events type
+ * ITmfSyncSequenceDiagramEvent
if the ITmfEvent
contains all relevant information.
+ * The analysis checks that the event type strings contains either string SEND or RECEIVE. If event type matches these key
+ * words, the analyzer will look for strings sender, receiver and signal in the event fields of type ITmfEventField
.
+ * If all the data is found a sequence diagram event from can be created. Note that Sync Messages are assumed, which
+ * means start and end time are the same.
+ *
+ * The parsing of the ITmfEvent
is done in the method getSequnceDiagramEvent()
of class
+ * TmfUml2SDSyncLoader
. By extending the class TmfUml2SDSyncLoader
and overwriting
+ * getSequnceDiagramEvent()
a customized parsing algorithm can be implemented.
+ *
+ * Note that combined traces of multiple components, that contain the trace information about the same interactions are not
+ * supported in the class TmfUml2SDSyncLoader
.
+ *
+ * @version 1.0
+ * @author Bernd Hufmann
*/
public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader, ISDFindProvider, ISDFilterProvider, ISDAdvancedPagingProvider, ISelectionListener {
// ------------------------------------------------------------------------
- // Attributes
+ // Constants
// ------------------------------------------------------------------------
+ /**
+ * Default title name.
+ */
protected final static String TITLE = Messages.TmfUml2SDSyncLoader_ViewName;
+ /**
+ * Default block size for background request.
+ */
protected final static int DEFAULT_BLOCK_SIZE = 50000;
+ /**
+ * Maximum number of messages per page.
+ */
protected final static int MAX_NUM_OF_MSG = 10000;
- protected static final long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec
+ /**
+ * Initial time range window.
+ */
+ protected final static long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
// Experiment attributes
+ /**
+ * The TMF experiment reference.
+ */
protected TmfExperiment fExperiment = null;
+ /**
+ * The current indexing event request.
+ */
protected ITmfEventRequest fIndexRequest = null;
+ /**
+ * The current request to fill a page.
+ */
protected ITmfEventRequest fPageRequest = null;
+ /**
+ * Flag whether the time range signal was sent by this loader class or not
+ */
volatile protected boolean fIsSignalSent = false;
+ /**
+ * The initial request window size.
+ */
volatile protected long fInitialWindow = INITIAL_WINDOW_OFFSET;
// The view and event attributes
+ /**
+ * The sequence diagram view reference.
+ */
protected SDView fView = null;
+ /**
+ * The current sequence diagram frame reference.
+ */
protected Frame fFrame = null;
+ /**
+ * The list of sequence diagram events of current page.
+ */
protected List fEvents = new ArrayList();
// Checkpoint and page attributes
+ /**
+ * The checkpoints of the whole sequence diagram trace (i.e. start time stamp of each page)
+ */
protected List fCheckPoints = new ArrayList(MAX_NUM_OF_MSG);
+ /**
+ * The current page displayed.
+ */
volatile protected int fCurrentPage = 0;
+ /**
+ * The current time selected.
+ */
protected ITmfTimestamp fCurrentTime = null;
- volatile protected boolean fIsSelect = false;
+ /**
+ * Flag to specify that selection of message is done by selection or by signal.
+ */
+ volatile protected boolean fIsSelect = false;
// Search attributes
+ /**
+ * The job for searching across pages.
+ */
protected SearchJob fFindJob = null;
+ /**
+ * List of found nodes within a page.
+ */
protected List fFindResults = new ArrayList();
+ /**
+ * The current find criteria reference
+ */
protected Criteria fFindCriteria = null;
+ /**
+ * The current find index within the list of found nodes (fFindeResults
within a page.
+ */
volatile protected int fCurrentFindIndex = 0;
// Filter attributes
+ /**
+ * The list of active filters.
+ */
protected List fFilterCriteria = null;
-
+
// Thread synchronization
+ /**
+ * The synchronization lock.
+ */
protected ReentrantLock fLock = new ReentrantLock();
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
+ /**
+ * Default constructor
+ */
public TmfUml2SDSyncLoader() {
super(TITLE);
}
+ /**
+ * Constructor
+ *
+ * @param name Name of loader
+ */
public TmfUml2SDSyncLoader(String name) {
super(name);
}
@@ -125,14 +217,15 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
-
/**
- * @return returns the current time if available else null
+ * Returns the current time if available else null.
+ *
+ * @return the current time if available else null
*/
public ITmfTimestamp getCurrentTime() {
- fLock.lock();
+ fLock.lock();
try {
- if (fCurrentTime != null) {
+ if (fCurrentTime != null) {
return fCurrentTime.clone();
}
return null;
@@ -140,7 +233,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
fLock.unlock();
}
}
-
+
/**
* Waits for the page request to be completed
*/
@@ -148,19 +241,20 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
fLock.lock();
ITmfEventRequest request = fPageRequest;
fLock.unlock();
- if (request != null) {
- try {
- request.waitForCompletion();
- } catch (InterruptedException e) {
- // ignore
- }
+ if (request != null)
+ try {
+ request.waitForCompletion();
+ } catch (InterruptedException e) {
+ // ignore
}
}
/**
+ * Signal handler for the experiment selected signal.
+ *
* Spawns a request to index the experiment (checkpoints creation) as well as it fills
* the first page.
- *
+ *
* @param signal The experiment selected signal
*/
@SuppressWarnings("unchecked")
@@ -184,7 +278,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
job.setUser(false);
job.schedule();
- fLock.lock();
+ fLock.lock();
try {
// Update the trace reference
TmfExperiment exp = (TmfExperiment) signal.getExperiment();
@@ -192,7 +286,6 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
fExperiment = exp;
}
- // TmfTimeRange window = getInitTRange(fExperiment.getTimeRange());
TmfTimeRange window = TmfTimeRange.ETERNITY;
fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) {
@@ -202,6 +295,10 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
private int fNbSeqEvents = 0;
private final List fSdEvents = new ArrayList(MAX_NUM_OF_MSG);
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
+ */
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
@@ -244,9 +341,12 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleSuccess()
+ */
@Override
public void handleSuccess() {
- // long indexingEnd = System.nanoTime();
if ((fFirstTime != null) && (fLastTime != null)) {
fLock.lock();
@@ -267,6 +367,10 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
super.handleSuccess();
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
+ */
@Override
public void handleCompleted() {
if (fEvents.size() == 0) {
@@ -282,14 +386,16 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
} finally {
fLock.unlock();
}
-
+
}
/**
+ * Signal handler for the experiment disposed signal.
+ *
* @param signal The experiment disposed signal
*/
@TmfSignalHandler
- public void experimentDisposed(TmfExperimentDisposedSignal signal) {
+ public void experimentDisposed(TmfExperimentDisposedSignal signal) {
if (signal.getExperiment() != TmfExperiment.getCurrentExperiment()) {
return;
}
@@ -336,10 +442,10 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
}
/**
- * Moves to the page that contains the current time provided by signal.
- * No message will be selected however the focus will be set to the message
+ * Moves to the page that contains the current time provided by signal.
+ * No message will be selected however the focus will be set to the message
* if the provided time is the time of a message.
- *
+ *
* @param signal The time range sync signal
*/
@TmfSignalHandler
@@ -742,6 +848,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
if (fFindJob != null) {
fFindJob.cancel();
}
+
fFindResults = null;
fFindCriteria = null;
fCurrentFindIndex = 0;
@@ -780,6 +887,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Fills current page with sequence diagram content.
+ *
* @param events sequence diagram events
*/
protected void fillCurrentPage(List events) {
@@ -795,8 +903,8 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
}
final Frame frame = new Frame();
- if (events.size() > 0) {
+ if (events.size() > 0) {
HashMap nodeToLifelineMap = new HashMap();
frame.setName(Messages.TmfUml2SDSyncLoader_FrameName);
@@ -979,6 +1087,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Moves to a certain page.
+ *
* @param notifyAll true to broadcast time range signal to other signal handlers else false
*/
protected void moveToPage(boolean notifyAll) {
@@ -1028,6 +1137,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Gets page that contains timestamp
+ *
* @param time The timestamp
* @return page that contains the time
*/
@@ -1054,6 +1164,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Background search in trace for expression in criteria.
+ *
* @param findCriteria The find criteria
* @return true if background request was started else false
*/
@@ -1083,6 +1194,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Gets time range for time range signal.
+ *
* @param startTime The start time of time range.
* @return the time range
*/
@@ -1099,6 +1211,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Checks if filter criteria matches the message name in given SD event.
+ *
* @param sdEvent The SD event to check
* @return true if match else false.
*/
@@ -1123,6 +1236,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Checks if filter criteria matches a lifeline name (sender or receiver) in given SD event.
+ *
* @param lifeline the message receiver
* @return true if match else false.
*/
@@ -1150,6 +1264,9 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
*/
protected class SearchJob extends Job {
+ /**
+ * The search event request.
+ */
final protected SearchEventRequest fSearchRequest;
/**
@@ -1240,10 +1357,21 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
*/
protected class SearchEventRequest extends TmfEventRequest {
+ /**
+ * The find criteria.
+ */
final private Criteria fCriteria;
-
+ /**
+ * A progress monitor
+ */
private IProgressMonitor fMonitor;
+ /**
+ * Flag to indicate that node was found according the criteria .
+ */
private boolean fIsFound = false;
+ /**
+ * Time stamp of found item.
+ */
private ITmfTimestamp fFoundTime = null;
/**
@@ -1325,6 +1453,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Set progress monitor.
+ *
* @param monitor
*/
public void setMonitor(IProgressMonitor monitor) {
@@ -1333,6 +1462,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
/**
* Check if find criteria was met.
+ *
* @return true if find criteria was met.
*/
public boolean isFound() {
@@ -1340,6 +1470,8 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
}
/**
+ * Returns timestamp of found time.
+ *
* @return timestamp of found time.
*/
public ITmfTimestamp getFoundTime() {
@@ -1348,6 +1480,8 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
}
/**
+ * Returns sequence diagram event if details in given event are available else null.
+ *
* @param tmfEvent Event to parse for sequence diagram event details
* @return sequence diagram event if details are available else null
*/
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/messages.properties
similarity index 50%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/messages.properties
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/messages.properties
index a7b1167812..39d0bda3f9 100644
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/messages.properties
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/messages.properties
@@ -1,3 +1,14 @@
+###############################################################################
+# Copyright (c) 2011, 2012 Ericsson
+#
+# All rights reserved. This program and the accompanying materials are
+# made available under the terms of the Eclipse Public License v1.0 which
+# accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Bernd Hufmann - Initial API and implementation
+###############################################################################
TmfUml2SDSyncLoader_ViewName=Component Interactions
TmfUml2SDSyncLoader_CategoryLifeline=Lifeline
TmfUml2SDSyncLoader_CategoryMessage=Interaction
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/ISDPreferences.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/ISDPreferences.java
similarity index 84%
rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/ISDPreferences.java
rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/ISDPreferences.java
index b0bb347e09..e7e8ac8a66 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/drawings/ISDPreferences.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/ISDPreferences.java
@@ -1,18 +1,25 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: ISDPreferences.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
* Bernd Hufmann - Updated for TMF
**********************************************************************/
-package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings;
+package org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences;
+
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont;
/**
+ * Interface for accessing sequence diagram preferences.
+ *
+ * @version 1.0
* @author sveyrier
*
*/
@@ -82,7 +89,7 @@ public interface ISDPreferences {
/**
* Returns the background color for the given preference name (font preference name)
*
- * @param prefId the preference nam
+ * @param prefId The preference name
* @return the color
*/
public IColor getBackGroundColor(String prefId);
@@ -90,15 +97,15 @@ public interface ISDPreferences {
/**
* Returns the foreground color for the given preference name (font preference name)
*
- * @param prefId
- * @return the color
+ * @param prefId A preference name
+ * @return the color
*/
public IColor getForeGroundColor(String prefId);
/**
* Returns the font color for the given preference name (font preference name)
*
- * @param prefId
+ * @param prefId A preference name
* @return the color
*/
public IColor getFontColor(String prefId);
@@ -121,17 +128,22 @@ public interface ISDPreferences {
/**
* Returns the background color used to draw selection
*
- * @return the color
+ * @return the background color
*/
public IColor getBackGroundColorSelection();
/**
* Returns the foreground color used to draw selection
*
- * @return the color
+ * @return the foreground color
*/
public IColor getForeGroundColorSelection();
+ /**
+ * Returns whether to use gradient color or not
+ *
+ * @return whether to use gradient color or not
+ */
public boolean useGradienColor();
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java
index 3fc0f8f555..a4a5e55f77 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewPref.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDViewPref.java,v 1.3 2008/01/24 02:28:51 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -22,7 +23,6 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont;
-import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl.ColorImpl;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl.FontImpl;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
@@ -33,44 +33,99 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
/**
- * This is the Sequence Diagram preference handler This class is responsible for accessing the current user preferences
- * selection This class also provider getters for each modifiable preferences
+ * This is the Sequence Diagram preference handler. This class is responsible for accessing the current user preferences
+ * selection This class also provider getters for each modifiable preferences.
*
+ * @version 1.0
* @author sveyrier
*/
public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Postfix string for background color property
+ */
public static final String BACK_COLOR_POSTFIX = "_BACK_COLOR";//$NON-NLS-1$
+ /**
+ * Postfix string for foreground color property
+ */
public static final String FORE_COLOR_POSTFIX = "_FORE_COLOR";//$NON-NLS-1$
+ /**
+ * Postfix string for text color property
+ */
public static final String TEXT_COLOR_POSTFIX = "_TEXT_COLOR";//$NON-NLS-1$
-
+ /**
+ * Array of preference names
+ */
private static final String[] fontList = { PREF_LIFELINE, PREF_EXEC, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_FRAME, PREF_LIFELINE_HEADER, PREF_FRAME_NAME };
-
+ /**
+ * A 2nd array of preference names
+ */
private static final String[] fontList2 = { SDMessages._88, SDMessages._89, SDMessages._90, SDMessages._91, SDMessages._92, SDMessages._93, SDMessages._94, SDMessages._95, SDMessages._96 };
-
+ /**
+ * Array of background color preference names
+ */
private static final String[] prefBackColorList = { PREF_LIFELINE, PREF_EXEC, PREF_FRAME, PREF_LIFELINE_HEADER, PREF_FRAME_NAME };
-
+ /**
+ * Array of foreground color preference names
+ */
private static final String[] prefForeColorList = { PREF_LIFELINE, PREF_EXEC, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_FRAME, PREF_LIFELINE_HEADER, PREF_FRAME_NAME };
-
+ /**
+ * Array of text color preference names
+ */
private static final String[] prefTextColorList = { PREF_LIFELINE, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_LIFELINE_HEADER, PREF_FRAME_NAME };
+ /**
+ * Temporary tag
+ */
+ protected static final String TEMP_TAG = "_TEMP";//$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The sequence diagram preferences singleton instance
+ */
+ private static SDViewPref handle = null;
+ /**
+ * Hashtable for font preferences
+ */
protected Hashtable fontPref;
+ /**
+ * Hashtable for foreground color preferences
+ */
protected Hashtable foreColorPref;
+ /**
+ * Hashtable for background color preferences
+ */
protected Hashtable backColorPref;
+ /**
+ * Hashtable for text color preferences
+ */
protected Hashtable textColorPref;
-
- private static SDViewPref handle = null;
+ /**
+ * The reference to the preference store.
+ */
protected IPreferenceStore prefStore = null;
+ /**
+ * Color for the time compression selection
+ */
protected IColor timeCompressionSelectionColor = null;
+ /**
+ * Flag whether no focus selection or not.
+ */
protected boolean noFocusSelection = false;
- protected static final String TEMP_TAG = "_TEMP";//$NON-NLS-1$
-
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
* Builds the Sequence Diagram preference handler: - Define the preference default values. - Load the currently used
* preferences setting
- *
*/
protected SDViewPref() {
prefStore = TmfUiPlugin.getDefault().getPreferenceStore();
@@ -100,14 +155,15 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
for (int i = 0; i < prefBackColorList.length; i++) {
IColor color;
- if ((prefBackColorList[i].equals(PREF_EXEC)) || prefBackColorList[i].equals(PREF_FRAME_NAME))
+ if ((prefBackColorList[i].equals(PREF_EXEC)) || prefBackColorList[i].equals(PREF_FRAME_NAME)) {
color = new ColorImpl(Display.getDefault(), 201, 222, 233);
- else if (prefBackColorList[i].equals(PREF_LIFELINE))
+ } else if (prefBackColorList[i].equals(PREF_LIFELINE)) {
color = new ColorImpl(Display.getDefault(), 220, 220, 220);
- else if (prefBackColorList[i].equals(PREF_LIFELINE_HEADER))
+ } else if (prefBackColorList[i].equals(PREF_LIFELINE_HEADER)) {
color = new ColorImpl(Display.getDefault(), 245, 244, 244);
- else
+ } else {
color = new ColorImpl(Display.getDefault(), 255, 255, 255);
+ }
PreferenceConverter.setDefault(prefStore, prefBackColorList[i] + BACK_COLOR_POSTFIX, ((Color) color.getColor()).getRGB());
PreferenceConverter.setDefault(prefStore, prefBackColorList[i] + BACK_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB());
color.dispose();
@@ -115,14 +171,15 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
for (int i = 0; i < prefForeColorList.length; i++) {
IColor color;
- if (prefForeColorList[i].equals(PREF_LIFELINE))
+ if (prefForeColorList[i].equals(PREF_LIFELINE)) {
color = new ColorImpl(Display.getDefault(), 129, 129, 129);
- else if (prefForeColorList[i].equals(PREF_FRAME_NAME))
+ } else if (prefForeColorList[i].equals(PREF_FRAME_NAME)) {
color = new ColorImpl(Display.getDefault(), 81, 153, 200);
- else if (prefForeColorList[i].equals(PREF_LIFELINE_HEADER))
+ } else if (prefForeColorList[i].equals(PREF_LIFELINE_HEADER)) {
color = new ColorImpl(Display.getDefault(), 129, 127, 137);
- else
+ } else {
color = new ColorImpl(Display.getDefault(), 134, 176, 212);
+ }
PreferenceConverter.setDefault(prefStore, prefForeColorList[i] + FORE_COLOR_POSTFIX, ((Color) color.getColor()).getRGB());
PreferenceConverter.setDefault(prefStore, prefForeColorList[i] + FORE_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB());
color.dispose();
@@ -130,14 +187,15 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
for (int i = 0; i < prefTextColorList.length; i++) {
IColor color;
- if (prefTextColorList[i].equals(PREF_LIFELINE))
+ if (prefTextColorList[i].equals(PREF_LIFELINE)) {
color = new ColorImpl(Display.getDefault(), 129, 129, 129);
- else if (prefTextColorList[i].equals(PREF_FRAME_NAME))
+ } else if (prefTextColorList[i].equals(PREF_FRAME_NAME)) {
color = new ColorImpl(Display.getDefault(), 0, 0, 0);
- else if (prefTextColorList[i].equals(PREF_LIFELINE_HEADER))
+ } else if (prefTextColorList[i].equals(PREF_LIFELINE_HEADER)) {
color = new ColorImpl(Display.getDefault(), 129, 127, 137);
- else
+ } else {
color = new ColorImpl(Display.getDefault(), 134, 176, 212);
+ }
PreferenceConverter.setDefault(prefStore, prefTextColorList[i] + TEXT_COLOR_POSTFIX, ((Color) color.getColor()).getRGB());
PreferenceConverter.setDefault(prefStore, prefTextColorList[i] + TEXT_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB());
color.dispose();
@@ -174,88 +232,83 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
*
* @return the preference handler instance
*/
- static public SDViewPref getInstance() {
- if (handle == null)
+ public static synchronized SDViewPref getInstance() {
+ if (handle == null) {
handle = new SDViewPref();
+ }
return handle;
}
- /**
- * Returns the chosen foreground color
- *
- * @return the foreground color
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getForeGroundColor(java.lang.String)
*/
@Override
public IColor getForeGroundColor(String prefName) {
- if ((foreColorPref.get(prefName + FORE_COLOR_POSTFIX) != null) && (foreColorPref.get(prefName + FORE_COLOR_POSTFIX) instanceof ColorImpl))
+ if ((foreColorPref.get(prefName + FORE_COLOR_POSTFIX) != null) && (foreColorPref.get(prefName + FORE_COLOR_POSTFIX) instanceof ColorImpl)) {
return (IColor) foreColorPref.get(prefName + FORE_COLOR_POSTFIX);
- else
- return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
+ }
+ return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
}
- /**
- * Returns the chosen background color
- *
- * @return the background color
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getBackGroundColor(java.lang.String)
*/
@Override
public IColor getBackGroundColor(String prefName) {
- if ((backColorPref.get(prefName + BACK_COLOR_POSTFIX) != null) && (backColorPref.get(prefName + BACK_COLOR_POSTFIX) instanceof ColorImpl))
+ if ((backColorPref.get(prefName + BACK_COLOR_POSTFIX) != null) && (backColorPref.get(prefName + BACK_COLOR_POSTFIX) instanceof ColorImpl)) {
return (IColor) backColorPref.get(prefName + BACK_COLOR_POSTFIX);
- else
- return ColorImpl.getSystemColor(SWT.COLOR_WHITE);
+ }
+ return ColorImpl.getSystemColor(SWT.COLOR_WHITE);
}
- /**
- * Returns the chosen font color
- *
- * @return the font color
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getFontColor(java.lang.String)
*/
@Override
public IColor getFontColor(String prefName) {
- if ((textColorPref.get(prefName + TEXT_COLOR_POSTFIX) != null) && (textColorPref.get(prefName + TEXT_COLOR_POSTFIX) instanceof ColorImpl))
+ if ((textColorPref.get(prefName + TEXT_COLOR_POSTFIX) != null) && (textColorPref.get(prefName + TEXT_COLOR_POSTFIX) instanceof ColorImpl)) {
return (IColor) textColorPref.get(prefName + TEXT_COLOR_POSTFIX);
- else
- return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
+ }
+ return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
}
- /**
- * Returns the foreground color to use for widget selection. This color is system dependent and not set using the
- * preference page
- *
- * @return the foreground color
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getForeGroundColorSelection()
*/
@Override
public IColor getForeGroundColorSelection() {
- if (noFocusSelection)
+ if (noFocusSelection) {
return ColorImpl.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
+ }
return ColorImpl.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
}
- /**
- * Returns the background color to use for widget selection. This color is system dependent and not set using the
- * preference page
- *
- * @return the background color
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getBackGroundColorSelection()
*/
@Override
public IColor getBackGroundColorSelection() {
- if (noFocusSelection)
+ if (noFocusSelection) {
return ColorImpl.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+ }
return ColorImpl.getSystemColor(SWT.COLOR_LIST_SELECTION);
}
- /**
- * Returns the chosen font
- *
- * @return the font
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getFont(java.lang.String)
*/
@Override
public IFont getFont(String prefName) {
- if ((fontPref.get(prefName) != null) && (fontPref.get(prefName) instanceof IFont))
+ if ((fontPref.get(prefName) != null) && (fontPref.get(prefName) instanceof IFont)) {
return (IFont) fontPref.get(prefName);
- else
- return FontImpl.getSystemFont();
+ }
+ return FontImpl.getSystemFont();
}
/**
@@ -295,20 +348,18 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
return prefStore.getBoolean(PREF_EXCLUDE_EXTERNAL_TIME);
}
- /**
- * Returns if the use gradient color has been chosen
- *
- * @return true if checked false otherwise
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#useGradienColor()
*/
@Override
public boolean useGradienColor() {
return prefStore.getBoolean(PREF_USE_GRADIENT);
}
- /**
- * Returns the color used to connect the time compression bar to the diagram graph node
- *
- * @return the selection color
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getTimeCompressionSelectionColor()
*/
@Override
public IColor getTimeCompressionSelectionColor() {
@@ -317,7 +368,6 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
/**
* Builds the new colors and fonts according the current user selection when the OK or Apply button is clicked
- *
*/
protected void buildFontsAndColors() {
@@ -325,35 +375,40 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
for (int i = 0; i < fontList.length; i++) {
FontData fontData = PreferenceConverter.getFontData(prefStore, fontList[i]);
- if ((fontPref.get(fontList[i]) != null) && (fontPref.get(fontList[i]) instanceof IFont))
+ if ((fontPref.get(fontList[i]) != null) && (fontPref.get(fontList[i]) instanceof IFont)) {
((IFont) fontPref.get(fontList[i])).dispose();
+ }
fontPref.put(fontList[i], new FontImpl(display, fontData));
}
for (int i = 0; i < prefBackColorList.length; i++) {
RGB rgb = PreferenceConverter.getColor(prefStore, prefBackColorList[i] + BACK_COLOR_POSTFIX);
- if ((backColorPref.get(prefBackColorList[i] + BACK_COLOR_POSTFIX) != null) && (backColorPref.get(prefBackColorList[i] + BACK_COLOR_POSTFIX) instanceof IColor))
+ if ((backColorPref.get(prefBackColorList[i] + BACK_COLOR_POSTFIX) != null) && (backColorPref.get(prefBackColorList[i] + BACK_COLOR_POSTFIX) instanceof IColor)) {
((IColor) backColorPref.get(prefBackColorList[i] + BACK_COLOR_POSTFIX)).dispose();
+ }
backColorPref.put(prefBackColorList[i] + BACK_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < prefForeColorList.length; i++) {
RGB rgb = PreferenceConverter.getColor(prefStore, prefForeColorList[i] + FORE_COLOR_POSTFIX);
- if ((foreColorPref.get(prefForeColorList[i] + FORE_COLOR_POSTFIX) != null) && (foreColorPref.get(prefForeColorList[i] + FORE_COLOR_POSTFIX) instanceof IColor))
+ if ((foreColorPref.get(prefForeColorList[i] + FORE_COLOR_POSTFIX) != null) && (foreColorPref.get(prefForeColorList[i] + FORE_COLOR_POSTFIX) instanceof IColor)) {
((IColor) foreColorPref.get(prefForeColorList[i] + FORE_COLOR_POSTFIX)).dispose();
+ }
foreColorPref.put(prefForeColorList[i] + FORE_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < prefTextColorList.length; i++) {
RGB rgb = PreferenceConverter.getColor(prefStore, prefTextColorList[i] + TEXT_COLOR_POSTFIX);
- if ((textColorPref.get(prefTextColorList[i] + TEXT_COLOR_POSTFIX) != null) && (textColorPref.get(prefTextColorList[i] + TEXT_COLOR_POSTFIX) instanceof IColor))
+ if ((textColorPref.get(prefTextColorList[i] + TEXT_COLOR_POSTFIX) != null) && (textColorPref.get(prefTextColorList[i] + TEXT_COLOR_POSTFIX) instanceof IColor)) {
((IColor) textColorPref.get(prefTextColorList[i] + TEXT_COLOR_POSTFIX)).dispose();
+ }
textColorPref.put(prefTextColorList[i] + TEXT_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
RGB rgb = PreferenceConverter.getColor(prefStore, PREF_TIME_COMP);
- if (timeCompressionSelectionColor != null)
+ if (timeCompressionSelectionColor != null) {
timeCompressionSelectionColor.dispose();
+ }
timeCompressionSelectionColor = new ColorImpl(display, rgb.red, rgb.green, rgb.blue);
}
@@ -371,8 +426,7 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
*/
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (!event.getProperty().equals("PREFOK")) //$NON-NLS-1$
- {
+ if (!event.getProperty().equals("PREFOK")) { //$NON-NLS-1$
buildFontsAndColors();
prefStore.firePropertyChangeEvent("PREFOK", null, null); //$NON-NLS-1$
}
@@ -383,6 +437,8 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
}
/**
+ * Returns the static font list.
+ *
* @return static font list
*/
public static String[] getFontList() {
@@ -390,6 +446,8 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
}
/**
+ * Returns the 2nd static font list.
+ *
* @return 2nd static font list
*/
public static String[] getFontList2() {
@@ -397,6 +455,8 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
}
/**
+ * Returns the preference background color list.
+ *
* @return preference background color list
*/
public static String[] getPrefBackColorList() {
@@ -404,6 +464,8 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
}
/**
+ * Returns the preference foreground color list.
+ *
* @return preference foreground color list
*/
public static String[] getPrefForeColorList() {
@@ -411,6 +473,8 @@ public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
}
/**
+ * Returns the preference text color list color list.
+ *
* @return preference text color list color list
*/
public static String[] getPrefTextColorList() {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java
index f41c191a9f..2c98b04967 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SDViewerPage.java,v 1.5 2008/01/24 02:28:51 apnan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -35,12 +36,24 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
- * The Sequence Diagram preferences page implementation
+ * The Sequence Diagram preferences page implementation.
*
+ * @version 1.0
* @author sveyrier
*/
public class SDViewerPage extends PreferencePage implements IWorkbenchPreferencePage, SelectionListener {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Temporary preferences tag
+ */
+ protected static final String TEMP_TAG = SDViewPref.TEMP_TAG;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
/**
* The preference handler used to access the PreferenceStore
*/
@@ -53,59 +66,60 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference
* Foreground color selector
*/
protected ColorFieldEditor backGroundColor = null;
-
/**
* Font color selector
*/
protected ColorFieldEditor textColor = null;
-
/**
* List which display all modifiable sequence Diagram font
*/
protected List classItemList = null;
-
/**
* Font selector (The same is used for each modifiable font)
*/
protected FontFieldEditor font = null;
-
/**
* Link font when zooming selector
*/
protected BooleanFieldEditor link = null;
-
/**
* Enable tooltip selector
*/
protected BooleanFieldEditor tooltip = null;
-
/**
* Do not take external time into account in the min max computation
*/
protected BooleanFieldEditor noExternalTime = null;
-
/**
* Use gradient color selector
*/
protected BooleanFieldEditor useGrad = null;
-
+ /**
+ * A button area.
+ */
protected Composite buttonArea;
-
/**
* SwimLane width selector
*/
protected IntegerFieldEditor lifelineWidth = null;
- protected static final String TEMP_TAG = SDViewPref.TEMP_TAG;
-
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public SDViewerPage() {
super();
}
- /**
- * Creates the Sequence Diagram preference page content
- *
- * @param parent the parent composite
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
@@ -198,13 +212,18 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference
return page;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
@Override
public void init(IWorkbench workbench) {
pref = SDViewPref.getInstance();
}
- /**
- * Apply the modification performed in the Sequence diagram preference page
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performApply()
*/
@Override
protected void performApply() {
@@ -228,19 +247,19 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference
swapPref(true);
}
- /**
- * Apply the modification performed in the Sequence diagram preference page
- *
- * @return true
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
*/
@Override
public boolean performOk() {
performApply();
return true;
}
-
- /**
- * Loads the Sequence diagram default preference settings
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
@Override
protected void performDefaults() {
@@ -312,10 +331,9 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference
textColor.load();
}
- /**
- * Sent when a new selection occurs in the graphNode font list
- *
- * @param e the selection event
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
@@ -343,21 +361,24 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference
// No Background for message graphNodes
if ((fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_SYNC_MESS)) || (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_SYNC_MESS_RET))
- || (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_ASYNC_MESS)) || (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_ASYNC_MESS_RET)))
+ || (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_ASYNC_MESS)) || (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_ASYNC_MESS_RET))) {
backGroundColor.setEnabled(false, buttonArea);
- else
+ } else {
backGroundColor.setEnabled(true, buttonArea);
+ }
// No font used for execution occurrence and global frame
- if ((fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_EXEC)) || (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_FRAME)))
+ if ((fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_EXEC)) || (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_FRAME))) {
textColor.setEnabled(false, buttonArea);
- else
+ } else {
textColor.setEnabled(true, buttonArea);
+ }
- if (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_FRAME))
+ if (fontList[classItemList.getSelectionIndex()].equals(SDViewPref.PREF_FRAME)) {
font.setEnabled(false, buttonArea);
- else
+ } else {
font.setEnabled(true, buttonArea);
+ }
}
protected void swapPref(boolean toTemp) {
@@ -389,7 +410,6 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference
backGroundColor.setPreferenceName((String) prefName + TAG2);
backGroundColor.store();
}
-
}
keySet = SDViewPref.getInstance().foreColorPref.keySet();
@@ -432,6 +452,10 @@ public class SDViewerPage extends PreferencePage implements IWorkbenchPreference
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDMessages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDMessages.java
index 8f5e318d1f..b9b6630c3a 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDMessages.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SDMessages.java
@@ -1,5 +1,7 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java
index e70abc6a9c..12e31d5b68 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncForBackward.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SortAsyncForBackward.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -19,27 +20,34 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
/**
- * Asynchronous message comparator
+ * Asynchronous message comparator.
*
* Compares two asyncMessages only taking into account the event occurrence when their
* appear.
*
* Used to order the AsyncMessage list insuring that the previous node has both of his ends smaller than the current node
*
+ * @version 1.0
* @author sveyrier
*
*/
public class SortAsyncForBackward implements Comparator, Serializable {
-
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
/**
* Serial version UID
*/
private static final long serialVersionUID = 603959931263853359L;
- /**
- * Compares two asynchronous messages Returns 0 (equal) if one of the message is not asynchronous
- *
- * @return 1 if arg0 is greater, 0 if equal, -1 otherwise
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(GraphNode arg0, GraphNode arg1) {
@@ -49,39 +57,46 @@ public class SortAsyncForBackward implements Comparator, Serializable
int m1Max, m2Max;
// AsyncMessage has two ends which may have different event occurrences
// Search for the greater event occurrence for each messages
- if (m1.getStartOccurrence() > m1.getEndOccurrence())
+ if (m1.getStartOccurrence() > m1.getEndOccurrence()) {
m1Max = m1.getStartOccurrence();
- else
+ } else {
m1Max = m1.getEndOccurrence();
- if (m2.getStartOccurrence() > m2.getEndOccurrence())
+ }
+ if (m2.getStartOccurrence() > m2.getEndOccurrence()) {
m2Max = m2.getStartOccurrence();
- else
+ } else {
m2Max = m2.getEndOccurrence();
+ }
int m1Min, m2Min;
// Search for the smaller event occurrence for each messages
- if (m1.getStartOccurrence() > m1.getEndOccurrence())
+ if (m1.getStartOccurrence() > m1.getEndOccurrence()) {
m1Min = m1.getEndOccurrence();
- else
+ } else {
m1Min = m1.getStartOccurrence();
- if (m2.getStartOccurrence() > m2.getEndOccurrence())
+ }
+ if (m2.getStartOccurrence() > m2.getEndOccurrence()) {
m2Min = m2.getEndOccurrence();
- else
+ } else {
m2Min = m2.getStartOccurrence();
+ }
- if (m1Max > m2Max)
+ if (m1Max > m2Max) {
return 1;
- else if (m1Max == m2Max)
- if (m1Min == m2Min)
+ } else if (m1Max == m2Max) {
+ if (m1Min == m2Min) {
return 0;
- else if (m1Min > m2Min)
+ } else if (m1Min > m2Min) {
return -1;
- else
+ } else {
return 1;
- else
+ }
+ } else {
return -1;
- } else
+ }
+ } else {
return 0;
+ }
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java
index 259e014cff..3a52094c19 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortAsyncMessageComparator.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SortAsyncMessageComparator.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -24,20 +25,26 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
*
* Used to order the AsyncMessage list insuring that next node has one of his ends greater than the current node
*
+ * @version 1.0
* @author sveyrier
*
*/
public class SortAsyncMessageComparator implements Comparator, Serializable {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
/**
* Serial version UID
*/
private static final long serialVersionUID = 1L;
- /**
- * Compares two synchronous syncMessages Returns 0 (equal) if one of the message is not synchronous
- *
- * @return 1 if arg0 is greater, 0 if equal, -1 otherwise
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(GraphNode arg0, GraphNode arg1) {
@@ -47,39 +54,46 @@ public class SortAsyncMessageComparator implements Comparator, Serial
int m1Min, m2Min;
// AsyncMessage has two ends which may have different event occurrences
// Search for the smaller event occurrence for each messages
- if (m1.getStartOccurrence() > m1.getEndOccurrence())
+ if (m1.getStartOccurrence() > m1.getEndOccurrence()) {
m1Min = m1.getEndOccurrence();
- else
+ } else {
m1Min = m1.getStartOccurrence();
- if (m2.getStartOccurrence() > m2.getEndOccurrence())
+ }
+ if (m2.getStartOccurrence() > m2.getEndOccurrence()) {
m2Min = m2.getEndOccurrence();
- else
+ } else {
m2Min = m2.getStartOccurrence();
+ }
int m1Max, m2Max;
// Search for the greater event occurrence for each messages
- if (m1.getStartOccurrence() > m1.getEndOccurrence())
+ if (m1.getStartOccurrence() > m1.getEndOccurrence()) {
m1Max = m1.getStartOccurrence();
- else
+ } else {
m1Max = m1.getEndOccurrence();
- if (m2.getStartOccurrence() > m2.getEndOccurrence())
+ }
+ if (m2.getStartOccurrence() > m2.getEndOccurrence()) {
m2Max = m2.getStartOccurrence();
- else
+ } else {
m2Max = m2.getEndOccurrence();
+ }
- if (m1Min > m2Min)
+ if (m1Min > m2Min) {
return 1;
- else if ((m1Min == m2Min))
- if (m1Max == m2Max)
+ } else if ((m1Min == m2Min)) {
+ if (m1Max == m2Max) {
return 0;
- else if (m1Max > m2Max)
+ } else if (m1Max > m2Max) {
return -1;
- else
+ } else {
return 1;
- else
+ }
+ } else {
return -1;
- } else
+ }
+ } else {
return 0;
+ }
}
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java
index 852e7d98a2..0036a89887 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/SortSyncMessageComparator.java
@@ -1,10 +1,11 @@
/**********************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: SortSyncMessageComparator.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -29,29 +30,35 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
*/
public class SortSyncMessageComparator implements Comparator, Serializable {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
/**
* Serial version UID
*/
private static final long serialVersionUID = 4781250984753283718L;
- /**
- * Compares two synchronous syncMessages. Returns 0 (equal) if one of the message is not synchronous
- *
- * @return 1 if arg0 is greater, 0 if equal, -1 otherwise
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(GraphNode arg0, GraphNode arg1) {
if (arg0 instanceof SyncMessage && arg1 instanceof SyncMessage) {
SyncMessage m1 = (SyncMessage) arg0;
SyncMessage m2 = (SyncMessage) arg1;
- if (m1.getEventOccurrence() > m2.getEventOccurrence())
+ if (m1.getEventOccurrence() > m2.getEventOccurrence()) {
return 1;
- else if (m1.getEventOccurrence() == m2.getEventOccurrence())
+ } else if (m1.getEventOccurrence() == m2.getEventOccurrence()) {
return 0;
- else
+ } else {
return -1;
- } else
+ }
+ } else {
return 0;
+ }
}
-
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java
index 58247eac6f..b6228df0d1 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/TimeEventComparator.java
@@ -1,10 +1,11 @@
/**********************************************************************
- * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 Ericsson.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id: TimeEventComparator.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
*
* Contributors:
* IBM - Initial API and implementation
@@ -25,26 +26,33 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SDTimeEvent;
*/
public class TimeEventComparator implements Comparator, Serializable {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
/**
* Serial version UID
*/
private static final long serialVersionUID = 5885497718872575669L;
- /**
- * Compares two time events.
- *
- * @return 1 if arg0 is greater, 0 if equal, -1 otherwise
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(SDTimeEvent arg0, SDTimeEvent arg1) {
SDTimeEvent t1 = (SDTimeEvent) arg0;
SDTimeEvent t2 = (SDTimeEvent) arg1;
- if (t1.getEvent() > t2.getEvent())
+ if (t1.getEvent() > t2.getEvent()) {
return 1;
- else if (t1.getEvent() == t2.getEvent())
+ }
+ else if (t1.getEvent() == t2.getEvent()) {
return 0;
- else
- return -1;
+ }
+ return -1;
}
-
}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/messages.properties
index d427f461b2..b27ec00e78 100755
--- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/messages.properties
+++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/messages.properties
@@ -1,10 +1,11 @@
###############################################################################
-# Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
+# Copyright (c) 2005, 2008 IBM Corporation and others.
+# Copyright (c) 2011, 2012 Ericsson.
+#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
-# $Id: messages.properties,v 1.9 2008/05/14 19:40:36 jkubasta Exp $
#
# Contributors:
# IBM Corporation - initial API and implementation
--
2.34.1