Add a "Clear Tracing Views" command
authorFrancois Chouinard <fchouinard@gmail.com>
Thu, 27 Sep 2012 19:28:05 +0000 (15:28 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Thu, 27 Sep 2012 19:44:20 +0000 (15:44 -0400)
Add the possibility to clear the views the tracing/LTTng perspective.
It does it by disposing of the experiment. Proper signal handlers were
added where necessary.

Change-Id: I33e974f26b6e66d55bcd0c34ac96b375bf3ccddb
Signed-off-by: Francois Chouinard <fchouinard@gmail.com>
Reviewed-on: https://git.eclipse.org/r/7962
Tested-by: Hudson CI
20 files changed:
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfClearExperimentSignal.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
org.eclipse.linuxtools.tmf.ui/icons/dtool16/clear.gif [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/icons/etool16/clear.gif [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/plugin.properties
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/ClearViewsHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/Messages.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/messages.properties
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsCache.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TracingPerspectiveFactory.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java

index 1b9abe4319932b32986afc010f916a5441997024..3e1db0d9ec90f828e03643ab7372035f7398d83a 100644 (file)
@@ -37,6 +37,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;\r
 import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;\r
 import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;\r
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;\r
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;\r
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;\r
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;\r
@@ -277,7 +278,7 @@ public class ControlFlowView extends TmfView {
         public void run() {\r
             ArrayList<ControlFlowEntry> entryList = null;\r
             synchronized (fEntryListSyncObj) {\r
-                entryList = fEntryList;\r
+                entryList = (ArrayList<ControlFlowEntry>) fEntryList.clone();\r
             }\r
             if (entryList == null) {\r
                 return;\r
@@ -424,6 +425,25 @@ public class ControlFlowView extends TmfView {
         thread.start();\r
     }\r
 \r
+    /**\r
+     * Experiment is disposed: clear the data structures and the view\r
+     *\r
+     * @param signal the signal received\r
+     */\r
+    @TmfSignalHandler\r
+    public void experimentDisposed(final TmfExperimentDisposedSignal signal) {\r
+        if (signal.getExperiment().equals(fSelectedExperiment)) {\r
+            fSelectedExperiment = null;\r
+            fStartTime = 0;\r
+            fEndTime = 0;\r
+            fZoomThread.cancel();\r
+            synchronized(fEntryListSyncObj) {\r
+                fEntryList.clear();\r
+            }\r
+            refresh(INITIAL_WINDOW_OFFSET);\r
+        }\r
+    }\r
+\r
     /**\r
      * Handler for the synch signal\r
      *\r
index 66bc22c1cbceed38f35bc4f6727f3326d2ba23ba..9062f49e01366cb7787981e88ac5feb67fea9fde 100644 (file)
@@ -34,6 +34,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;\r
 import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;\r
 import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;\r
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;\r
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;\r
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;\r
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;\r
@@ -235,7 +236,7 @@ public class ResourcesView extends TmfView {
         public void run() {\r
             ArrayList<TraceEntry> entryList = null;\r
             synchronized (fEntryListSyncObj) {\r
-                entryList = fEntryList;\r
+                entryList = (ArrayList<TraceEntry>) fEntryList.clone();\r
             }\r
             if (entryList == null) {\r
                 return;\r
@@ -332,6 +333,7 @@ public class ResourcesView extends TmfView {
      */\r
     @Override\r
     public void setFocus() {\r
+        refresh(INITIAL_WINDOW_OFFSET);\r
         fTimeGraphViewer.setFocus();\r
     }\r
 \r
@@ -360,6 +362,25 @@ public class ResourcesView extends TmfView {
         thread.start();\r
     }\r
 \r
+    /**\r
+     * Experiment is disposed: clear the data structures and the view\r
+     *\r
+     * @param signal the signal received\r
+     */\r
+    @TmfSignalHandler\r
+    public void experimentDisposed(final TmfExperimentDisposedSignal signal) {\r
+        if (signal.getExperiment().equals(fSelectedExperiment)) {\r
+            fSelectedExperiment = null;\r
+            fStartTime = 0;\r
+            fEndTime = 0;\r
+            fZoomThread.cancel();\r
+            synchronized(fEntryListSyncObj) {\r
+                fEntryList.clear();\r
+            }\r
+            refresh(INITIAL_WINDOW_OFFSET);\r
+        }\r
+    }\r
+\r
     /**\r
      * Handler for the TimeSynch signal\r
      *\r
@@ -610,25 +631,28 @@ public class ResourcesView extends TmfView {
                 }\r
                 ITimeGraphEntry[] entries = null;\r
                 synchronized (fEntryListSyncObj) {\r
-                    entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
+                    if (fEntryList != null) {\r
+                        entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
+                    }\r
                 }\r
-                Arrays.sort(entries, new TraceEntryComparator());\r
-                fTimeGraphViewer.setInput(entries);\r
-                fTimeGraphViewer.setTimeBounds(fStartTime, fEndTime);\r
+                if (entries != null) {\r
+                    Arrays.sort(entries, new TraceEntryComparator());\r
+                    fTimeGraphViewer.setInput(entries);\r
+                    fTimeGraphViewer.setTimeBounds(fStartTime, fEndTime);\r
 \r
-                long endTime = fStartTime + windowRange;\r
+                    long endTime = fStartTime + windowRange;\r
 \r
-                if (fEndTime < endTime) {\r
-                    endTime = fEndTime;\r
-                }\r
-                fTimeGraphViewer.setStartFinishTime(fStartTime, endTime);\r
+                    if (fEndTime < endTime) {\r
+                        endTime = fEndTime;\r
+                    }\r
+                    fTimeGraphViewer.setStartFinishTime(fStartTime, endTime);\r
 \r
-                startZoomThread(fStartTime, endTime);\r
+                    startZoomThread(fStartTime, endTime);\r
+                }\r
             }\r
         });\r
     }\r
 \r
-\r
     private void redraw() {\r
         synchronized (fSyncObj) {\r
             if (fRedrawState == State.IDLE) {\r
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfClearExperimentSignal.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfClearExperimentSignal.java
new file mode 100644 (file)
index 0000000..090740c
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************\r
+ * Copyright (c) 2012 Ericsson\r
+ *\r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *   Francois Chouinard - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.core.signal;\r
+\r
+/**\r
+ * Clear experiment signal\r
+ *\r
+ * @version 1.0\r
+ * @author Francois Chouinard\r
+ * @since 2.0\r
+ */\r
+public class TmfClearExperimentSignal extends TmfSignal {\r
+\r
+    /**\r
+     * @param source the signal source\r
+     */\r
+    public TmfClearExperimentSignal(Object source) {\r
+        super(source);\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see java.lang.Object#toString()\r
+     */\r
+    @Override\r
+    @SuppressWarnings("nls")\r
+    public String toString() {\r
+        return "[TmfClearExperimentSignal]";\r
+    }\r
+}\r
index f20d6ec8084a9ab18d4955f7246c7e3e1608c5e6..b517a9ef55daa57e93d98db29e24aa0fb3b6c55f 100644 (file)
@@ -26,6 +26,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
 import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.signal.TmfClearExperimentSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
@@ -141,6 +142,15 @@ public class TmfExperiment extends TmfTrace implements ITmfEventParser {
         super.dispose();
     }
 
+    /**
+     * @param signal the clear view signal
+     * @since 2.0
+     */
+    @TmfSignalHandler
+    public void handleClearExperimentSignal(TmfClearExperimentSignal signal) {
+        dispose();
+    }
+
     // ------------------------------------------------------------------------
     // ITmfTrace - Initializers
     // ------------------------------------------------------------------------
diff --git a/org.eclipse.linuxtools.tmf.ui/icons/dtool16/clear.gif b/org.eclipse.linuxtools.tmf.ui/icons/dtool16/clear.gif
new file mode 100644 (file)
index 0000000..7f32480
Binary files /dev/null and b/org.eclipse.linuxtools.tmf.ui/icons/dtool16/clear.gif differ
diff --git a/org.eclipse.linuxtools.tmf.ui/icons/etool16/clear.gif b/org.eclipse.linuxtools.tmf.ui/icons/etool16/clear.gif
new file mode 100644 (file)
index 0000000..2d3935a
Binary files /dev/null and b/org.eclipse.linuxtools.tmf.ui/icons/etool16/clear.gif differ
index 17367f2fb2dd0a6a4c3622537a5aacf1338378f7..52a383a4cd456a62fb511878cc36b476b9115d6d 100644 (file)
@@ -73,6 +73,10 @@ command.select_trace_type.bundle = Bundle
 command.select_trace_type.type = Trace Type
 command.select_trace_type.icon = Icon
 
+command.clear_views = Clear
+command.clear_views.mnemonic = l
+command.clear_views.description = Clear the tracing views
+
 ## Trace menu
 #  Open, Copy, Rename, Delete, Delete Supplementary Files, Select Trace Type
 
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/ClearViewsHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/ClearViewsHandler.java
new file mode 100644 (file)
index 0000000..eaa929e
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.tmf.core.signal.TmfClearExperimentSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Sends the clear signal to the TmfView:s
+ *
+ * @version 1.0
+ * @author Francois Chouinard
+ */
+public class ClearViewsHandler extends AbstractHandler {
+
+    // ------------------------------------------------------------------------
+    // Execution
+    // ------------------------------------------------------------------------
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        boolean clearViewConfirmed = MessageDialog.openConfirm(
+                PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+                Messages.ClearViewsHandler_title, Messages.ClearViewsHandler_message);
+        if (clearViewConfirmed) {
+            TmfSignalManager.dispatchSignal(new TmfClearExperimentSignal(this));
+        }
+        return null;
+    }
+
+}
index 16d59b48af39237f46c418139f0d9c07dc0afb4e..227d86623d27121a7a8fe8cb5465f024af357453 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************
- * 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:
  *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
@@ -14,6 +14,13 @@ package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
 
 import org.eclipse.osgi.util.NLS;
 
+/**
+ * Messages file
+ *
+ * @author Francois Chouinard
+ * @version 1.0
+ */
+@SuppressWarnings("javadoc")
 public class Messages extends NLS {
 
     private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tmf.ui.project.handlers.messages"; //$NON-NLS-1$
@@ -32,6 +39,9 @@ public class Messages extends NLS {
     public static String SelectTraceTypeHandler_Title;
     public static String SelectTraceTypeHandler_InvalidTraceType;
 
+    public static String ClearViewsHandler_message;
+    public static String ClearViewsHandler_title;
+
     static {
         // initialize resource bundle
         NLS.initializeMessages(BUNDLE_NAME, Messages.class);
index 2c3e838255e232c396fa232152d34e156c3764eb..e00c819d163967111a16e4be8ca37eaed377e33a 100644 (file)
@@ -15,3 +15,7 @@ DeleteExperimentHandler_Message = Are you sure you want to delete this experimen
 # Set Trace Type
 SelectTraceTypeHandler_Title = Validation Error
 SelectTraceTypeHandler_InvalidTraceType =  Type could not be set for one or more traces
+
+# Clear tracing views
+ClearViewsHandler_title=Clear Views
+ClearViewsHandler_message=Clear the tracing views
index c7781b9b89ff11991124c97bac6693d1db8efc03..0faf968695937f85e3cb87d553b55224d9aaffb6 100644 (file)
@@ -38,12 +38,27 @@ import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
 
 /**
  * Wizard implementation for creating a TMF tracing project.
- * <p>
+ *
  * @version 1.0
  * @author Francois Chouinard
  */
 public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutableExtension {
 
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    /**
+     * The wizard id
+     *
+     * @since 2.0
+     */
+    public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.ui.wizards.newProject"; //$NON-NLS-1$
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
     private final String fTtitle;
     private final String fDescription;
 
@@ -51,14 +66,18 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab
      * Wizard main page
      */
     protected NewTmfProjectMainWizardPage fMainPage;
+
     /**
      * The Project name
      */
     protected String fProjectName;
+
     /**
      * The project location
      */
+
     protected URI fProjectLocation;
+
     /**
      * The configuration element.
      */
@@ -69,6 +88,10 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab
      */
     protected IProject fProject;
 
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+
     /**
      * Default constructor
      */
@@ -91,6 +114,10 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab
         fDescription = desc;
     }
 
+    // ------------------------------------------------------------------------
+    // Wizard
+    // ------------------------------------------------------------------------
+
     /*
      * (non-Javadoc)
      *
@@ -128,8 +155,7 @@ public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutab
         return true;
     }
 
-    private static IProject createProject(String projectName,
-            URI projectLocation, IProgressMonitor monitor) {
+    private static IProject createProject(String projectName, URI projectLocation, IProgressMonitor monitor) {
 
         IWorkspace workspace = ResourcesPlugin.getWorkspace();
         IWorkspaceRoot root = workspace.getRoot();
index 68ccec8eea9dbe83184669000296fda956f6b280..9bd2a3bb8157de000b8ac186af2ededbcf2f8f1b 100644 (file)
@@ -13,6 +13,7 @@
 package org.eclipse.linuxtools.tmf.ui.viewers.events;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.List;\r
 \r
 import org.eclipse.core.runtime.IProgressMonitor;\r
@@ -99,6 +100,7 @@ public class TmfEventsCache {
      * Clear the current contents of this cache.\r
      */\r
     public synchronized void clear() {\r
+        Arrays.fill(fCache, null);\r
         fCacheStartIndex = 0;\r
         fCacheEndIndex = 0;\r
         fFilterIndex.clear();\r
index f854f1dbf9b86423f369a66621442d4c9677d836..d1d2881221f619c49189cd3723953fcc244bf93a 100644 (file)
@@ -1527,8 +1527,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker,
                             startFilterThread();
                         }
                     }
-                    fRawViewer.setTrace(fTrace);
                 }
+                fRawViewer.setTrace(fTrace);
             }
         });
     }
index 72310436061ddfa4724a80415756de473fd7308d..04a0f9bcaad3934020f45ebd09bfd0d84dc98465 100644 (file)
@@ -55,7 +55,8 @@ public abstract class TmfView extends ViewPart implements ITmfComponent {
        }
 
        /**
-        * Disposes this view and deregisters itself from the signal manager
+        * Disposes this view and de-registers itself from the signal manager
+        *
         * @see org.eclipse.ui.part.WorkbenchPart#dispose()
         */
        @Override
@@ -86,6 +87,10 @@ public abstract class TmfView extends ViewPart implements ITmfComponent {
                TmfSignalManager.dispatchSignal(signal);
        }
 
+    // ------------------------------------------------------------------------
+    // View pinning support
+    // ------------------------------------------------------------------------
+
     /**
      * Returns whether the pin flag is set.
      * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
@@ -113,4 +118,5 @@ public abstract class TmfView extends ViewPart implements ITmfComponent {
             toolBarManager.add(fPinAction);
         }
     }
+
 }
index b1aba0dfaf198eadd7fd67115bd4235f91e48c6b..90f458c44a8254257a5f36fba3a1f6fc8d2d3188 100644 (file)
@@ -1,6 +1,6 @@
 /*******************************************************************************
  * Copyright (c) 2010, 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
@@ -12,6 +12,7 @@
 
 package org.eclipse.linuxtools.tmf.ui.views;
 
+import org.eclipse.linuxtools.tmf.ui.project.wizards.NewTmfProjectWizard;
 import org.eclipse.linuxtools.tmf.ui.views.events.TmfEventsView;
 import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramView;
 import org.eclipse.linuxtools.tmf.ui.views.statistics.TmfStatisticsView;
@@ -21,7 +22,7 @@ import org.eclipse.ui.IPerspectiveFactory;
 
 /**
  * The tracing perspective definition.
- * 
+ *
  * @version 1.0
  * @author Francois Chouinard
  */
@@ -32,7 +33,7 @@ public class TracingPerspectiveFactory implements IPerspectiveFactory {
     // ------------------------------------------------------------------------
 
     /** The Perspective ID */
-    public static final String ID = "org.eclipse.linuxtools.tmf.ui.perspective.tracing"; //$NON-NLS-1$
+    public static final String ID = "org.eclipse.linuxtools.tmf.ui.perspective"; //$NON-NLS-1$
 
     // Standard TMF views
     private static final String EVENTS_VIEW_ID = TmfEventsView.ID;
@@ -55,11 +56,6 @@ public class TracingPerspectiveFactory implements IPerspectiveFactory {
         // No editor part
         layout.setEditorAreaVisible(false);
 
-        // Goodies
-        addFastViews(layout);
-        addViewShortcuts(layout);
-        addPerspectiveShortcuts(layout);
-
         // Create the top left folder
         IFolderLayout topLeftFolder = layout.createFolder(
                 "topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
@@ -67,33 +63,24 @@ public class TracingPerspectiveFactory implements IPerspectiveFactory {
 
         // Create the top right folder
         IFolderLayout topRightFolder = layout.createFolder(
-                "topRightFolder", IPageLayout.TOP, 0.40f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
+                "topRightFolder", IPageLayout.TOP, 0.50f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
         topRightFolder.addView(EVENTS_VIEW_ID);
 
         // Create the middle right folder
         IFolderLayout middleRightFolder = layout.createFolder(
-                "middleRightFolder", IPageLayout.BOTTOM, 0.40f, "topRightFolder"); //$NON-NLS-1$//$NON-NLS-2$
+                "middleRightFolder", IPageLayout.BOTTOM, 0.50f, "topRightFolder"); //$NON-NLS-1$//$NON-NLS-2$
         middleRightFolder.addView(STATISTICS_VIEW_ID);
 
         // Create the bottom right folder
         IFolderLayout bottomRightFolder = layout.createFolder(
-                "bottomRightFolder", IPageLayout.BOTTOM, 0.50f, "middleRightFolder"); //$NON-NLS-1$ //$NON-NLS-2$
+                "bottomRightFolder", IPageLayout.BOTTOM, 0.55f, "middleRightFolder"); //$NON-NLS-1$ //$NON-NLS-2$
         bottomRightFolder.addView(HISTOGRAM_VIEW_ID);
         bottomRightFolder.addView(PROPERTIES_VIEW_ID);
         bottomRightFolder.addView(BOOKMARKS_VIEW_ID);
-    }
-
-    // ------------------------------------------------------------------------
-    // Helper functions
-    // ------------------------------------------------------------------------
-
-    private void addFastViews(IPageLayout layout) {
-    }
-
-    private void addViewShortcuts(IPageLayout layout) {
-    }
 
-    private void addPerspectiveShortcuts(IPageLayout layout) {
+        // Populate menus, etc
+        layout.addPerspectiveShortcut(ID);
+        layout.addNewWizardShortcut(NewTmfProjectWizard.ID);
     }
 
 }
index f713a38ccc32dde5010398e21d79ebbf61743a8d..6b87620708a425b645f6584054ec011b5ffc3f1a 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.tmf.ui.views.environment;
 import java.util.ArrayList;
 
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
@@ -65,26 +66,29 @@ public class TmfEnvironmentView extends TmfView {
     public void createPartControl(Composite parent) {
         fParent = parent;
         TableItem ti[];
-        // If an experiment is already selected, update the table
-        TmfExperiment experiment = TmfExperiment.getCurrentExperiment();
-        if (experiment == null) {
-            return;
-        }
-        fTable = new Table(parent, SWT.BORDER|SWT.FILL);
-
 
+        // Always create the table anyway otherwise we have an NPE when
+        // setFocus() is called by platform. Besides it's nice to have
+        // at least the column headers.
+        fTable = new Table(parent, SWT.BORDER|SWT.FILL);
         ArrayList<Pair> tableData = new ArrayList<Pair>();
-        for (ITmfTrace trace : experiment.getTraces()) {
-            Pair traceEntry = new Pair(trace.getName());
-            tableData.add(traceEntry);
-            if (trace instanceof CtfTmfTrace) {
-                CtfTmfTrace ctfTrace = (CtfTmfTrace) trace;
-                for (String varName : ctfTrace
-                        .getEnvNames()) {
-                    tableData.add(new Pair( varName, ctfTrace.getEnvValue(varName)));
+
+        // If an experiment is already selected, update the table
+        TmfExperiment experiment = TmfExperiment.getCurrentExperiment();
+        if (experiment != null) {
+            for (ITmfTrace trace : experiment.getTraces()) {
+                Pair traceEntry = new Pair(trace.getName());
+                tableData.add(traceEntry);
+                if (trace instanceof CtfTmfTrace) {
+                    CtfTmfTrace ctfTrace = (CtfTmfTrace) trace;
+                    for (String varName : ctfTrace
+                            .getEnvNames()) {
+                        tableData.add(new Pair( varName, ctfTrace.getEnvValue(varName)));
+                    }
                 }
             }
         }
+
         TableColumn nameCol = new TableColumn(fTable, SWT.NONE, 0);
         TableColumn valueCol = new TableColumn(fTable, SWT.NONE, 1);
         nameCol.setText("Environment Variable"); //$NON-NLS-1$
@@ -106,7 +110,6 @@ public class TmfEnvironmentView extends TmfView {
         fTable.pack();
 
         parent.layout();
-
     }
 
     /* (non-Javadoc)
@@ -145,5 +148,14 @@ public class TmfEnvironmentView extends TmfView {
         }
     }
 
+    /**
+     * @param signal the incoming signal
+     * @since 2.0
+     */
+    @TmfSignalHandler
+    public void experimentDisposed(TmfExperimentDisposedSignal signal) {
+        fExperiment = null;
+        fTable.clearAll();
+    }
 
 }
index ec88671d730fb7307c3b7005d97593a57842123f..e94edc4106aa14e9da5c6d9aa1f5648a47ad2155 100644 (file)
@@ -274,7 +274,7 @@ public class TmfEventsView extends TmfView implements IResourceChangeListener {
             if ((fExperiment != null) && (fExperiment.getBookmarksFile() != null)) {
                 ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
             }
-
+            fExperiment = null;
         }
     }
 
index 7961545dac1c7496a2baecadc0dc31237bd2c94b..927ab951f048e79b550d6eb0534d76f16360d149 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
 import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
@@ -372,6 +373,37 @@ public class HistogramView extends TmfView {
         fParent.redraw();
     }
 
+    /**
+     * @param signal the incoming signal
+     * @since 2.0
+     */
+    @TmfSignalHandler
+    public void experimentDisposed(TmfExperimentDisposedSignal signal) {
+
+        // Kill any running request
+        if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
+            fTimeRangeRequest.cancel();
+        }
+        if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
+            fFullTraceRequest.cancel();
+        }
+
+        // Initialize the internal data
+        fCurrentExperiment = null;
+        fExperimentStartTime = 0;
+        fExperimentEndTime = 0;
+        fWindowStartTime = 0;
+        fWindowEndTime = 0;
+        fWindowSpan = INITIAL_WINDOW_SPAN;
+        fCurrentTimestamp = 0;
+
+        // Clear the UI widgets
+        fFullTraceHistogram.clear();
+        fTimeRangeHistogram.clear();
+        fCurrentEventTimeControl.setValue(0);
+        fTimeSpanControl.setValue(0);
+    }
+
     /**
      * Handles experiment range updated signal. Extends histogram according to the new time range. If a
      * HistogramRequest is already ongoing, it will be cancelled and a new request with the new range
@@ -471,7 +503,7 @@ public class HistogramView extends TmfView {
     // ------------------------------------------------------------------------
 
     private void initializeHistograms() {
-        TmfTimeRange fullRange = updateExperimentTimeRange(fCurrentExperiment);
+        TmfTimeRange fullRange = updateExperimentTimeRange();
 
         fTimeRangeHistogram.clear();
         fTimeRangeHistogram.setFullRange(fExperimentStartTime, fExperimentEndTime);
@@ -496,7 +528,7 @@ public class HistogramView extends TmfView {
         }
     }
 
-    private TmfTimeRange updateExperimentTimeRange(TmfExperiment experiment) {
+    private TmfTimeRange updateExperimentTimeRange() {
         fExperimentStartTime = 0;
         fExperimentEndTime = 0;
         fCurrentTimestamp = 0;
index 7d2e858cc0411e3b11601471c25245f12e111f39..abe307903f3293488ca155d448f77c0ceb52dbad 100755 (executable)
@@ -19,6 +19,7 @@ package org.eclipse.linuxtools.tmf.ui.views.statistics;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
@@ -194,6 +195,23 @@ public class TmfStatisticsView extends TmfView {
         fStatsViewers.dispose();
     }
 
+    /**
+     * @param signal the incoming signal
+     * @since 2.0
+     */
+    @TmfSignalHandler
+    public void experimentDisposed(TmfExperimentDisposedSignal signal) {
+
+        // Clear the internal data
+        fExperiment = null;
+        fRequestData = false;
+
+        // Clear the UI widgets
+        fStatsViewers.clear();  // Also cancels ongoing requests
+        createStatisticsViewers();
+        fStatsViewers.layout();
+    }
+
     /*
      * (non-Javadoc)
      *
index 7d134a21071dead02963e40ac4f914dcaf58c968..37d5a0fa7fe7fa5e4c734838dbd7a4459e225a39 100644 (file)
@@ -278,6 +278,11 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                    //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
                    fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));\r
                    }\r
+        } else {\r
+            fBottomContext = null;\r
+            fillTextArea();\r
+            fSlider.setThumb(SLIDER_MAX);\r
+            fSlider.setSelection(0);\r
                }\r
        }\r
 \r
This page took 0.038622 seconds and 5 git commands to generate.