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
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
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
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
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
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
*/\r
@Override\r
public void setFocus() {\r
+ refresh(INITIAL_WINDOW_OFFSET);\r
fTimeGraphViewer.setFocus();\r
}\r
\r
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
}\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
--- /dev/null
+/*******************************************************************************\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
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;
super.dispose();
}
+ /**
+ * @param signal the clear view signal
+ * @since 2.0
+ */
+ @TmfSignalHandler
+ public void handleClearExperimentSignal(TmfClearExperimentSignal signal) {
+ dispose();
+ }
+
// ------------------------------------------------------------------------
// ITmfTrace - Initializers
// ------------------------------------------------------------------------
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
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+
+}
/*******************************************************************************
- * 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
*******************************************************************************/
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$
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);
# 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
/**
* 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;
* Wizard main page
*/
protected NewTmfProjectMainWizardPage fMainPage;
+
/**
* The Project name
*/
protected String fProjectName;
+
/**
* The project location
*/
+
protected URI fProjectLocation;
+
/**
* The configuration element.
*/
*/
protected IProject fProject;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
* Default constructor
*/
fDescription = desc;
}
+ // ------------------------------------------------------------------------
+ // Wizard
+ // ------------------------------------------------------------------------
+
/*
* (non-Javadoc)
*
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();
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
* 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
startFilterThread();
}
}
- fRawViewer.setTrace(fTrace);
}
+ fRawViewer.setTrace(fTrace);
}
});
}
}
/**
- * 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
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.
toolBarManager.add(fPinAction);
}
}
+
}
/*******************************************************************************
* 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
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;
/**
* The tracing perspective definition.
- *
+ *
* @version 1.0
* @author Francois Chouinard
*/
// ------------------------------------------------------------------------
/** 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;
// 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$
// 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);
}
}
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;
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$
fTable.pack();
parent.layout();
-
}
/* (non-Javadoc)
}
}
+ /**
+ * @param signal the incoming signal
+ * @since 2.0
+ */
+ @TmfSignalHandler
+ public void experimentDisposed(TmfExperimentDisposedSignal signal) {
+ fExperiment = null;
+ fTable.clearAll();
+ }
}
if ((fExperiment != null) && (fExperiment.getBookmarksFile() != null)) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
}
-
+ fExperiment = null;
}
}
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;
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
// ------------------------------------------------------------------------
private void initializeHistograms() {
- TmfTimeRange fullRange = updateExperimentTimeRange(fCurrentExperiment);
+ TmfTimeRange fullRange = updateExperimentTimeRange();
fTimeRangeHistogram.clear();
fTimeRangeHistogram.setFullRange(fExperimentStartTime, fExperimentEndTime);
}
}
- private TmfTimeRange updateExperimentTimeRange(TmfExperiment experiment) {
+ private TmfTimeRange updateExperimentTimeRange() {
fExperimentStartTime = 0;
fExperimentEndTime = 0;
fCurrentTimestamp = 0;
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;
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)
*
//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