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 5aa969f41c2c8b4fae1af74484efced573a12a08..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
+ *     IBM - Initial API and implementation
+ *     Bernd Hufmann - Updated for TMF
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
 
 import java.text.MessageFormat;
@@ -26,8 +25,7 @@ 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.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;
@@ -85,7 +83,8 @@ import org.eclipse.ui.part.ViewPart;
  * @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
@@ -514,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);
@@ -542,8 +541,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
     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);
@@ -554,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();
@@ -587,7 +586,8 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
     /**
      * 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) {
@@ -599,7 +599,8 @@ 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) {
@@ -697,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();
@@ -744,7 +745,8 @@ 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) {
@@ -980,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) {
@@ -1004,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);
@@ -1115,11 +1117,16 @@ 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;
@@ -1135,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();
@@ -1169,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;
@@ -1185,7 +1191,6 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
      */
     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) &&
@@ -1200,19 +1205,15 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             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();
 
@@ -1224,16 +1225,12 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
                         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();
                 }
             }
         }
@@ -1303,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) {
@@ -1327,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);
@@ -1343,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);
@@ -1496,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;
     }
@@ -1709,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);
                 }
             }
@@ -1874,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();
@@ -2003,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();
This page took 0.029154 seconds and 5 git commands to generate.