tmf: Switch tmf.ui to Java 7 + fix warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / TimeGraphPresentationProvider.java
index 19b4cf383c86379e9cfd12df48c2d545454825b0..05d11bbb46550bf5292a3b917013fd7da5d229ce 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,15 +9,19 @@
  * Contributors:
  *   Alvaro Sanchez-Leon - Initial API and implementation
  *   Patrick Tasse - Refactoring
+ *   Geneviève Bastien - Add drawing helper methods
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 import org.eclipse.linuxtools.internal.tmf.ui.Messages;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITmfTimeGraphDrawingHelper;
 import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Rectangle;
@@ -29,7 +33,13 @@ import org.eclipse.swt.graphics.Rectangle;
  * @author Patrick Tasse
  *
  */
-public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider {
+public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider2 {
+
+    private ITmfTimeGraphDrawingHelper fDrawingHelper;
+    private final String fStateTypeName;
+
+    // The list of listeners for graph color changes
+    private final List<ITimeGraphColorListener> fListeners = new ArrayList<>();
 
     // ------------------------------------------------------------------------
     // Constants
@@ -40,13 +50,26 @@ public class TimeGraphPresentationProvider implements ITimeGraphPresentationProv
     // Operations
     // ------------------------------------------------------------------------
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTypeName()
+    /**
+     * Constructor
+     * @param stateTypeName  The state type name
+     * @since 2.1
+     */
+    public TimeGraphPresentationProvider(String stateTypeName) {
+        fStateTypeName = stateTypeName;
+    }
+
+    /**
+     * Constructor
+     * @since 2.1
      */
+    public TimeGraphPresentationProvider() {
+        this(Messages.TmfTimeLegend_TRACE_STATES);
+    }
+
     @Override
     public String getStateTypeName() {
-        return Messages.TmfTimeLegend_TRACE_STATES;
+        return fStateTypeName;
     }
 
     /**
@@ -57,90 +80,68 @@ public class TimeGraphPresentationProvider implements ITimeGraphPresentationProv
     public String getStateTypeName(ITimeGraphEntry entry) {
         return null;
     }
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTable()
-     */
+
     @Override
     public StateItem[] getStateTable() {
         return null;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventTableIndex(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
-     */
     @Override
     public int getStateTableIndex(ITimeEvent event) {
         return 0;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawControl(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
+    /**
+     * @since 2.1
+     */
+    @Override
+    public ITmfTimeGraphDrawingHelper getDrawingHelper() {
+        return fDrawingHelper;
+    }
+
+    /**
+     * @since 2.1
      */
+    @Override
+    public void setDrawingHelper(ITmfTimeGraphDrawingHelper helper) {
+        fDrawingHelper = helper;
+    }
+
     @Override
     public void postDrawControl(Rectangle bounds, GC gc) {
         // Override to add own drawing code
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEntry(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
-     */
     @Override
     public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc) {
         // Override to add own drawing code
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEvent(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
-     */
     @Override
     public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) {
         // Override to add own drawing code
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemHeight(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
-     */
     @Override
     public int getItemHeight(ITimeGraphEntry entry) {
         return DEFAULT_ITEM_HEIGHT;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemImage(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
-     */
     @Override
     public Image getItemImage(ITimeGraphEntry entry) {
         return null;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
-     */
     @Override
     public String getEventName(ITimeEvent event) {
         return null;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
-     */
     @Override
     public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent, long)
-     */
     /**
      * @since 2.0
      */
@@ -149,4 +150,40 @@ public class TimeGraphPresentationProvider implements ITimeGraphPresentationProv
         return getEventHoverToolTipInfo(event);
     }
 
-}
\ No newline at end of file
+    /**
+     * @since 3.0
+     */
+    @Override
+    public boolean displayTimesInTooltip() {
+        return true;
+    }
+
+    /**
+     * @since 3.0
+     */
+    @Override
+    public void addColorListener(ITimeGraphColorListener listener) {
+        if (!fListeners.contains(listener)) {
+            fListeners.add(listener);
+        }
+    }
+
+    /**
+     * @since 3.0
+     */
+    @Override
+    public void removeColorListener(ITimeGraphColorListener listener) {
+        fListeners.remove(listener);
+    }
+
+    /**
+     * Notifies listeners of the state table change
+     * @since 3.0
+     */
+    protected void fireColorSettingsChanged() {
+        for (ITimeGraphColorListener listener : fListeners) {
+            listener.colorSettingsChanged(getStateTable());
+        }
+    }
+
+}
This page took 0.037986 seconds and 5 git commands to generate.