tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / SDWidget.java
index a3722d6c45eecf34bc943969239292f3ebf2da50..3001b30e845b69748a8af721876c755d00d7a63c 100755 (executable)
@@ -1,16 +1,15 @@
 /**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- * 
+ * Copyright (c) 2005, 2013 IBM Corporation, 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: 
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *     Bernd Hufmann - Updated for TMF
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
 
 import java.text.MessageFormat;
@@ -19,17 +18,14 @@ 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;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
-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.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
@@ -83,12 +79,12 @@ import org.eclipse.ui.part.ViewPart;
  * <p>
  * This class implements sequence diagram widget used in the sequence diagram view.
  * </p>
- * 
- * @version 1.0 
+ *
+ * @version 1.0
  * @author sveyrier
- * 
  */
-public class SDWidget extends ScrollView implements SelectionListener, IPropertyChangeListener, DisposeListener, ITimeCompressionListener {
+public class SDWidget extends ScrollView implements SelectionListener,
+        IPropertyChangeListener, DisposeListener, ITimeCompressionListener {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -103,59 +99,59 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
      */
     protected Image fOverView = null;
     /**
-     * The zoom in menu item. 
+     * The zoom in menu item.
      */
     protected MenuItem fZoomIn = null;
     /**
-     * The zoom out menu item. 
+     * The zoom out menu item.
      */
     protected MenuItem fZoomOut = null;
     /**
-     * The sequence diagram selection provider. 
+     * The sequence diagram selection provider.
      */
     protected SDWidgetSelectionProvider fSelProvider = null;
     /**
-     * The current zoom value. 
+     * The current zoom value.
      */
     public float fZoomValue = 1;
     /**
-     * The current zoomInMode (true for zoom in). 
+     * The current zoomInMode (true for zoom in).
      */
     protected boolean fZoomInMode = false;
     /**
-     * The current zoomOutMode (true for zoom out). 
+     * The current zoomOutMode (true for zoom out).
      */
     protected boolean fZoomOutMode = false;
     /**
-     * The current list of selected graph nodes. 
+     * The current list of selected graph nodes.
      */
     protected List<GraphNode> fSelectedNodeList = null;
     /**
-     * Flag whether ctrl button is selected or not. 
+     * Flag whether ctrl button is selected or not.
      */
     protected boolean fCtrlSelection = false;
     /**
-     * A reference to the view site. 
+     * A reference to the view site.
      */
     protected ViewPart fSite = null;
     /**
-     * The current graph node (the last selected one). 
+     * The current graph node (the last selected one).
      */
     public GraphNode fCurrentGraphNode = null;
     /**
-     * The first graph node in list (multiple selection). 
+     * The first graph node in list (multiple selection).
      */
     public GraphNode fListStart = null;
     /**
-     * The previous graph node (multiple selection). 
+     * The previous graph node (multiple selection).
      */
     public List<GraphNode> fPrevList = null;
     /**
-     * The time compression bar.  
+     * The time compression bar.
      */
     protected TimeCompressionBar fTimeBar = null;
     /**
-     * The current diagram tool tip. 
+     * The current diagram tool tip.
      */
     protected DiagramToolTip fToolTip = null;
     /**
@@ -171,7 +167,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
      */
     protected Lifeline fDragAndDrop = null;
     /**
-     * The number of focused widgets. 
+     * The number of focused widgets.
      */
     protected int fFocusedWidget = -1;
     /**
@@ -187,7 +183,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
      */
     protected int fPrinterX = 0;
     /**
-     * Flag whether drag and drop is enabled or not. 
+     * Flag whether drag and drop is enabled or not.
      */
     protected boolean fIsDragAndDrop = false;
     /**
@@ -235,19 +231,19 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
      */
     protected Printer fPrinter = null;
     /**
-     * Flag whether shift was selected or not. 
+     * Flag whether shift was selected or not.
      */
     protected boolean fShiftSelection = false;
     /**
-     * The scroll tooltip. 
+     * The scroll tooltip.
      */
     protected DiagramToolTip fScrollToolTip = null;
-    /** 
-     * Timer for auto_scroll feature 
+    /**
+     * Timer for auto_scroll feature
      */
     protected AutoScroll fLocalAutoScroll = null;
     /**
-     * TimerTask for auto_scroll feature !=null when auto scroll is running 
+     * TimerTask for auto_scroll feature !=null when auto scroll is running
      */
     protected Timer fLocalAutoScrollTimer = null;
 
@@ -370,8 +366,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
                     e.detail |= ACC.STATE_FOCUSED;
                 } else {
                     e.detail |= ACC.STATE_SELECTABLE;
-                    if (e.childID == fFocusedWidget)
+                    if (e.childID == fFocusedWidget) {
                         e.detail |= ACC.STATE_FOCUSED | ACC.STATE_SELECTED | ACC.STATE_CHECKED;
+                    }
                 }
             }
         });
@@ -379,8 +376,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         fInsertionCartet = new Caret((Canvas) getViewControl(), SWT.NONE);
         fInsertionCartet.setVisible(false);
 
-        fCollapaseCaretImg = TmfUiPlugin.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ);
-        fArrowUpCaretImg = TmfUiPlugin.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ);
+        fCollapaseCaretImg = Activator.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_COLLAPSE_OBJ);
+        fArrowUpCaretImg = Activator.getDefault().getImageFromPath(ITmfImageConstants.IMG_UI_ARROW_UP_OBJ);
 
         fReorderList = new ArrayList<Lifeline[]>();
         getViewControl().addTraverseListener(new LocalTraverseListener());
@@ -412,13 +409,13 @@ 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) {
@@ -427,10 +424,10 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             fTimeBar.addTimeCompressionListener(this);
         }
     }
-    
+
     /**
      * Resize the contents to insure the frame fit into the view
-     * 
+     *
      * @param frame the frame which will be drawn in the view
      */
     public void resizeContents(Frame frame) {
@@ -441,7 +438,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * The frame to render (the sequence diagram)
-     * 
+     *
      * @param theFrame the frame to display
      * @param resetPosition boolean
      */
@@ -465,8 +462,8 @@ 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 fFrame;
@@ -474,16 +471,16 @@ 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 fSelProvider;
     }
-    
+
     /**
      * Returns a list of selected graph nodes.
-     * 
+     *
      * @return a list of selected graph nodes.
      */
     public List<GraphNode> getSelection() {
@@ -492,7 +489,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Adds a graph node to the selected nodes list.
-     * 
+     *
      * @param node A graph node
      */
     public void addSelection(GraphNode node) {
@@ -508,7 +505,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Adds a list of node to the selected nodes list.
-     *  
+     *
      * @param list of graph nodes
      */
     public void addSelection(List<GraphNode> list) {
@@ -516,7 +513,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         for (int i = 0; i < list.size(); i++) {
             if (!fSelectedNodeList.contains(list.get(i))) {
                 fSelectedNodeList.add(list.get(i));
-                ((GraphNode) list.get(i)).setSelected(true);
+                list.get(i).setSelected(true);
             }
         }
         StructuredSelection selection = new StructuredSelection(fSelectedNodeList);
@@ -525,7 +522,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Removes a node from the selected nodes list.
-     * 
+     *
      * @param node to remove
      */
     public void removeSelection(GraphNode node) {
@@ -538,14 +535,14 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Removes a list of graph nodes from the selected nodes list.
-     * 
+     *
      * @param list of nodes to remove.
      */
     public void removeSelection(List<GraphNode> list) {
         fSelectedNodeList.removeAll(list);
         for (int i = 0; i < list.size(); i++) {
-            ((GraphNode) list.get(i)).setSelected(false);
-            ((GraphNode) list.get(i)).setFocused(false);
+            list.get(i).setSelected(false);
+            list.get(i).setFocused(false);
         }
         StructuredSelection selection = new StructuredSelection(fSelectedNodeList);
         fSelProvider.setSelection(selection);
@@ -556,8 +553,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
      */
     public void clearSelection() {
         for (int i = 0; i < fSelectedNodeList.size(); i++) {
-            ((GraphNode) fSelectedNodeList.get(i)).setSelected(false);
-            ((GraphNode) fSelectedNodeList.get(i)).setFocused(false);
+            fSelectedNodeList.get(i).setSelected(false);
+            fSelectedNodeList.get(i).setFocused(false);
         }
         fCurrentGraphNode = null;
         fSelectedNodeList.clear();
@@ -566,7 +563,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Sets view part.
-     *  
+     *
      * @param viewSite The view part to set
      */
     public void setSite(ViewPart viewSite) {
@@ -579,17 +576,18 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Returns the GraphNode overView the mouse if any
-     * 
-     * @return the current graph node 
+     *
+     * @return the current graph node
      * */
     public GraphNode getMouseOverNode() {
         return fCurrentGraphNode;
     }
-    
+
     /**
      * Sets the zoom in mode.
-     * 
-     * @param The mode value to set. 
+     *
+     * @param value
+     *            The mode value to set.
      */
     public void setZoomInMode(boolean value) {
         if (value) {
@@ -600,8 +598,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Sets the zoom out mode.
-     * 
-     * @param The mode value to set.
+     *
+     * @param value
+     *            The mode value to set.
      */
     public void setZoomOutMode(boolean value) {
         if (value) {
@@ -612,7 +611,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * 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) {
@@ -626,7 +625,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Moves the Sequence diagram to ensure the given node is visible
-     * 
+     *
      * @param node the GraphNode to move to
      */
     public void ensureVisible(GraphNode node) {
@@ -664,7 +663,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Returns teh printer reference.
-     * 
+     *
      * @return the printer reference
      */
     public Printer getPrinter() {
@@ -673,7 +672,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Returns whether the widget is used for printing or not.
-     * 
+     *
      * @return whether the widget is used for printing or not
      */
     public boolean isPrinting() {
@@ -682,7 +681,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Gets the overview image.
-     * 
+     *
      * @param rect Rectangle to include overview.
      * @return the overview image
      */
@@ -699,7 +698,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             fOverView = new Image(getDisplay(), rect.width, rect.height);
             GC gcim = new GC(fOverView);
             NGC context = new NGC(this, gcim);
-            context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+            context.setBackground(SDViewPref.getInstance().getBackGroundColor(ISDPreferences.PREF_FRAME));
             fFrame.draw(context);
             setContentsPos(backX, backY);
             gcim.dispose();
@@ -708,7 +707,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         fZoomValue = oldzoom;
         return fOverView;
     }
-    
+
     /**
      * Resets the zoom factor.
      */
@@ -726,7 +725,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Enable or disable the lifeline reodering using Drag and Drop
-     * 
+     *
      * @param mode - true to enable false otherwise
      */
     public void setReorderMode(boolean mode) {
@@ -736,8 +735,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
     /**
      * 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 
+     *
+     * @return - the re-odered sequence
      */
     public List<Lifeline[]> getLifelineReoderList() {
         return fReorderList;
@@ -745,8 +744,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Sets the focus on given graph node (current node).
-     * 
-     * @param the graph node to focus on.
+     *
+     * @param node
+     *            The graph node to focus on.
      */
     public void setFocus(GraphNode node) {
         if (node == null) {
@@ -763,7 +763,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Returns the graph node focused on.
-     * 
+     *
      * @return the current graph node
      */
     public GraphNode getFocusNode() {
@@ -898,7 +898,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             traverseLeft();
         }
         GraphNode node = null;
-        
+
         if (selectedNode instanceof BaseMessage) {
             if (((BaseMessage) selectedNode).getStartLifeline() != null) {
                 node = fFrame.getNextLifelineMessage(((BaseMessage) selectedNode).getStartLifeline(), null);
@@ -954,7 +954,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Method to print UI.
-     * 
+     *
      * @param sdPrintDialog the sequence diagram printer dialog.
      */
     public void printUI(SDPrintDialogUI sdPrintDialog) {
@@ -963,12 +963,12 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         if ((data == null) || (fFrame == null)) {
             return;
         }
-        
+
         fPrinter = new Printer(data);
-        
+
         String jobName = MessageFormat.format(SDMessages._116, new Object[] { String.valueOf(fSite.getContentDescription()), String.valueOf(fFrame.getName()) });
         fPrinter.startJob(jobName);
-        
+
         GC gc = new GC(fPrinter);
 //        Frame.setUserPref(SDViewPref.getInstance());
 
@@ -982,16 +982,16 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
         // 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.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
+        Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
         Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
         Metrics.setFrameFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_FRAME_NAME)));
         Metrics.setLifelineHeaderFontHeight(context.getFontHeight(SDViewPref.getInstance().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 syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS));
+        int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS_RET));
+        int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS));
+        int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS_RET));
 
         int messageFontHeight = 0;
         if (syncMessFontH > syncMessRetFontH) {
@@ -1006,7 +1006,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             messageFontHeight = asyncMessRetFontH;
         }
         Metrics.setMessageFontHeight(messageFontHeight);
-        context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+        context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
 
         int width = Math.round((fFrame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * fZoomValue);
         int height = Math.round((fFrame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * fZoomValue);
@@ -1081,7 +1081,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
                 return;
             }
         } catch (Exception e) {
-            TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error creating image", e)); //$NON-NLS-1$
+            Activator.getDefault().logError("Error creating image", e); //$NON-NLS-1$
             return;
         }
         printUI(sdPrinter.getDialogUI());
@@ -1089,7 +1089,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Method to print a page.
-     * 
+     *
      * @param pageNum The page number
      * @param pd The sequence diagram print dialog
      * @param context The graphical context
@@ -1116,12 +1116,17 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * 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
+     *
+     * @param i
+     *            The start page
+     * @param j
+     *            The end page
+     * @param pd
+     *            The sequence diagram print dialog
+     * @param context
+     *            The graphical context
+     * @param pageNum
+     *            The current page
      */
     public void printPage(int i, int j, SDPrintDialogUI pd, NGC context, int pageNum) {
         fIsPrinting = false;
@@ -1137,7 +1142,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         fFrame.draw(context);
 
         fZoomValue = pageNumFontZoom;
-        context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+        context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
         String currentPageNum = String.valueOf(pageNum);
         int ii = context.textExtent(currentPageNum);
         int jj = context.getCurrentFontHeight();
@@ -1148,20 +1153,20 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         fIsPrinting = false;
         fZoomValue = lastZoom;
     }
-    
+
     /**
      * Sets the collapse provider.
-     * 
+     *
      * @param provider The collapse provider to set
      */
     protected void setCollapseProvider(ISDCollapseProvider provider) {
         fCollapseProvider = provider;
     }
 
-    
+
     /**
      * Checks for focus of children.
-     * 
+     *
      * @param children Control to check
      * @return true if child is on focus else false
      */
@@ -1171,9 +1176,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             for (int i = 0; i < child.length; i++) {
                 if (child[i].isFocusControl()) {
                     return true;
-                } else {
-                    checkFocusOnChilds(child[i]);
                 }
+                checkFocusOnChilds(child[i]);
             }
         }
         return false;
@@ -1181,61 +1185,52 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * A post action for a tooltip (before displaying).
-     *  
+     *
      * @param accessible true if accessible else false
      * @return the tooltip text.
      */
     protected String getPostfixForTooltip(boolean accessible) {
         StringBuffer postfix = new StringBuffer();
-//        String postfix = "";//$NON-NLS-1$
         // Determine if the tooltip must show the time difference between the current mouse position and
         // the last selected graphNode
-        if ((fCurrentGraphNode != null) && 
-                (fCurrentGraphNode instanceof ITimeRange) && 
-                (fToolTipNode instanceof ITimeRange) && 
-                (fCurrentGraphNode != fToolTipNode) && 
-                ((ITimeRange) fToolTipNode).hasTimeInfo() && 
+        if ((fCurrentGraphNode != null) &&
+                (fCurrentGraphNode instanceof ITimeRange) &&
+                (fToolTipNode instanceof ITimeRange) &&
+                (fCurrentGraphNode != fToolTipNode) &&
+                ((ITimeRange) fToolTipNode).hasTimeInfo() &&
                 ((ITimeRange) fCurrentGraphNode).hasTimeInfo()) {
             postfix.append(" -> "); //$NON-NLS-1$
             postfix.append(fCurrentGraphNode.getName());
             postfix.append("\n"); //$NON-NLS-1$
             postfix.append(SDMessages._138);
             postfix.append(" "); //$NON-NLS-1$
-            
-//            postfix = " -> " + fCurrentGraphNode.getName() + "\n" + SDMessages._138 + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
-            
+
             //double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
             ITmfTimestamp firstTime = ((ITimeRange) fCurrentGraphNode).getEndTime();
             ITmfTimestamp lastTime = ((ITimeRange) fToolTipNode).getEndTime();
-            TmfTimestamp delta = (TmfTimestamp) lastTime.getDelta(firstTime);
+            ITmfTimestamp delta =  lastTime.getDelta(firstTime);
             postfix.append(delta.toString());
 
-//            postfix += delta.toString();
         } else {
             if ((fToolTipNode instanceof ITimeRange) && ((ITimeRange) fToolTipNode).hasTimeInfo()) {
                 postfix.append("\n"); //$NON-NLS-1$
-//                postfix = "\n";//$NON-NLS-1$
                 ITmfTimestamp firstTime = ((ITimeRange) fToolTipNode).getStartTime();
-                ITmfTimestamp lastTime = ((ITimeRange) fToolTipNode).getEndTime();  
-                
+                ITmfTimestamp lastTime = ((ITimeRange) fToolTipNode).getEndTime();
+
                 if (firstTime != null) {
                     if (lastTime != null && firstTime.compareTo(lastTime, true) != 0) {
                         postfix.append("start: "); //$NON-NLS-1$
                         postfix.append(firstTime.toString());
                         postfix.append("\n"); //$NON-NLS-1$
-                        postfix.append("end: "); //$NON-NLS-1$ 
+                        postfix.append("end: "); //$NON-NLS-1$
                         postfix.append(lastTime.toString());
                         postfix.append("\n"); //$NON-NLS-1$
-//                            postfix += "start: " + firstTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
-//                            postfix += "end: " + lastTime + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
                         } else {
                             postfix.append(firstTime.toString());
-//                            postfix += firstTime.toString();    
                         }
                     }
                 else if (lastTime != null) {
                     postfix.append(lastTime.toString());
-//                    postfix += lastTime.toString();
                 }
             }
         }
@@ -1244,7 +1239,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Sets a new focused widget.
-     * 
+     *
      * @param newFocusShape A new focus shape.
      */
     protected void setFocus(int newFocusShape) {
@@ -1259,7 +1254,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
     /**
      * Highlight the given GraphNode<br>
      * The GraphNode is then displayed using the system default selection color
-     * 
+     *
      * @param node the GraphNode to highlight
      */
     protected void performSelection(GraphNode node) {
@@ -1283,8 +1278,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /**
      * Returns a draw buffer image.
-     * 
-     * @return a Image containing the draw buffer. 
+     *
+     * @return a Image containing the draw buffer.
      */
     protected Image getDrawBuffer() {
 
@@ -1296,7 +1291,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         try {
             dbuffer = new Image(getDisplay(), area.width, area.height);
         } catch (Exception e) {
-            TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error creating image", e)); //$NON-NLS-1$
+            Activator.getDefault().logError("Error creating image", e); //$NON-NLS-1$
         }
 
         gcim = new GC(dbuffer);
@@ -1305,16 +1300,16 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
         // 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.setLifelineFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
+        Metrics.setLifelineFontWidth(context.getFontWidth(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE)));
         Metrics.setLifelineWidth(SDViewPref.getInstance().getLifelineWidth());
         Metrics.setFrameFontHeight(context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_FRAME_NAME)));
         Metrics.setLifelineHeaderFontHeight(context.getFontHeight(SDViewPref.getInstance().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 syncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS));
+        int syncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_SYNC_MESS_RET));
+        int asyncMessFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS));
+        int asyncMessRetFontH = context.getFontHeight(SDViewPref.getInstance().getFont(ISDPreferences.PREF_ASYNC_MESS_RET));
 
         int messageFontHeight = 0;
         if (syncMessFontH > syncMessRetFontH) {
@@ -1329,7 +1324,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             messageFontHeight = asyncMessRetFontH;
         }
         Metrics.setMessageFontHeight(messageFontHeight);
-        context.setFont(SDViewPref.getInstance().getFont(SDViewPref.PREF_LIFELINE));
+        context.setFont(SDViewPref.getInstance().getFont(ISDPreferences.PREF_LIFELINE));
 
         int width = (int) ((fFrame.getWidth() + 2 * Metrics.FRAME_H_MARGIN) * fZoomValue);
         int height = (int) ((fFrame.getHeight() + 2 * Metrics.FRAME_V_MARGIN) * fZoomValue);
@@ -1345,7 +1340,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
         fFrame.draw(context);
         if (fDragAndDrop != null) {
-            Lifeline node = (Lifeline) fDragAndDrop;
+            Lifeline node = fDragAndDrop;
             boolean isSelected = fDragAndDrop.isSelected();
             boolean hasFocus = fDragAndDrop.hasFocus();
             node.setSelected(false);
@@ -1358,7 +1353,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         context.dispose();
         return dbuffer;
     }
-    
+
     /*
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
@@ -1417,8 +1412,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
         if (event.character == ' ') {
             performSelection(fCurrentGraphNode);
-            if (!fShiftSelection)
+            if (!fShiftSelection) {
                 fListStart = fCurrentGraphNode;
+            }
         }
 
         if ((fShiftSelection) && (prevNode != getFocusNode())) {
@@ -1427,7 +1423,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             addSelection(fFrame.getNodeList(fListStart, getFocusNode()));
             if (getFocusNode() instanceof Lifeline) {
                 ensureVisible(getFocusNode().getX(), getFocusNode().getY(), getFocusNode().getWidth(), getFocusNode().getHeight(), SWT.CENTER | SWT.VERTICAL, true);
-            } else { 
+            } else {
                 ensureVisible(getFocusNode());
             }
         } else if ((!fCtrlSelection) && (!fShiftSelection)) {
@@ -1477,10 +1473,12 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
     @Override
     protected void keyReleasedEvent(KeyEvent event) {
         setFocus(-1);
-        if (event.keyCode == SWT.CTRL)
+        if (event.keyCode == SWT.CTRL) {
             fCtrlSelection = false;
-        if (event.keyCode == SWT.SHIFT)
+        }
+        if (event.keyCode == SWT.SHIFT) {
             fShiftSelection = false;
+        }
         super.keyReleasedEvent(event);
         setFocus(1);
     }
@@ -1495,9 +1493,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         for (int i = 0; i < child.length; i++) {
             if (child[i].isFocusControl()) {
                 return true;
-            } else {
-                checkFocusOnChilds(child[i]);
             }
+            checkFocusOnChilds(child[i]);
         }
         return false;
     }
@@ -1510,7 +1507,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
     public boolean setContentsPos(int x, int y) {
         int localX = x;
         int localY = y;
-        
+
         if (localX < 0) {
             localX = 0;
         }
@@ -1708,20 +1705,20 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
                 int rx = Math.round(node.getX() * fZoomValue);
                 if (rx <= event.x && Math.round(rx + (node.getWidth() * fZoomValue)) >= event.x) {
                     if ((fCollapseProvider != null) && (fDragAndDrop != node)) {
-                        fCollapseProvider.collapseTwoLifelines((Lifeline) fDragAndDrop, node);
+                        fCollapseProvider.collapseTwoLifelines(fDragAndDrop, node);
                     }
                 } else if (rx < event.x) {
-                    fFrame.insertLifelineAfter((Lifeline) fDragAndDrop, node);
+                    fFrame.insertLifelineAfter(fDragAndDrop, node);
                     if (node.getIndex() < fFrame.lifeLinesCount()) {
-                        Lifeline temp[] = { (Lifeline) fDragAndDrop, fFrame.getLifeline(node.getIndex()) };
+                        Lifeline temp[] = { fDragAndDrop, fFrame.getLifeline(node.getIndex()) };
                         fReorderList.add(temp);
                     } else {
-                        Lifeline temp[] = { (Lifeline) fDragAndDrop, null };
+                        Lifeline temp[] = { fDragAndDrop, null };
                         fReorderList.add(temp);
                     }
                 } else {
-                    fFrame.insertLifelineBefore((Lifeline) fDragAndDrop, node);
-                    Lifeline temp[] = { (Lifeline) fDragAndDrop, node };
+                    fFrame.insertLifelineBefore(fDragAndDrop, node);
+                    Lifeline temp[] = { fDragAndDrop, node };
                     fReorderList.add(temp);
                 }
             }
@@ -1812,9 +1809,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         fIsDragAndDrop = (event.button == 1);
 
     }
-    
-    /** 
-     * TimerTask for auto scroll feature. 
+
+    /**
+     * TimerTask for auto scroll feature.
      */
     protected static class AutoScroll extends TimerTask {
         /**
@@ -1832,7 +1829,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
         /**
          * Constructor for AutoScroll.
-         * @param sv sequence diagram widget reference 
+         * @param sv sequence diagram widget reference
          * @param dx delta x
          * @param dy delta y
          */
@@ -1851,8 +1848,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             Display.getDefault().asyncExec(new Runnable() {
                 @Override
                 public void run() {
-                    if (fSdWidget.isDisposed())
+                    if (fSdWidget.isDisposed()) {
                         return;
+                    }
                     fSdWidget.fDragX += fDeltaX;
                     fSdWidget.fDragY += fDeltaY;
                     fSdWidget.scrollBy(fDeltaX, fDeltaY);
@@ -1872,10 +1870,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             gc.fillRectangle(0, 0, getVisibleWidth(), getVisibleHeight());
             gc.dispose();
             return;
-        } else {
-//            Frame.setUserPref(SDViewPref.getInstance());
-            SDViewPref.getInstance();
         }
+        // Frame.setUserPref(SDViewPref.getInstance());
+        SDViewPref.getInstance();
 
         Rectangle area = getClientArea();
         Image dbuffer = getDrawBuffer();
@@ -1884,7 +1881,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         try {
             gc.drawImage(dbuffer, 0, 0, area.width, area.height, 0, 0, area.width, area.height);
         } catch (Exception e) {
-            TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error drawin content", e)); //$NON-NLS-1$
+            Activator.getDefault().logError("Error drawin content", e); //$NON-NLS-1$
         }
         dbuffer.dispose();
         setHScrollBarIncrement(Math.round(SDViewPref.getInstance().getLifelineWidth() / (float) 2 * fZoomValue));
@@ -1928,7 +1925,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
 
     /*
      * 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)
      */
@@ -1941,8 +1938,9 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         {
             // Prepare the overview to be reused for the new
             // settings (especially the colors)
-            if (fOverView != null)
+            if (fOverView != null) {
                 fOverView.dispose();
+            }
             fOverView = null;
             redraw();
         }
@@ -2000,7 +1998,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             fOverView = new Image(getDisplay(), r.width, r.height);
             GC gcim = new GC(fOverView);
             NGC context = new NGC(this, gcim);
-            context.setBackground(SDViewPref.getInstance().getBackGroundColor(SDViewPref.PREF_FRAME));
+            context.setBackground(SDViewPref.getInstance().getBackGroundColor(ISDPreferences.PREF_FRAME));
             fFrame.draw(context);
             setContentsPos(backX, backY);
             gcim.dispose();
@@ -2104,7 +2102,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
         }
         return super.getContentsY();
     }
-    
+
     /**
      * Traverse Listener implementation.
      */
This page took 0.037837 seconds and 5 git commands to generate.