import java.net.URL;
import java.util.Vector;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
assertNull("getTimestamp", fExperiment.getTimestamp(10000));
}
- // ------------------------------------------------------------------------
- // Bookmarks file handling
- // ------------------------------------------------------------------------
-
- @Test
- public void testBookmarks() {
- assertNull("GetBookmarksFile", fExperiment.getBookmarksFile());
- IFile bookmarks = (IFile) fTestTraces[0].getResource();
- fExperiment.setBookmarksFile(bookmarks);
- assertEquals("GetBookmarksFile", bookmarks, fExperiment.getBookmarksFile());
- }
-
// ------------------------------------------------------------------------
// State system, statistics and modules methods
// ------------------------------------------------------------------------
/*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
public class TmfTraceOpenedSignal extends TmfSignal {
private final ITmfTrace fTrace;
- private final IFile fBookmarksFile;
+ private final IFile fEditorFile;
/**
* Constructor for a new signal.
* The object sending this signal
* @param trace
* The trace that has been opened
- * @param bookmarksFile
- * Pointer to the bookmark file
+ * @param editorFile
+ * Pointer to the editor file
*/
- public TmfTraceOpenedSignal(Object source, ITmfTrace trace, IFile bookmarksFile) {
+ public TmfTraceOpenedSignal(Object source, ITmfTrace trace, IFile editorFile) {
super(source);
fTrace = trace;
- fBookmarksFile = bookmarksFile;
+ fEditorFile = editorFile;
}
/**
}
/**
- * Get a pointer to the bookmark file of this trace
+ * Get a pointer to the editor file for this trace
*
* @return The IFile object
+ * @since 3.0
*/
- public IFile getBookmarksFile() {
- return fBookmarksFile;
+ public IFile getEditorFile() {
+ return fEditorFile;
}
@Override
/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2009, 2014 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
import java.nio.ByteBuffer;
import java.util.Arrays;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
*/
private boolean fInitialized = false;
- /**
- * The experiment bookmarks file
- */
- private IFile fBookmarksFile;
-
// ------------------------------------------------------------------------
// Construction
// ------------------------------------------------------------------------
return (event != null) ? event.getTimestamp() : null;
}
- /**
- * Set the file to be used for bookmarks on this experiment
- *
- * @param file
- * the bookmarks file
- */
- public void setBookmarksFile(final IFile file) {
- fBookmarksFile = file;
- }
-
- /**
- * Get the file used for bookmarks on this experiment
- *
- * @return the bookmarks file or null if none is set
- */
- public IFile getBookmarksFile() {
- return fBookmarksFile;
- }
-
// ------------------------------------------------------------------------
// Request management
// ------------------------------------------------------------------------
/*******************************************************************************
- * Copyright (c) 2013 Ericsson
+ * Copyright (c) 2013, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
package org.eclipse.linuxtools.tmf.core.trace;
+import org.eclipse.core.resources.IFile;
import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
final class TmfTraceContext {
static final TmfTraceContext NULL_CONTEXT =
- new TmfTraceContext(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH, TmfTimeRange.NULL_RANGE);
+ new TmfTraceContext(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH, TmfTimeRange.NULL_RANGE, null);
private final TmfTimeRange fSelection;
private final TmfTimeRange fWindowRange;
+ private final IFile fEditorFile;
private final ITmfFilter fFilter;
- public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr) {
+ public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr, IFile editorFile) {
fSelection = new TmfTimeRange(beginTs, endTs);
fWindowRange = tr;
+ fEditorFile = editorFile;
fFilter = null;
}
public TmfTraceContext(TmfTraceContext prevCtx, ITmfTimestamp beginTs, ITmfTimestamp endTs) {
fSelection = new TmfTimeRange(beginTs, endTs);
fWindowRange = prevCtx.fWindowRange;
+ fEditorFile = prevCtx.fEditorFile;
fFilter = prevCtx.fFilter;
}
public TmfTraceContext(TmfTraceContext prevCtx, TmfTimeRange tr) {
fSelection = prevCtx.fSelection;
fWindowRange = tr;
+ fEditorFile = prevCtx.fEditorFile;
fFilter = prevCtx.fFilter;
}
public TmfTraceContext(TmfTraceContext prevCtx, ITmfFilter filter) {
fSelection = prevCtx.fSelection;
fWindowRange = prevCtx.fWindowRange;
+ fEditorFile = prevCtx.fEditorFile;
fFilter = filter;
}
return fWindowRange;
}
+ public IFile getEditorFile() {
+ return fEditorFile;
+ }
+
/**
* @return the current filter applied to the trace
* @since 2.2
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
return Collections.unmodifiableSet(fTraces.keySet());
}
+ /**
+ * Get the editor file for an opened trace.
+ *
+ * @param trace
+ * the trace
+ * @return the editor file or null if the trace is not opened
+ * @since 3.0
+ */
+ public synchronized IFile getTraceEditorFile(ITmfTrace trace) {
+ TmfTraceContext ctx = fTraces.get(trace);
+ if (ctx != null) {
+ return ctx.getEditorFile();
+ }
+ return null;
+ }
+
private TmfTraceContext getCurrentTraceContext() {
TmfTraceContext curCtx = fTraces.get(fCurrentTrace);
if (curCtx == null) {
@TmfSignalHandler
public synchronized void traceOpened(final TmfTraceOpenedSignal signal) {
final ITmfTrace trace = signal.getTrace();
+ final IFile editorFile = signal.getEditorFile();
final ITmfTimestamp startTs = trace.getStartTime();
/* Calculate the initial time range */
long endTime = startTs.normalize(0, SCALE).getValue() + offset;
final TmfTimeRange startTr = new TmfTimeRange(startTs, new TmfTimestamp(endTime, SCALE));
- final TmfTraceContext startCtx = new TmfTraceContext(startTs, startTs, startTr);
+ final TmfTraceContext startCtx = new TmfTraceContext(startTs, startTs, startTr, editorFile);
fTraces.put(trace, startCtx);
/*******************************************************************************
- * Copyright (c) 2010, 2013 Ericsson
+ * Copyright (c) 2010, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
package org.eclipse.linuxtools.tmf.ui.editors;
-import org.eclipse.core.resources.IFile;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
* @return The trace
*/
ITmfTrace getTrace();
-
- /**
- * Get the bookmark file associated to this trace
- *
- * @return The IFile object pointing to the bookmark file
- */
- IFile getBookmarksFile();
}
return fTrace;
}
- @Override
- public IFile getBookmarksFile() {
- return fFile;
- }
-
@Override
public void setFocus() {
fEventsTable.setFocus();
return trace;
}
- private static ITmfTrace openExperimentElement(final TmfExperimentElement experimentElement, IFile bookmarkFile) {
+ private static ITmfTrace openExperimentElement(final TmfExperimentElement experimentElement) {
/* Experiment element now has an experiment type associated with it */
final TmfExperiment experiment = experimentElement.instantiateTrace();
if (experiment == null) {
// Create the experiment
experiment.initExperiment(ITmfEvent.class, experimentElement.getName(), traces, cacheSize, experimentElement.getResource());
- experiment.setBookmarksFile(bookmarkFile);
return experiment;
}
- private static ITmfTrace openProjectElement(final TmfCommonProjectElement element, IFile bookmarkFile) {
+ private static ITmfTrace openProjectElement(final TmfCommonProjectElement element) {
ITmfTrace trace = null;
if (element instanceof TmfTraceElement) {
trace = openTraceElement((TmfTraceElement) element);
} else if (element instanceof TmfExperimentElement) {
- trace = openExperimentElement((TmfExperimentElement) element, bookmarkFile);
+ trace = openExperimentElement((TmfExperimentElement) element);
}
return trace;
}
@Override
public void run() {
- final ITmfTrace trace = openProjectElement(traceElement, file);
+ final ITmfTrace trace = openProjectElement(traceElement);
if (trace == null) {
return;
}
@Override
public void run() {
- final ITmfTrace trace = openProjectElement(traceElement, file);
+ final ITmfTrace trace = openProjectElement(traceElement);
if (trace == null) {
return;
}
/*******************************************************************************
- * Copyright (c) 2010, 2013 Ericsson
+ * Copyright (c) 2010, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;
import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
/**
* Generic Time Chart view, which is similar to a Gantt chart for trace analysis
IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
fViewer.getTimeGraphControl().setStatusLineManager(statusLineManager);
- IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();
- for (IEditorReference editorReference : editorReferences) {
- IEditorPart editor = editorReference.getEditor(false);
- if (editor instanceof ITmfTraceEditor) {
- ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
- if (trace != null) {
- IFile bookmarksFile = ((ITmfTraceEditor) editor).getBookmarksFile();
- TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);
- fTimeAnalysisEntries.add(timeAnalysisEntry);
- fDecorationProviders.put(trace, new TimeChartDecorationProvider(bookmarksFile));
- Thread thread = new ProcessTraceThread(timeAnalysisEntry);
- thread.start();
- }
- }
+ for (ITmfTrace trace : TmfTraceManager.getInstance().getOpenedTraces()) {
+ IFile bookmarksFile = TmfTraceManager.getInstance().getTraceEditorFile(trace);
+ TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);
+ fTimeAnalysisEntries.add(timeAnalysisEntry);
+ fDecorationProviders.put(trace, new TimeChartDecorationProvider(bookmarksFile));
+ Thread thread = new ProcessTraceThread(timeAnalysisEntry);
+ thread.start();
}
fViewer.setInput(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0]));
@TmfSignalHandler
public void traceOpened(TmfTraceOpenedSignal signal) {
final ITmfTrace trace = signal.getTrace();
- final IFile bookmarksFile = signal.getBookmarksFile();
+ final IFile bookmarksFile = signal.getEditorFile();
TimeChartAnalysisEntry timeAnalysisEntry = null;
for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {