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 a834327a963fe170020edd13a1973ec226671b1f..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;
@@ -515,7 +513,7 @@ public class SDWidget extends ScrollView implements SelectionListener,
         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);
@@ -543,8 +541,8 @@ public class SDWidget extends ScrollView implements SelectionListener,
     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);
@@ -555,8 +553,8 @@ public class SDWidget extends ScrollView implements SelectionListener,
      */
     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();
@@ -700,7 +698,7 @@ public class SDWidget extends ScrollView implements SelectionListener,
             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();
@@ -984,16 +982,16 @@ public class SDWidget extends ScrollView implements SelectionListener,
 
         // 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) {
@@ -1008,7 +1006,7 @@ public class SDWidget extends ScrollView implements SelectionListener,
             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);
@@ -1144,7 +1142,7 @@ public class SDWidget extends ScrollView implements SelectionListener,
         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();
@@ -1178,9 +1176,8 @@ public class SDWidget extends ScrollView implements SelectionListener,
             for (int i = 0; i < child.length; i++) {
                 if (child[i].isFocusControl()) {
                     return true;
-                } else {
-                    checkFocusOnChilds(child[i]);
                 }
+                checkFocusOnChilds(child[i]);
             }
         }
         return false;
@@ -1194,7 +1191,6 @@ public class SDWidget extends ScrollView implements SelectionListener,
      */
     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) &&
@@ -1209,19 +1205,15 @@ public class SDWidget extends ScrollView implements SelectionListener,
             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();
 
@@ -1233,16 +1225,12 @@ public class SDWidget extends ScrollView implements SelectionListener,
                         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();
                 }
             }
         }
@@ -1312,16 +1300,16 @@ public class SDWidget extends ScrollView implements SelectionListener,
 
         // 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) {
@@ -1336,7 +1324,7 @@ public class SDWidget extends ScrollView implements SelectionListener,
             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);
@@ -1352,7 +1340,7 @@ public class SDWidget extends ScrollView implements SelectionListener,
 
         fFrame.draw(context);
         if (fDragAndDrop != null) {
-            Lifeline node = (Lifeline) fDragAndDrop;
+            Lifeline node = fDragAndDrop;
             boolean isSelected = fDragAndDrop.isSelected();
             boolean hasFocus = fDragAndDrop.hasFocus();
             node.setSelected(false);
@@ -1505,9 +1493,8 @@ public class SDWidget extends ScrollView implements SelectionListener,
         for (int i = 0; i < child.length; i++) {
             if (child[i].isFocusControl()) {
                 return true;
-            } else {
-                checkFocusOnChilds(child[i]);
             }
+            checkFocusOnChilds(child[i]);
         }
         return false;
     }
@@ -1718,20 +1705,20 @@ public class SDWidget extends ScrollView implements SelectionListener,
                 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);
                 }
             }
@@ -1883,10 +1870,9 @@ public class SDWidget extends ScrollView implements SelectionListener,
             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();
@@ -2012,7 +1998,7 @@ public class SDWidget extends ScrollView implements SelectionListener,
             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.028644 seconds and 5 git commands to generate.