From 8035003b6ab8323cd14af8d873712c05c1299b9b Mon Sep 17 00:00:00 2001 From: Alvaro Sanchez-Leon Date: Thu, 11 Feb 2010 16:51:37 +0000 Subject: [PATCH] temporary re-factoring project --- org.eclipse.linuxtools.lttng.ui/.classpath | 1 + .../plugin.properties | 53 +- org.eclipse.linuxtools.lttng.ui/plugin.xml | 403 ++------ .../linuxtools/lttng/ui/LTTngUiPlugin.java | 12 - .../linuxtools/lttng/ui/TraceDebug.java | 4 +- .../trange/TimeRangeResourceFactory.java | 30 +- .../ui/views/common/AbsTRangeUpdate.java | 6 +- .../ui/views/common/AbsTimeUpdateView.java | 667 +++--------- .../ui/views/common/DataRequestState.java | 110 ++ .../lttng/ui/views/common/ParamsUpdater.java | 28 +- .../ui/views/controlflow/ControlFlowView.java | 678 ++++++++----- .../evProcessor/AbsFlowTRangeUpdate.java | 35 +- .../FlowTRangeAfterUpdateHandlers.java | 423 ++++++++ .../FlowTRangeBeforeUpdateHandlers.java | 427 ++++++++ .../FlowTRangeFinishUpdateHandler.java | 109 ++ .../evProcessor/FlowTRangeUpdateFactory.java | 171 ++++ .../ui/views/controlflow/messages.properties | 2 - .../model/FlowProcessContainer.java | 32 +- .../lttng/ui/views/events/EventsView.java | 19 +- .../ui/views/histogram/HistogramView.java | 960 +----------------- .../project/LTTngProjectContentProvider.java | 162 +++ .../project/LTTngProjectLabelProvider.java | 160 +++ .../lttng/ui/views/project/ProjectView.java | 200 ++-- .../ui/views/project/TraceDragSource.java | 68 ++ .../ui/views/project/TraceDropTarget.java | 35 + .../actions/AddTraceActionDelegate.java | 92 ++ .../DeleteExperimentActionDelegate.java | 89 ++ .../actions/DeleteProjectActionDelegate.java | 79 ++ .../actions/DeleteTraceActionDelegate.java | 89 ++ .../actions/ImportTraceActionDelegate.java | 85 ++ .../actions/NewExperimentActionDelegate.java | 80 ++ .../actions/NewProjectActionDelegate.java | 72 ++ .../views/project/dialogs/AddTraceWizard.java | 42 +- .../project/dialogs/AddTraceWizardPage.java | 35 +- .../project/dialogs/ImportTraceWizard.java | 44 +- .../dialogs/ImportTraceWizardPage.java | 318 +----- .../dialogs/LTTngTraceContentProvider.java | 51 + .../dialogs/LTTngTraceLabelProvider.java | 50 + .../project/dialogs/NewExperimentDialog.java | 12 +- .../project/dialogs/NewProjectWizard.java | 10 +- .../project/model/LTTngExperimentEntry.java | 87 ++ .../project/model/LTTngExperimentFolder.java | 81 ++ .../ui/views/project/model/LTTngProject.java | 85 ++ .../views/project/model/LTTngTraceEntry.java | 55 + .../views/project/model/LTTngTraceFolder.java | 78 ++ .../ui/views/resources/ResourcesView.java | 405 +++++--- .../evProcessor/AbsResourcesTRangeUpdate.java | 98 +- .../ResourcesTRangeAfterUpdateHandlers.java | 76 ++ .../ResourcesTRangeBeforeUpdateHandlers.java | 414 ++++++++ .../ResourcesTRangeFinishUpdateHandler.java | 64 ++ .../ResourcesTRangeUpdateFactory.java | 129 +++ .../ui/views/resources/messages.properties | 2 - .../resources/model/ResourceContainer.java | 93 +- .../ui/views/statistics/StatisticsView.java | 241 +---- .../AbstractStatsEventHandler.java | 35 +- .../evProcessor/StatsEventCountHandler.java | 50 + .../StatsEventCountHandlerFactory.java | 71 ++ .../evProcessor/StatsModeChangeHandler.java | 2 +- .../evProcessor/StatsModeEndHandler.java | 2 +- .../StatsTimeCountHandlerFactory.java | 29 +- .../evProcessor/StatsTimeCountHandlers.java | 48 +- .../model/StatisticsTreeFactory.java | 58 ++ .../statistics/model/StatisticsTreeNode.java | 40 +- .../ui/views/timeframe/SpinnerGroup.java | 13 +- .../ui/views/timeframe/TimeFrameView.java | 103 +- .../lttng/stubs/LTTngEventParserStub.java | 139 +++ .../lttng/stubs/LTTngTimestampStub.java | 52 + .../lttng/stubs/LTTngTraceStub.java | 152 +++ 68 files changed, 5353 insertions(+), 3292 deletions(-) create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/DataRequestState.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeAfterUpdateHandlers.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeUpdateFactory.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectContentProvider.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectLabelProvider.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDragSource.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDropTarget.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/AddTraceActionDelegate.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteExperimentActionDelegate.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteProjectActionDelegate.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteTraceActionDelegate.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/ImportTraceActionDelegate.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewExperimentActionDelegate.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewProjectActionDelegate.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/LTTngTraceContentProvider.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/LTTngTraceLabelProvider.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentEntry.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentFolder.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProject.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceEntry.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceFolder.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeAfterUpdateHandlers.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeBeforeUpdateHandlers.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeFinishUpdateHandler.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandler.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandlerFactory.java create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeFactory.java create mode 100644 org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java create mode 100644 org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTimestampStub.java create mode 100644 org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java diff --git a/org.eclipse.linuxtools.lttng.ui/.classpath b/org.eclipse.linuxtools.lttng.ui/.classpath index 64c5e31b7a..978c0d27e1 100644 --- a/org.eclipse.linuxtools.lttng.ui/.classpath +++ b/org.eclipse.linuxtools.lttng.ui/.classpath @@ -3,5 +3,6 @@ + diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.properties b/org.eclipse.linuxtools.lttng.ui/plugin.properties index 75b2914195..24e8ce6bd5 100644 --- a/org.eclipse.linuxtools.lttng.ui/plugin.properties +++ b/org.eclipse.linuxtools.lttng.ui/plugin.properties @@ -1,28 +1,33 @@ #Properties file for org.eclipse.linuxtools.lttng.ui -Bundle-Name = Linux Tracing Toolkit (LTTng) UI (Incubation) -Bundle-Vendor = Eclipse Linux Tools - -# org.eclipse.ui.perspectives -extension.name.0 = LTTng Perspective +extension.name = LTTng Perspective perspective.name = LTTng - -# org.eclipse.ui.views -extension.name.1 = LTTng Views +extension.name.0 = LTTng Views category.name = LTTng -view.name.0 = Project -view.name.1 = Control -view.name.2 = Events -view.name.3 = Time Frame -view.name.4 = Control Flow -view.name.5 = Resources -view.name.6 = Statistics -view.name.7 = Histogram - -# org.eclipse.ui.newWizards -extension.name.2 = LTTng New Wizards +view.name = Project +view.name.0 = Control +view.name.1 = Events +view.name.2 = Time Frame +view.name.3 = Control Flow +view.name.4 = Resources +view.name.5 = Statistics +view.name.6 = Histogram +extension.name.1 = LTTng New Wizards category.name.0 = LTTng -wizard.name.0 = LTTng Project -wizard.description.0 = Create an LTTng project - -# org.eclipse.core.resources.natures -extension.name.3 = LTTng Project Nature +wizard.name = LTTng Project +wizard.description = Create a new LTTng project +extension.name.2 = LTTng Project Nature +actionSet.description = LTTng project management options +actionSet.label = LTTng Project ActionSet +menu.label = <Tng +action.label = New LTTng Project +action.tooltip = Create a new LTTng project +action.label.0 = Delete LTTng Project +action.label.1 = New LTTng Project +action.tooltip.0 = Create a new LTTng project +action.label.2 = Import a Trace +action.label.3 = Delete Trace +action.label.4 = New Experiment +action.label.5 = Delete Experiment +action.label.6 = Add Traces +Bundle-Vendor = Eclipse +Bundle-Name = Linux Tracing Toolkit (LTTng) UI \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.xml b/org.eclipse.linuxtools.lttng.ui/plugin.xml index 55bf5083f7..4f5cb39802 100644 --- a/org.eclipse.linuxtools.lttng.ui/plugin.xml +++ b/org.eclipse.linuxtools.lttng.ui/plugin.xml @@ -3,7 +3,7 @@ - %wizard.description.0 + %wizard.description + description="%actionSet.description" + id="org.eclipse.linuxtools.lttng.ui.view.project.actionSet" + label="%actionSet.label" + visible="false"> + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="org.eclipse.linuxtools.lttng.ui.view.project.menu.newProjectAction" + label="%action.label.1" + menubarPath="additions" + tooltip="%action.tooltip.0"> + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/LTTngUiPlugin.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/LTTngUiPlugin.java index 460ed6a8f6..1e24ba3014 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/LTTngUiPlugin.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/LTTngUiPlugin.java @@ -1,15 +1,3 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 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.lttng.ui; import org.eclipse.ui.plugin.AbstractUIPlugin; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/TraceDebug.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/TraceDebug.java index c0b24d242d..a8f27eddfa 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/TraceDebug.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/TraceDebug.java @@ -102,8 +102,7 @@ public class TraceDebug { } private static String trace(StackTraceElement e[], int level) { - if (e != null) { - level = level >= e.length ? e.length - 1 : level; + if (e != null && e.length >= level) { StackTraceElement s = e[level]; if (s != null) { String simpleClassName = s.getClassName(); @@ -114,7 +113,6 @@ public class TraceDebug { + "." + s.getLineNumber() + "." + s.getMethodName(); } } - return null; } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeResourceFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeResourceFactory.java index 94f2340f44..6c95c518c4 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeResourceFactory.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeResourceFactory.java @@ -11,11 +11,9 @@ *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.model.trange; - import org.eclipse.linuxtools.lttng.state.StateStrings; import org.eclipse.linuxtools.lttng.state.model.LttngIRQState; import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; -import org.eclipse.linuxtools.lttng.state.model.LttngTrapState; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource.ResourceTypes; /** @@ -132,27 +130,17 @@ public class TimeRangeResourceFactory { @Override public String getStateMode(LttngTraceState traceSt) { // Determine the trap state. + long trapState = traceSt.getTrap_states().get(getResourceId()) + .getRunning().longValue(); String trapStateMode = ""; - LttngTrapState ts = traceSt.getTrap_states().get(getResourceId()); - - // *** Note : - // Ts might not have been created yet. - // This is because the state system will be updated next to this before hook - // It should be correct to create it here as Busy - // (traps are created with running++ so it wont be idle) - if ( ts != null ) { - Long trapState = ts.getRunning(); - - if (trapState == 0) { - trapStateMode = StateStrings.TrapMode.LTTV_TRAP_IDLE.getInName(); - } else { - trapStateMode = StateStrings.TrapMode.LTTV_TRAP_BUSY.getInName(); - } - } - else { - trapStateMode = StateStrings.TrapMode.LTTV_TRAP_BUSY.getInName(); + if (trapState == 0) { + trapStateMode = StateStrings.TrapMode.LTTV_TRAP_IDLE + .getInName(); + } else { + trapStateMode = StateStrings.TrapMode.LTTV_TRAP_BUSY + .getInName(); } - + return trapStateMode; } }; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTRangeUpdate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTRangeUpdate.java index 9664c525f2..f1757bedfd 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTRangeUpdate.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTRangeUpdate.java @@ -10,13 +10,13 @@ *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.common; -import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; import org.eclipse.linuxtools.lttng.state.evProcessor.state.AbsStateProcessing; import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; public abstract class AbsTRangeUpdate extends AbsStateProcessing implements - ILttngEventProcessor { + IEventProcessing { private static final long MINORBITS = 20; @@ -46,7 +46,7 @@ public abstract class AbsTRangeUpdate extends AbsStateProcessing implements protected double getPixelsPerNs(LttngTraceState traceSt, ParamsUpdater params) { double pixPerNs = params.getPixelsPerNs(); if (pixPerNs == 0) { - TmfTimeRange tsetRange = traceSt.getContext().getExperimentTimeWindow(); + TmfTimeRange tsetRange = traceSt.getInputDataRef().getExperimentTimeWindow(); long startTime = tsetRange.getStartTime().getValue(); long endTime = tsetRange.getEndTime().getValue(); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java index 5870292a31..5b0ddbe472 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -11,37 +11,18 @@ *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.common; -import java.util.Arrays; - -import org.eclipse.linuxtools.lttng.control.LttngCoreProviderFactory; -import org.eclipse.linuxtools.lttng.control.LttngSyntheticEventProvider; -import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent; -import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent.SequenceInd; -import org.eclipse.linuxtools.lttng.event.LttngTimestamp; -import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest; -import org.eclipse.linuxtools.lttng.request.IRequestStatusListener; -import org.eclipse.linuxtools.lttng.request.LttngSyntEventRequest; -import org.eclipse.linuxtools.lttng.request.RequestCompletedSignal; -import org.eclipse.linuxtools.lttng.request.RequestStartedSignal; -import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor; +import org.eclipse.linuxtools.lttng.state.IStateDataRequestListener; +import org.eclipse.linuxtools.lttng.state.RequestCompletedSignal; +import org.eclipse.linuxtools.lttng.state.RequestStartedSignal; +import org.eclipse.linuxtools.lttng.state.StateDataRequest; +import org.eclipse.linuxtools.lttng.state.StateManager; +import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.ui.TraceDebug; -import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; -import org.eclipse.linuxtools.lttng.ui.views.resources.model.ResourceModelFactory; -import org.eclipse.linuxtools.tmf.event.TmfEvent; +import org.eclipse.linuxtools.lttng.ui.views.common.DataRequestState.RequestState; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.request.TmfDataRequest; -import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; -import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; -import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; import org.eclipse.linuxtools.tmf.ui.views.TmfView; -import org.eclipse.swt.widgets.Display; /** *

@@ -49,46 +30,28 @@ import org.eclipse.swt.widgets.Display; * requests *

*

- * The class handles a single element queue of data requests, i.e. request can - * be triggered from different sources e.g. opening a file as well as a new - * selected time window + * The class handles a single element queue of data requests, and a list of + * requests in progress i.e. request can be triggered from different sources + * e.g. opening a file as well as a new selected time window *

* * @author alvaro * */ public abstract class AbsTimeUpdateView extends TmfView implements - IRequestStatusListener { + IStateDataRequestListener { // ======================================================================== // Data // ======================================================================== - /** - * One second in nanoseconds - */ - private static final long INITIAL_WINDOW_OFFSET = 1000000000L; /* - * 1 sec // - * in ns // - */ - // private static final long INITIAL_WINDOW_OFFSET = 100000000L; /* 100 ms - // in ns */ - /** - * Number of events before a GUI refresh - */ - private static final Long INPUT_CHANGED_REFRESH = 3000L; - private static final long DEFAULT_OFFSET = 0L; - private static final int DEFAULT_CHUNK = 1; - - protected boolean synch = true; // time synchronisation, used to be an - // option - protected ITimeAnalysisViewer tsfviewer = null; + private DataRequestState reqState = new DataRequestState(); + private String viewID = ""; // ======================================================================== // Constructor // ======================================================================== public AbsTimeUpdateView(String viewID) { - super(viewID); - // freqState = UiCommonFactory.getQueue(this); + this.viewID = viewID; } // ======================================================================== @@ -102,27 +65,45 @@ public abstract class AbsTimeUpdateView extends TmfView implements */ @TmfSignalHandler public synchronized void processingStarted(RequestStartedSignal signal) { - LttngSyntEventRequest request = signal.getRequest(); + StateDataRequest request = signal.getRequest(); if (request != null) { - // update queue with the id of the current request. - // freqState.requestStarted(request); - - // if there was no new request then this one is still on - // prepare for the reception of new data - waitCursor(true); - - // no new time range for zoom orders - TmfTimeRange trange = null; - // Time Range will be used to filter out events which are - // not visible in one pixel - trange = request.getRange(); - - // indicate if the data model needs to be cleared e.g. a new - // experiment is being selected - boolean clearData = request.isclearDataInd(); - // Indicate if current data needs to be cleared and if so - // specify the new experiment time range that applies - ModelUpdatePrep(trange, clearData); + // Check if a newer request is in the queue + TmfTimeRange newerReq = reqState.peekQueued(); + if (newerReq == null) { + reqState.setState(DataRequestState.RequestState.BUSY); + reqState.setCurrentRequest(request); + + waitCursor(true); + + StateManager smanager = request.getStateManager(); + // Clear the children on the Processes related to this + // manager. + // Leave the GUI in charge of the updated data. + String traceId = smanager.getEventLog().getName(); + + // indicate if the data model needs to be cleared e.g. a new + // experiment is being selected + boolean clearData = request.isclearDataInd(); + // no new time range for zoom orders + TmfTimeRange trange = null; + if (clearData) { + // Time Range will be used to filter out events which are + // not visible in one pixel + trange = StateManagerFactory.getExperimentManager() + .getExperimentTimeRange(); + } + + //Indicate if current data needs to be cleared and if so + //specify the new experiment time range that applies + ModelUpdatePrep(traceId, clearData, trange); + } else { + // clean up any possible pending request + request.cancel(); + + // Start the new request. + StateManagerFactory.getExperimentManager() + .readExperimentTimeWindow(newerReq, viewID, this); + } } } @@ -133,307 +114,103 @@ public abstract class AbsTimeUpdateView extends TmfView implements * processingCompleted(org.eclipse.linuxtools.lttng.state.StateDataRequest) */ @TmfSignalHandler - public void processingCompleted(RequestCompletedSignal signal) { - ILttngSyntEventRequest request = signal.getRequest(); + public synchronized void processingCompleted(RequestCompletedSignal signal) { + StateDataRequest request = signal.getRequest(); if (request == null) { return; - } + } else { + reqState.setCurrentRequest(null); - // Update wait cursor - waitCursor(false); + } // No data refresh actions for cancelled requests. if (request.isCancelled() || request.isFailed()) { + + requestStateUpdate(); + if (TraceDebug.isDEBUG()) { TmfTimeRange trange = request.getRange(); if (request.isCancelled()) { TraceDebug.debug("Request cancelled " + trange.getStartTime() + "-" + trange.getEndTime() - + " Handled Events: " + request.getSynEventCount() - + " " + request.toString(), 15); + + " Handled Events: " + request.getNumOfEvents()); } else if (request.isFailed()) { TraceDebug.debug("Request Failed " + trange.getStartTime() + "-" + trange.getEndTime() + " Handled Events: " - + request.getSynEventCount() + " " - + request.toString()); + + request.getNumOfEvents()); } } return; } else { - modelInputChanged(request, true); + ModelUpdateComplete(request); + requestStateUpdate(); } } /** - * Registers as listener of time selection from other views + * Evaluates the need to either send a new data request or queue the request + * till next available opportunity. One element queue to keep the latest + * request only. * - * @param signal + * @param trange */ - public void synchToTime(TmfTimeSynchSignal signal) { - if (synch) { - Object source = signal.getSource(); - if (signal != null && source != null && source != this) { - // Internal value is expected in nano seconds. - long selectedTime = signal.getCurrentTime().getValue(); - if (tsfviewer != null) { - tsfviewer.setSelectedTime(selectedTime, true, source); + public synchronized void dataRequest(TmfTimeRange trange) { + if (trange != null) { + // cancelPendingRequests(); + StateDataRequest currentRequest = reqState.getCurrentRequest(); + // If a request is ongoing queue the new request + if (reqState.getState().equals(RequestState.BUSY)) { + reqState.setQueued(trange); + currentRequest = reqState.getCurrentRequest(); + if (currentRequest != null) { + currentRequest.cancel(); + } else { + TraceDebug + .debug("Exception : State busy but current request is null"); } - } - } - } - - /** - * Process the reception of time window adjustment in this view if the - * source of the update is not this view. - * - * @param signal - * @param clearingData - */ - public void synchToTimeRange(TmfRangeSynchSignal signal, boolean clearingData) { - if (synch) { - Object source = signal.getSource(); - if (signal != null && source != null && source != this) { - // Internal value is expected in nano seconds. - TmfTimeRange trange = signal.getCurrentRange(); - TmfExperiment experiment = TmfExperiment.getCurrentExperiment(); - if (experiment == null) { - TraceDebug.debug("Current selected experiment is null"); - return; + } else { + // Set the state to busy + reqState.setState(DataRequestState.RequestState.BUSY); + waitCursor(true); + if (TraceDebug.isDEBUG()) { + TraceDebug + .debug("Requesting data: " + trange.getStartTime() + + "-" + trange.getEndTime()); } + // no request is ongoing, proceed with request + StateManagerFactory.getExperimentManager() + .readExperimentTimeWindow(trange, viewID, this); - // Clearing of process data is configurable - dataRequest(trange, experiment.getTimeRange(), clearingData); } } } /** - * Trigger time synchronisation to other views this method shall be called - * when a check has been performed to note that an actual change of time has - * been performed vs a pure re-selection of the same time - * - * @param time - * @param source + * Check for pending request an either send a new request or change the + * state to idle */ - protected void synchTimeNotification(long time, Object source) { - // if synchronisation selected - if (synch) { - // Notify other views - TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(source, new LttngTimestamp(time))); - } - } - - /** - * Common implementation of ITmfTimeSelectionListener, not used by all the - * views extending this abstract class - * - * @param event - */ - protected void tsfTmProcessSelEvent(TmfTimeSelectionEvent event) { - Object source = event.getSource(); - if (source == null) { - return; - } - - ParamsUpdater paramUpdater = getParamsUpdater(); - Long savedSelTime = paramUpdater.getSelectedTime(); - - long selTimens = event.getSelectedTime(); - - // make sure the new selected time is different than saved before - // executing update - if (savedSelTime == null || savedSelTime != selTimens) { - // Notify listener views. - synchTimeNotification(selTimens, source); - - // Update the parameter updater to save the selected time - paramUpdater.setSelectedTime(selTimens); - + private synchronized void requestStateUpdate() { + // Check if a new time range update is waiting to be processed + TmfTimeRange queuedRequest = reqState.popQueued(); + if (queuedRequest != null) { + // Trigger the pending request if (TraceDebug.isDEBUG()) { - TraceDebug.debug("Selected Time: " + new LttngTimestamp(selTimens) + "\n\t\t" + getName()); - } - } - } - - /** - * Common implementation of ITmfTimeScaleSelectionListener, not used by all - * the views extending this abstract class - * - * @param event - */ - protected synchronized void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { - // source needed to keep track of source values - Object source = event.getSource(); - - if (source != null) { - // Update the parameter updater before carrying out a read request - ParamsUpdater paramUpdater = getParamsUpdater(); - boolean newParams = paramUpdater.processTimeScaleEvent(event); - - if (newParams) { - // Read the updated time window - TmfTimeRange trange = paramUpdater.getTrange(); - if (trange != null) { - - // Notify listener views. to perform data requests - // upon this notification - synchTimeRangeNotification(trange, paramUpdater.getSelectedTime(), source); - } - } - } - } - - /** - * Inform registered listeners about the new time range - * - * @param trange - * @param selectedTime - * @param source - */ - protected void synchTimeRangeNotification(TmfTimeRange trange, Long selectedTime, Object source) { - // if synchronisation selected - if (synch) { - // Notify other views - TmfSignalManager.dispatchSignal(new TmfRangeSynchSignal(source, trange, new LttngTimestamp(selectedTime))); - } - } - - /** - * @param zoomedTRange - * @param experimentTRange - */ - public void dataRequest(TmfTimeRange zoomedTRange, - TmfTimeRange experimentTRange, boolean clearingData) { - - // timeRange is the Experiment time range - boolean sent = processDataRequest(zoomedTRange, experimentTRange, clearingData); - - if (sent) { - waitCursor(true); - } - } - - /** - * send data request directly e.g. doesn't use a queue - * - * @param requestTrange - * @param listener - * @param experimentTRange - * @param processor - * @return - */ - private boolean processDataRequest(TmfTimeRange requestTrange, - TmfTimeRange experimentTRange, boolean clearingData) { - // Validate input - if (requestTrange == null || experimentTRange == null) { - TraceDebug.debug("Invalid input"); - return false; - } - - LttngSyntEventRequest request = new LttngSyntEventRequest( - requestTrange, DEFAULT_OFFSET, TmfDataRequest.ALL_DATA, - DEFAULT_CHUNK, this, experimentTRange, getEventProcessor()) { - - Long fCount = getSynEventCount(); - ITransEventProcessor processor = getProcessor(); - TmfTimestamp frunningTimeStamp; - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.lttng.request.LttngSyntEventRequest#handleData - * () - */ - @Override - public void handleData() { - TmfEvent[] result = getData(); - - TmfEvent evt = (result.length > 0) ? result[0] : null; - if (evt != null) { - LttngSyntheticEvent synEvent = (LttngSyntheticEvent) evt; - // process event - SequenceInd indicator = synEvent.getSynType(); - if (indicator == SequenceInd.BEFORE - || indicator == SequenceInd.AFTER) { - processor.process(evt, synEvent.getTraceModel()); - } else if (indicator == SequenceInd.STARTREQ) { - handleRequestStarted(); - } else if (indicator == SequenceInd.ENDREQ) { - processor.process(evt, synEvent.getTraceModel()); - // handleCompleted(); - } - - if (indicator == SequenceInd.BEFORE) { - fCount++; - if (fCount != 0 && fCount % INPUT_CHANGED_REFRESH == 0) { - // send partial update - modelInputChanged(this, false); - - if (TraceDebug.isDEBUG()) { - frunningTimeStamp = evt.getTimestamp(); - TraceDebug.debug("handled: " + fCount + " sequence: " + synEvent.getSynType()); - } - - } - } - } - } - - public void handleRequestStarted() { - notifyStarting(); - } - - @Override - public void handleCompleted() { - super.handleCompleted(); - - // Data is not complete and should be handled as such - if (isFailed() || isCancelled()) { - modelIncomplete(this); - } - - if (TraceDebug.isDEBUG()) { - if (frunningTimeStamp != null) { - TraceDebug.debug("Last event time stamp: " - + frunningTimeStamp.getValue()); - } - } + TmfTimestamp start = queuedRequest.getStartTime(); + TmfTimestamp end = queuedRequest.getEndTime(); + TraceDebug.debug("New request about to start: " + start + "-" + + end); } - }; - - // obtain singleton core provider - LttngSyntheticEventProvider provider = LttngCoreProviderFactory - .getEventProvider(); - - // send the request to TMF - request.startRequestInd(provider); - request.setclearDataInd(clearingData); - return true; - } - /** - * Returns an initial smaller window to allow the user to select the area of - * interest - * - * @param experimentTRange - * @return - */ - protected TmfTimeRange getInitTRange(TmfTimeRange experimentTRange) { - TmfTimestamp expStartTime = experimentTRange.getStartTime(); - TmfTimestamp expEndTime = experimentTRange.getEndTime(); - TmfTimestamp initialEndOfWindow = new LttngTimestamp(expStartTime - .getValue() - + INITIAL_WINDOW_OFFSET); - if (initialEndOfWindow.compareTo(expEndTime, false) < 0) { - return new TmfTimeRange(expStartTime, initialEndOfWindow); + StateManagerFactory.getExperimentManager() + .readExperimentTimeWindow(queuedRequest, viewID, this); + } else { + // All requests cancelled and no more pending requests + TraceDebug.debug("No requests pending in the queue"); + reqState.setState(RequestState.IDLE); + waitCursor(false); } - - // The original size of the experiment is smaller than proposed adjusted - // time - return experimentTRange; } /** @@ -442,230 +219,26 @@ public abstract class AbsTimeUpdateView extends TmfView implements * * @param waitInd */ - protected void waitCursor(final boolean waitInd) { - if (tsfviewer != null) { - Display display = tsfviewer.getControl().getDisplay(); - - // Perform the updates on the UI thread - display.asyncExec(new Runnable() { - public void run() { - tsfviewer.waitCursor(waitInd); - } - }); - } - } + protected abstract void waitCursor(boolean waitInd); /** - * View preparation to override the current local information + * View preparation to override the current local information related to the + * given traceId * + * @param traceId + * @param clearAllData + * - reset all data e.g when a new experiment is selected * @param timeRange * - new total time range e.g. Experiment level - * @param clearAllData - */ - protected void ModelUpdatePrep(TmfTimeRange timeRange, boolean clearAllData) { - ItemContainer itemContainer = getItemContainer(); - if (clearAllData) { - // start fresh e.g. new experiment selected - itemContainer.clearItems(); - } else { - // clear children but keep processes - itemContainer.clearChildren(); - } - - // Obtain the current resource array - ITmfTimeAnalysisEntry[] itemArr = itemContainer.readItems(); - - // clean up data and boundaries - displayModel(itemArr, -1, -1, false, -1, -1, null); - - ParamsUpdater updater = getParamsUpdater(); - if (updater != null) { - // Start over - updater.setEventsDiscarded(0); - - // Update new visible time range if available - if (timeRange != null) { - updater.update(timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue()); - } - } - } - - /** - * Initialize the model and view before reloading items - * - * @param boundaryRange - * @param visibleRange - * @param source */ - protected void ModelUpdateInit(TmfTimeRange boundaryRange, TmfTimeRange visibleRange, Object source) { - // Update the view boundaries - if (boundaryRange != null) { - ItemContainer itemContainer = getItemContainer(); - if (itemContainer != null) { - itemContainer.clearItems(); - // Obtain the current process array - ITmfTimeAnalysisEntry[] itemArr = itemContainer.readItems(); - - long startTime = boundaryRange.getStartTime().getValue(); - long endTime = boundaryRange.getEndTime().getValue(); - - // Update the view part - displayModel(itemArr, startTime, endTime, true, visibleRange.getStartTime().getValue(), visibleRange - .getEndTime().getValue(), source); - } - } - - // update the view filtering parameters - if (visibleRange != null) { - ParamsUpdater updater = getParamsUpdater(); - if (updater != null) { - // Start over - updater.setEventsDiscarded(0); - // Update new visible time range if available - updater.update(visibleRange.getStartTime().getValue(), visibleRange.getEndTime().getValue()); - } - } - } + public abstract void ModelUpdatePrep(String traceId, boolean clearAllData, + TmfTimeRange timeRange); /** * Actions taken by the view to refresh its widget(s) with the updated data * model * * @param request - * @param complete - * true: yes, false: partial update - */ - protected void modelInputChanged(ILttngSyntEventRequest request, boolean complete) { - long experimentStartTime = -1; - long experimentEndTime = -1; - TmfTimeRange experimentTimeRange = request.getExperimentTimeRange(); - if (experimentTimeRange != null) { - experimentStartTime = experimentTimeRange.getStartTime().getValue(); - experimentEndTime = experimentTimeRange.getEndTime().getValue(); - } - - // Obtain the current resource list - ITmfTimeAnalysisEntry[] itemArr = getItemContainer().readItems(); - - if (itemArr != null) { - // Sort the array by pid - Arrays.sort(itemArr); - - // Update the view part - displayModel(itemArr, experimentStartTime, experimentEndTime, false, request.getRange().getStartTime() - .getValue(), request.getRange().getEndTime().getValue(), request.getSource()); - } - - if (complete) { - // reselect to original time - ParamsUpdater paramUpdater = ResourceModelFactory.getParamsUpdater(); - if (paramUpdater != null && tsfviewer != null) { - final Long selTime = paramUpdater.getSelectedTime(); - if (selTime != null) { - TraceDebug.debug("View: " + getName() + "\n\t\tRestoring the selected time to: " + selTime); - Display display = tsfviewer.getControl().getDisplay(); - display.asyncExec(new Runnable() { - public void run() { - tsfviewer.setSelectedTime(selTime, false, this); - } - }); - } - - if (TraceDebug.isDEBUG()) { - int eventCount = 0; - Long count = request.getSynEventCount(); - for (int pos = 0; pos < itemArr.length; pos++) { - eventCount += itemArr[pos].getTraceEvents().size(); - } - - int discarded = getParamsUpdater().getEventsDiscarded(); - int discardedOutofOrder = paramUpdater.getEventsDiscardedWrongOrder(); - TmfTimeRange range = request.getRange(); - StringBuilder sb = new StringBuilder("View: " + getName() + ", Events handled: " + count - + ", Events loaded in view: " + eventCount + ", Number of events discarded: " + discarded - + "\n\tNumber of events discarded with start time earlier than next good time: " - + discardedOutofOrder); - - sb.append("\n\t\tRequested Time Range: " + range.getStartTime() + "-" + range.getEndTime()); - sb.append("\n\t\tExperiment Time Range: " + experimentStartTime + "-" + experimentEndTime); - TraceDebug.debug(sb.toString()); - } - } - - } - } - - // /** - // * Obtains the remainder fraction on unit Seconds of the entered value in - // * nanoseconds. e.g. input: 1241207054171080214 ns The number of seconds - // can - // * be obtain by removing the last 9 digits: 1241207054 the fractional - // * portion of seconds, expressed in ns is: 171080214 - // * - // * @param v - // * @return - // */ - // protected String formatNs(long v) { - // StringBuffer str = new StringBuffer(); - // boolean neg = v < 0; - // if (neg) { - // v = -v; - // str.append('-'); - // } - // - // String strVal = String.valueOf(v); - // if (v < 1000000000) { - // return strVal; - // } - // - // // Extract the last nine digits (e.g. fraction of a S expressed in ns - // return strVal.substring(strVal.length() - 9); - // } - - /** - * The request was stopped, the data is incomplete - * - * @param request - */ - protected abstract void modelIncomplete(ILttngSyntEventRequest request); - - /** - * Returns the Event processor instance related to a specific view - * - * @return - */ - protected abstract ITransEventProcessor getEventProcessor(); - - /** - * To be overridden by some sub-classes although may not be needed in some - * e.g. statistics view - * - * @param items - * @param startBoundTime - * @param endBoundTime - * @param updateTimeBounds - * - Time bounds updated needed e.g. if a new Experiment or trace - * is selected - * @param startVisibleWindow - * @param endVisibleWindow - * @param source - */ - protected abstract void displayModel(final ITmfTimeAnalysisEntry[] items, final long startBoundTime, - final long endBoundTime, final boolean updateTimeBounds, final long startVisibleWindow, - final long endVisibleWindow, final Object source); - - /** - * To be overridden by some sub-classes although may not be needed in some - * e.g. statistics view - * - * @return - */ - protected abstract ParamsUpdater getParamsUpdater(); - - /** - * Returns the model's item container - * - * @return */ - protected abstract ItemContainer getItemContainer(); + public abstract void ModelUpdateComplete(StateDataRequest request); } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/DataRequestState.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/DataRequestState.java new file mode 100644 index 0000000000..6a1fee4855 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/DataRequestState.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.common; + +import org.eclipse.linuxtools.lttng.state.StateDataRequest; +import org.eclipse.linuxtools.lttng.ui.TraceDebug; +import org.eclipse.linuxtools.tmf.event.TmfTimeRange; + +/** + * One instance to keep track of the state of data request and a single time + * range data request pending in queue + * + * @author alvaro + * + */ +public class DataRequestState { + + // ======================================================================== + // Data + // ======================================================================== + public enum RequestState { + IDLE, BUSY + } + + private TmfTimeRange queued = null; + RequestState state = RequestState.IDLE; + private StateDataRequest currentRequest = null; + + // ======================================================================== + // Methods + // ======================================================================== + /** + * @return the data request time range in queue + */ + public synchronized TmfTimeRange peekQueued() { + return queued; + } + + /** + * @return the data request time range in queue and reset it reference to + * null to get ready for a new entry in queue + */ + public synchronized TmfTimeRange popQueued() { + // Save the reference to current request + TmfTimeRange result = queued; + // remove from queue + queued = null; + // Send original reference + return result; + } + + /** + * @param queued + *

+ * Set the data request time range to be waiting for processing + *

+ *

+ * Only the latest request is preserved + *

+ */ + public synchronized void setQueued(TmfTimeRange nqueued) { + if (TraceDebug.isDEBUG()) { + if (this.queued != null) { + StringBuilder sb = new StringBuilder( + "Queued request replaced from: " + + + queued.getStartTime() + "-" + + queued.getEndTime() + "\n\t\t to: " + + nqueued.getStartTime() + "-" + + nqueued.getEndTime()); + TraceDebug.debug(sb.toString()); + } + } + + this.queued = nqueued; + } + + /** + * @return the state + */ + public synchronized RequestState getState() { + return state; + } + + /** + * @param state + * the state to set + */ + public synchronized void setState(RequestState state) { + this.state = state; + } + + public synchronized void setCurrentRequest(StateDataRequest currentRequest) { + this.currentRequest = currentRequest; + } + + public synchronized StateDataRequest getCurrentRequest() { + return currentRequest; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java index ae9c3a5bb3..5659066bd0 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java @@ -33,10 +33,9 @@ public class ParamsUpdater { private long startTime = 0; private long endTime = Long.MAX_VALUE; private Long selectedTime = null; - private final int DEFAULT_WIDTH = 2000; // number of estimated pixels - // that + private final int defaultWidth = 2000; // number of estimated pixels that // can hold the time range space - private int width = DEFAULT_WIDTH; // width in pixels used to represent the + private int width = defaultWidth; // width in pixels used to represent the // time interval private double pixelsPerNs = 0; private int eventsDiscarded = 0; @@ -61,14 +60,7 @@ public class ParamsUpdater { int dwidth = event.getWidth(); updated = update(time0, time1, dwidth); - - // initialization only, otherwise wait for the actual selection - // event to update its value. Note that the time must be different - // upon selection of a new time in order to trigger an update to all - if (selectedTime == null) { - setSelectedTime(event.getSelectedTime()); - } - + setSelectedTime(event.getSelectedTime()); } return updated; @@ -80,9 +72,11 @@ public class ParamsUpdater { * @param selTime */ public void setSelectedTime(long selTime) { - TraceDebug.debug("Selected time changed from: \n\t" + selectedTime - + " to: \n\t" + selTime); - selectedTime = selTime; + if (selTime > startTime && selTime < endTime) { + selectedTime = selTime; + } else { + selectedTime = null; + } } /** @@ -181,9 +175,9 @@ public class ParamsUpdater { */ public int getWidth() { if (width == 0) { - TraceDebug - .debug("Unexpected width value of 0 pixels, returning default"); - return DEFAULT_WIDTH; + return defaultWidth; + } else { + TraceDebug.debug("Unexpected width value of 0 pixels"); } return width; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java index 342fb026ec..e3c3fd13d8 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.controlflow; +import java.util.Arrays; import java.util.Vector; import org.eclipse.jface.action.Action; @@ -33,24 +34,24 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.linuxtools.lttng.event.LttngTimestamp; -import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest; -import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor; +import org.eclipse.linuxtools.lttng.state.StateDataRequest; +import org.eclipse.linuxtools.lttng.state.StateManager; +import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy; +import org.eclipse.linuxtools.lttng.state.experiment.StateExperimentManager; +import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.ui.TraceDebug; -import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeViewerProvider; import org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView; import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; -import org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor.FlowEventToHandlerFactory; +import org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor.FlowTRangeUpdateFactory; import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowModelFactory; -import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; -import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; +import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory; +import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeFilterSelectionListener; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener; @@ -61,11 +62,15 @@ import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysis import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Menu; @@ -80,6 +85,8 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; /** * ControlFlowView + *

+ * TODO: Implement me. Please. */ /** * @author alvaro @@ -131,10 +138,13 @@ public class ControlFlowView extends AbsTimeUpdateView implements private Action filterTraces; private Action zoomIn; private Action zoomOut; - private Action zoomFilter; + private Action synch; + private ITimeAnalysisViewer tsfviewer; private ViewProcessFilter tableFilter = null; private ScrolledComposite scrollFrame = null; + private Composite wrapper = null; + private Composite top; // private static SimpleDateFormat stimeformat = new SimpleDateFormat( // "yy/MM/dd HH:mm:ss"); @@ -164,7 +174,9 @@ public class ControlFlowView extends AbsTimeUpdateView implements public void inputChanged(Viewer v, Object oldInput, Object newInput) { this.elements = (ITmfTimeAnalysisEntry[]) newInput; if (elements != null) { - TraceDebug.debug("Total number of processes provided to Control Flow view: " + elements.length); + TraceDebug + .debug("Total number of processes provided to Control Flow view: " + + elements.length); } else { TraceDebug.debug("New input = null"); } @@ -182,6 +194,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements // @Override public Object[] getElements(Object inputElement) { + // TODO Auto-generated method stub return elements; } } @@ -294,102 +307,113 @@ public class ControlFlowView extends AbsTimeUpdateView implements * This is a callback that will allow us to create the viewer and initialize * it. */ - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse - * .swt.widgets.Composite) - */ @Override public void createPartControl(Composite parent) { + top = new Composite(parent, SWT.BORDER); - scrollFrame = new ScrolledComposite(parent, SWT.V_SCROLL); - + top.setLayout(new FillLayout()); + + scrollFrame = new ScrolledComposite(top, SWT.V_SCROLL | SWT.H_SCROLL); + scrollFrame.setBounds(top.getClientArea()); + + wrapper = new Composite(scrollFrame, SWT.NONE); + scrollFrame.setEnabled(true); + scrollFrame.setRedraw(true); scrollFrame.setExpandVertical(true); scrollFrame.setExpandHorizontal(true); + scrollFrame.setContent(wrapper); scrollFrame.setAlwaysShowScrollBars(true); - - SashForm sash = new SashForm(scrollFrame, SWT.NONE); - scrollFrame.setContent(sash); - - tableViewer = new TableViewer(sash, SWT.FULL_SELECTION | SWT.H_SCROLL); + wrapper.setLayout(new FillLayout()); + + SashForm sash = new SashForm(wrapper, SWT.NONE); + final Composite tableComposite = new Composite(sash, SWT.NO_SCROLL); + FillLayout layout = new FillLayout(); + tableComposite.setLayout(layout); + tableViewer = new TableViewer(tableComposite, SWT.FULL_SELECTION + | SWT.H_SCROLL); tableViewer.setContentProvider(new ViewContentProvider(tableViewer)); tableViewer.setLabelProvider(new ViewLabelProvider()); Table table = tableViewer.getTable(); - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection sel = event.getSelection(); - if (!sel.isEmpty()) { - Object firstSel = null; - if (sel instanceof IStructuredSelection) { - firstSel = ((IStructuredSelection) sel).getFirstElement(); - - // Make sure the selection is visible - updateScrollOrigin(); - - if (firstSel instanceof ITmfTimeAnalysisEntry) { - ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) firstSel; - tsfviewer.setSelectedTrace(trace); + tableViewer + .addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + ISelection sel = event.getSelection(); + if (!sel.isEmpty()) { + Object firstSel = null; + if (sel instanceof IStructuredSelection) { + firstSel = ((IStructuredSelection) sel) + .getFirstElement(); + + // Make sure the selection is visible + updateScrollOrigin(); + + if (firstSel instanceof ITmfTimeAnalysisEntry) { + ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) firstSel; + tsfviewer.setSelectedTrace(trace); + } + } } } - } - } - /** - * Make sure the selected item is visible - */ - private void updateScrollOrigin() { - Table table = tableViewer.getTable(); - if (table != null && table.getItemCount() > 0) { - TableItem item = table.getSelection()[0]; - if (item == null) { - // no selected reference to go up or down - return; - } + /** + * Make sure the selected item is visible + */ + private void updateScrollOrigin() { + Table table = tableViewer.getTable(); + if (table != null && table.getItemCount() > 0) { + TableItem item = table.getSelection()[0]; + if (item == null) { + // no selected reference to go up or down + return; + } - Rectangle itemRect = item.getBounds(); - int step = itemRect.height; + Rectangle itemRect = item.getBounds(); + int step = itemRect.height; - // calculate height of horizontal bar - int hscrolly = 0; - ScrollBar hbar = scrollFrame.getHorizontalBar(); - if (hbar != null) { - hscrolly = hbar.getSize().y; - } + // calculate height of horizontal bar + int hscrolly = 0; + ScrollBar hbar = scrollFrame.getHorizontalBar(); + if (hbar != null) { + hscrolly = hbar.getSize().y; + } - int visibleHeight = scrollFrame.getSize().y - hscrolly; + int visibleHeight = scrollFrame.getSize().y + - hscrolly; - // the current scrollbar offset to adjust i.e. start - // of - // the visible window - Point origin = scrollFrame.getOrigin(); - // end of visible window - int endy = origin.y + visibleHeight; + // the current scrollbar offset to adjust i.e. start + // of + // the visible window + Point origin = scrollFrame.getOrigin(); + // end of visible window + int endy = origin.y + visibleHeight; - int itemStartPos = itemRect.y + table.getHeaderHeight() + table.getBorderWidth() - + table.getParent().getBorderWidth(); + int itemStartPos = itemRect.y + + table.getHeaderHeight() + + table.getBorderWidth() + + table.getParent().getBorderWidth(); - // Item End Position - int itemEndPos = itemStartPos + step; + // Item End Position + int itemEndPos = itemStartPos + step; - // check if need to go up - if (origin.y >= step && itemStartPos < origin.y) { - // one step up - scrollFrame.setOrigin(origin.x, origin.y - step); + // check if need to go up + if (origin.y >= step && itemStartPos < origin.y) { + // one step up + scrollFrame + .setOrigin(origin.x, origin.y - step); - } + } // check if it needs to go down - if (itemEndPos > endy) { - // one step down - scrollFrame.setOrigin(origin.x, origin.y + step); + if (itemEndPos > endy) { + // one step down + scrollFrame + .setOrigin(origin.x, origin.y + step); } - } - } - }); - + } + } + }); + // Listen to page up /down and Home / Enc keys tableViewer.getTable().addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { @@ -483,7 +507,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements int borderWidth = table.getBorderWidth(); - int itemHeight = table.getItemHeight() + checkForSWTBugItemHeightAdjustement(); + int itemHeight = table.getItemHeight(); int headerHeight = table.getHeaderHeight(); table.getVerticalBar().setVisible(false); @@ -521,38 +545,54 @@ public class ControlFlowView extends AbsTimeUpdateView implements hookDoubleClickAction(); contributeToActionBars(); - // scrollFrame.addControlListener(new ControlAdapter() { - // - // @Override - // public void controlResized(ControlEvent e) { - // tsfviewer.resizeControls(); - // updateScrolls(scrollFrame); - // } - // }); + scrollFrame.addControlListener(new ControlAdapter() { + @Override + public void controlResized(ControlEvent e) { + tsfviewer.resizeControls(); + updateScrolls(scrollFrame, wrapper); + } + }); + + tableComposite.addControlListener(new ControlListener() { + public void controlResized(ControlEvent e) { + scrollFrame.getParent().update(); + } + + public void controlMoved(ControlEvent e) { + + } + }); + + // Register the updater in charge to refresh elements as we update the + // time ranges + // FlowParamsUpdater listener = FlowModelFactory.getParamsUpdater(); + // tsfviewer.addWidgetTimeScaleSelectionListner(listener); + + // Register this view to receive updates when the model is updated with + // fresh info + // ModelListenFactory.getRegister().addFlowModelUpdatesListener(this); + + // Register the event processor factory in charge of event handling + EventProcessorProxy.getInstance().addEventProcessorFactory( + FlowTRangeUpdateFactory.getInstance()); // set the initial view parameter values // Experiment start and end time // as well as time space width in pixels, used by the time analysis // widget + ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater(); + StateExperimentManager experimentManger = StateManagerFactory + .getExperimentManager(); // Read relevant values int timeSpaceWidth = tsfviewer.getTimeSpace(); - if (timeSpaceWidth < 0) { - timeSpaceWidth = -timeSpaceWidth; + TmfTimeRange timeRange = experimentManger.getExperimentTimeRange(); + if (timeRange != null) { + long time0 = timeRange.getStartTime().getValue(); + long time1 = timeRange.getEndTime().getValue(); + paramUpdater.update(time0, time1, timeSpaceWidth); } - TmfExperiment experiment = TmfExperiment.getCurrentExperiment(); - if (experiment != null) { - TmfTimeRange experimentTRange = experiment.getTimeRange(); - - // send request and received the adjusted time used - TmfTimeRange adjustedTimeRange = initialExperimentDataRequest(this, - experimentTRange); - - // initialize widget time boundaries and filtering parameters - ModelUpdateInit(experimentTRange, adjustedTimeRange, this); - } else { - TraceDebug.debug("No selected experiment information available"); - } + experimentManger.readExperiment("flowView", this); } private void hookContextMenu() { @@ -586,7 +626,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements // manager.add(filterTraces); manager.add(zoomIn); manager.add(zoomOut); - manager.add(zoomFilter); + manager.add(synch); manager.add(new Separator()); } @@ -602,7 +642,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements // manager.add(filterTraces); manager.add(zoomIn); manager.add(zoomOut); - manager.add(zoomFilter); + manager.add(synch); manager.add(new Separator()); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } @@ -618,12 +658,12 @@ public class ControlFlowView extends AbsTimeUpdateView implements // manager.add(filterTraces); manager.add(zoomIn); manager.add(zoomOut); - manager.add(zoomFilter); + manager.add(synch); manager.add(new Separator()); } private void makeActions() { - // resetScale + // action4 resetScale = new Action() { @Override public void run() { @@ -641,7 +681,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements .getString("ControlFlowView.tmf.UI"), "icons/home_nav.gif")); - // nextEvent + // action5 nextEvent = new Action() { @Override public void run() { @@ -659,7 +699,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements .getString("ControlFlowView.tmf.UI"), "icons/next_event.gif")); - // prevEvent + // action6 prevEvent = new Action() { @Override public void run() { @@ -677,7 +717,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements .getString("ControlFlowView.tmf.UI"), "icons/prev_event.gif")); - // nextTrace + // action7 nextTrace = new Action() { @Override public void run() { @@ -695,7 +735,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements .getString("ControlFlowView.tmf.UI"), "icons/next_item.gif")); - // prevTrace + // action8 prevTrace = new Action() { @Override public void run() { @@ -713,7 +753,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements .getString("ControlFlowView.tmf.UI"), "icons/prev_item.gif")); - // showLegend + // action9 showLegend = new Action() { @Override public void run() { @@ -726,7 +766,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements showLegend.setToolTipText(Messages .getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$ - // filterTraces + // action10 filterTraces = new Action() { @Override public void run() { @@ -744,7 +784,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements .getString("ControlFlowView.tmf.UI"), "icons/filter_items.gif")); - // zoomIn + // action10 zoomIn = new Action() { @Override public void run() { @@ -760,7 +800,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements Messages.getString("ControlFlowView.tmf.UI"), "icons/zoomin_nav.gif")); - // zoomOut + // action10 zoomOut = new Action() { @Override public void run() { @@ -776,24 +816,29 @@ public class ControlFlowView extends AbsTimeUpdateView implements Messages.getString("ControlFlowView.tmf.UI"), "icons/zoomout_nav.gif")); - // zoomFilter - zoomFilter = new Action() { + // action11 + synch = new Action() { @Override public void run() { - // Nothing to do, however the selection status is needed by the - // application + // Note: No action since the synch flag is used by Control flow + // view + // the actual viewer is set to accept api selections in + // createpartcontrol. + + // if (synch.isChecked()) { + // tsfviewer.setAcceptSelectionAPIcalls(true); + // } else { + // tsfviewer.setAcceptSelectionAPIcalls(false); + // } } }; - zoomFilter.setText(Messages - .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$ - zoomFilter.setToolTipText(Messages - .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$ - zoomFilter.setImageDescriptor(AbstractUIPlugin - .imageDescriptorFromPlugin(Messages - .getString("ControlFlowView.tmf.UI"), - "icons/filter_items.gif")); - zoomFilter.setChecked(false); - + synch.setText(Messages.getString("ControlFlowView.Action.Synchronize")); //$NON-NLS-1$ + synch.setToolTipText(Messages + .getString("ControlFlowView.Action.Synchronize.ToolTip")); //$NON-NLS-1$ + synch.setChecked(false); + synch.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( + Messages.getString("ControlFlowView.tmf.UI"), + "icons/synced.gif")); // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED); doubleClickAction = new Action() { @@ -828,37 +873,85 @@ public class ControlFlowView extends AbsTimeUpdateView implements tableViewer.getControl().setFocus(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * tsfTmProcessSelEvent - * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent - * ) - */ - @Override public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event) { - // common implementation - super.tsfTmProcessSelEvent(event); + Object source = event.getSource(); + if (source == null) { + return; + } // Reselect the table viewer to widget selection ISelection sel = tsfviewer.getSelectionTrace(); if (sel != null && !sel.isEmpty()) { tableViewer.setSelection(sel); } + + ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater(); + Long savedSelTime = paramUpdater.getSelectedTime(); + + long selTimens = event.getSelectedTime(); + + // make sure the new selected time is different than saved before + // executing update + if (savedSelTime == null || savedSelTime != selTimens) { + // Notify listener views. + synchTimeNotification(selTimens); + + // Update the parameter updater to save the selected time + paramUpdater.setSelectedTime(selTimens); + + if (TraceDebug.isDEBUG()) { + // Object selection = event.getSelection(); + TraceDebug.debug("Selected Time in control Flow View: " + + new LttngTimestamp(selTimens)); + } + } } - /* - * (non-Javadoc) + public synchronized void tsfTmProcessTimeScaleEvent( + TmfTimeScaleSelectionEvent event) { + // source needed to keep track of source values + Object source = event.getSource(); + + if (source != null) { + // Update the parameter updater before carrying out a read request + ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater(); + boolean newParams = paramUpdater.processTimeScaleEvent(event); + + if (newParams) { + // Read the updated time window + TmfTimeRange trange = paramUpdater.getTrange(); + if (trange != null) { + // Request new data for specified time range + dataRequest(trange); + } + } + } + } + + /** + * Obtains the remainder fraction on unit Seconds of the entered value in + * nanoseconds. e.g. input: 1241207054171080214 ns The number of seconds can + * be obtain by removing the last 9 digits: 1241207054 the fractional + * portion of seconds, expressed in ns is: 171080214 * - * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis. - * ITmfTimeScaleSelectionListener - * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools - * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent) + * @param v + * @return */ - @Override - public synchronized void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { - super.tsfTmProcessTimeScaleEvent(event); + public String formatNs(long v) { + StringBuffer str = new StringBuffer(); + boolean neg = v < 0; + if (neg) { + v = -v; + str.append('-'); + } + + String strVal = String.valueOf(v); + if (v < 1000000000) { + return strVal; + } + + // Extract the last nine digits (e.g. fraction of a S expressed in ns + return strVal.substring(strVal.length() - 9); } private void applyTableLayout(Table table) { @@ -871,20 +964,15 @@ public class ControlFlowView extends AbsTimeUpdateView implements table.setLinesVisible(true); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel - * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. - * ITmfTimeAnalysisEntry[], long, long, boolean, long, long, - * java.lang.Object) + /** + * @param items + * @param startTime + * @param endTime + * @param updateTimeBounds - Update needed e.g. a new Experiment or trace selected */ - @Override - public void displayModel(final ITmfTimeAnalysisEntry[] items, - final long startBoundTime, final long endBoundTime, - final boolean updateTimeBounds, final long startVisibleWindow, - final long endVisibleWindow, final Object source) { + public void flowModelUpdates(final ITmfTimeAnalysisEntry[] items, + final long startTime, final long endTime, + final boolean updateTimeBounds) { final Table table = tableViewer.getTable(); Display display = table.getDisplay(); @@ -901,21 +989,14 @@ public class ControlFlowView extends AbsTimeUpdateView implements table.update(); tableViewer.refresh(); - tsfviewer.display(items, startBoundTime, endBoundTime, - updateTimeBounds); - - // validate visible boundaries - if (startVisibleWindow > -1 && endVisibleWindow > -1) { - tsfviewer.setSelectVisTimeWindow(startVisibleWindow, - endVisibleWindow, source); - } - + tsfviewer.display(items, startTime, endTime, updateTimeBounds); tsfviewer.resizeControls(); // Adjust the size of the vertical scroll bar to fit the // contents - if (scrollFrame != null) { - updateScrolls(scrollFrame); + if (scrollFrame != null && wrapper != null) { + updateScrolls(scrollFrame, wrapper); + // scrollFrame.update(); } } }); @@ -925,7 +1006,12 @@ public class ControlFlowView extends AbsTimeUpdateView implements public void dispose() { // dispose parent resources super.dispose(); + // Remove the event processor factory + EventProcessorProxy.getInstance().removeEventProcessorFactory( + FlowTRangeUpdateFactory.getInstance()); + // Remove listener to model updates + // ModelListenFactory.getRegister().removeFlowModelUpdatesListener(this); tsfviewer.removeFilterSelectionListner(this); tsfviewer.removeWidgetSelectionListner(this); tsfviewer.removeWidgetTimeScaleSelectionListner(this); @@ -967,132 +1053,186 @@ public class ControlFlowView extends AbsTimeUpdateView implements * @param scrollFrame * @param wrapper */ - private void updateScrolls(final ScrolledComposite scrollFrame) { - scrollFrame.setMinSize(tableViewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT)); + private void updateScrolls(final ScrolledComposite scrollFrame, + final Composite wrapper) { + + Point ptSize = wrapper.computeSize(SWT.DEFAULT, SWT.DEFAULT); + wrapper.setSize(ptSize); + scrollFrame.setMinSize(ptSize); + + // calculate the increment area considering the table header height and + // borders + Rectangle area = top.getBounds(); + int marginsHeight = tableViewer.getTable().getHeaderHeight(); + marginsHeight -= top.getBorderWidth() + wrapper.getBorderWidth(); + area.height -= marginsHeight; + + // set page vertical increment area + ScrollBar verBar = scrollFrame.getVerticalBar(); + ScrollBar horBar = scrollFrame.getHorizontalBar(); + if (verBar != null) { + verBar.setPageIncrement(area.height); + } + if (horBar != null) { + horBar.setPageIncrement(area.width); + } + } /** - * Registers as listener of time selection from other views + * Trigger time synchronisation to other views this method shall be called + * when a check has been performed to note that an actual change of time has + * been performed vs a pure re-selection of the same time * - * @param signal + * @param time */ - @Override - @TmfSignalHandler - public void synchToTime(TmfTimeSynchSignal signal) { - super.synchToTime(signal); + private void synchTimeNotification(long time) { + // if synchronisation selected + if (synch.isChecked()) { + // Notify other views + TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(this, + new LttngTimestamp(time))); + } } /** - * Annotation Registers as listener of time range selection from other views - * The implementation handles the entry of the signal. + * Registers as listener of time selection from other tmf views * * @param signal */ @TmfSignalHandler - public void synchToTimeRange(TmfRangeSynchSignal signal) { - if (zoomFilter != null) { - synchToTimeRange(signal, zoomFilter.isChecked()); + public void synchToTime(TmfTimeSynchSignal signal) { + if (synch.isChecked()) { + Object source = signal.getSource(); + if (signal != null && source != null && source != this) { + // Internal value is expected in nano seconds. + long selectedTime = signal.getCurrentTime().getValue(); + if (tsfviewer != null) { + tsfviewer.setSelectedTime(selectedTime, true, source); + } + } } } - @Override - public void modelIncomplete(ILttngSyntEventRequest request) { - // Nothing to do - // The data will be refreshed on the next request - } - /* * (non-Javadoc) * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * getEventProcessor() + * @see + * org.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView#waitCursor + * (boolean) */ @Override - public ITransEventProcessor getEventProcessor() { - return FlowEventToHandlerFactory.getInstance(); - } - - /** - * @param signal - */ - @TmfSignalHandler - public void experimentSelected( - TmfExperimentSelectedSignal signal) { - if (signal != null) { - TmfTimeRange experimentTRange = signal.getExperiment() - .getTimeRange(); - - // prepare time intervals in widget - ModelUpdateInit(experimentTRange, experimentTRange, signal - .getSource()); - - // request initial data - initialExperimentDataRequest(signal - .getSource(), experimentTRange); - } - } - - /** - * @param source - * @param experimentTRange - * @return Adjusted time window used for the request (smaller window to - * initialize view) - */ - private TmfTimeRange initialExperimentDataRequest(Object source, - TmfTimeRange experimentTRange) { - // Adjust the initial time window to a shorter interval to allow - // user to select the interesting area based on the perspective - TmfTimeRange initTimeWindow = getInitTRange(experimentTRange); - - dataRequest(initTimeWindow, experimentTRange, true); - if (TraceDebug.isDEBUG()) { - TraceDebug.debug("Initialization request time range is: " - + initTimeWindow.getStartTime().toString() + "-" - + initTimeWindow.getEndTime().toString()); - } - - return initTimeWindow; - } - - // *** HACK *** - // - // - // - public int checkForSWTBugItemHeightAdjustement() { - int returnedAjustement = 0; - String desktopSessionName = System.getenv("DESKTOP_SESSION"); - - // Gnome : most common case, no adjustement - if ( desktopSessionName.equals("gnome") ) { - returnedAjustement = 0; - } - // Kde : ajustement of 2 is needed - else if ( desktopSessionName.equals("kde") ) { - returnedAjustement = 2; + protected synchronized void waitCursor(final boolean waitInd) { + if (tsfviewer != null) { + Display display = tsfviewer.getControl().getDisplay(); + + // Perform the updates on the UI thread + display.asyncExec(new Runnable() { + public void run() { + tsfviewer.waitCursor(waitInd); + } + }); } - - return returnedAjustement; } /* * (non-Javadoc) * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * getParamsUpdater() + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# + * ModelUpdatePrep(java.lang.String, boolean) */ @Override - protected ParamsUpdater getParamsUpdater() { - return FlowModelFactory.getParamsUpdater(); + public void ModelUpdatePrep(String traceId, boolean clearAllData, + TmfTimeRange trange) { + if (clearAllData) { + FlowModelFactory.getProcContainer().clearProcesses(); + // Obtain the current process array + TimeRangeEventProcess[] processArr = FlowModelFactory + .getProcContainer().readProcesses(); + + + // initialise to an empty model + flowModelUpdates(processArr, -1, -1, false); + } else { + FlowModelFactory.getProcContainer().clearChildren(traceId); + } + + ParamsUpdater updater = FlowModelFactory.getParamsUpdater(); + // Start over + updater.setEventsDiscarded(0); + + // Update new visible time range if available + if (trange != null) { + updater.update(trange.getStartTime().getValue(), trange + .getEndTime().getValue()); + } } /* * (non-Javadoc) * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * getItemContainer() + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# + * ModelUpdateComplete(org.eclipse.linuxtools.lttng.state.StateDataRequest) */ @Override - protected ItemContainer getItemContainer() { - return FlowModelFactory.getProcContainer(); + public void ModelUpdateComplete(StateDataRequest request) { + long experimentStartTime = -1; + long experimentEndTime = -1; + StateManager smanager = request.getStateManager(); + TmfTimeRange experimentTimeRange = smanager.getExperimentTimeWindow(); + if (experimentTimeRange != null) { + experimentStartTime = experimentTimeRange.getStartTime().getValue(); + experimentEndTime = experimentTimeRange.getEndTime().getValue(); + } + // Obtain the current process array + TimeRangeEventProcess[] processArr = FlowModelFactory + .getProcContainer().readProcesses(); + // Sort the array by pid + Arrays.sort(processArr); + + // Update the view part + flowModelUpdates(processArr, experimentStartTime, experimentEndTime, + request.isclearDataInd()); + + // get back to user selected time if still within range + ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater(); + final Long selTime = paramUpdater.getSelectedTime(); + if (selTime != null) { + Display display = tsfviewer.getControl().getDisplay(); + display.asyncExec(new Runnable() { + public void run() { + tsfviewer.setSelectedTime(selTime, false, this); + } + }); + } + + if (TraceDebug.isDEBUG()) { + int eventCount = 0; + Long count = smanager.getEventCount(); + for ( int pos = 0; posnext_good_time,evtime) > 0) + // *** // Visibility check // Display a "more information" indication by allowing non visible event // as long as its previous event is visible. @@ -149,6 +147,12 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements ILt .size() - 1); prevEventVisibility = prevEvent.isVisible(); + // ***VERIFY*** + // This replace all C Call like this one ? + // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime, + // time_window.start_time) == -1 || ltt_time_compare(evtime, + // time_window.end_time) == 1) + // if previous event visibility is false and the time span // between events less than two pixels, there is no need to // load it in memory i.e. not visible and a more indicator is @@ -171,13 +175,26 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements ILt } // Create the time-range event + // *** VERIFY *** + // This should replace this C call, right? + // TimeWindow time_window = + // lttvwindow_get_time_window(control_flow_data->tab); TimeRangeEvent time_window = new TimeRangeEvent(stime, etime, localProcess, Type.PROCESS_MODE, stateMode); + // *** VERIFY *** + // This is added to replace the multiple draw and gtk/glib command but + // I'm not sure about it time_window.setVisible(visible); localProcess.getTraceEvents().add(time_window); localProcess.setNext_good_time(etime); + // *** VERIFY *** + // Missing checks like this one? + // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime, + // time_window.start_time) == -1 || ltt_time_compare(evtime, + // time_window.end_time) == 1) + return false; } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeAfterUpdateHandlers.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeAfterUpdateHandlers.java new file mode 100644 index 0000000000..df7e041f8a --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeAfterUpdateHandlers.java @@ -0,0 +1,423 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.state.StateStrings.Events; +import org.eclipse.linuxtools.lttng.state.StateStrings.Fields; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; +import org.eclipse.linuxtools.lttng.state.model.LttngProcessState; +import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; +import org.eclipse.linuxtools.lttng.ui.TraceDebug; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; +import org.eclipse.linuxtools.tmf.event.TmfTimeRange; + +/** + * Creates instances of specific after state update handlers, per corresponding + * event. + * + * @author alvaro + * + */ +class FlowTRangeAfterUpdateHandlers { + /** + *

+ * Handles: LTT_EVENT_SCHED_SCHEDULE + *

+ * Replace C function "after_schedchange_hook" in eventhooks.c + *

+ * Fields: LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID + *

+ * + * @return + */ + final IEventProcessing getSchedChangeHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_SCHED_SCHEDULE; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + // get event time, cpu, trace_number, process, pid + LttngProcessState process_in = traceSt.getRunning_process().get(trcEvent.getCpuId()); + + // pid_out is never used, even in LTTv! + //Long pid_out = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PREV_PID); + Long pid_in = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_NEXT_PID); + + if ( !(pid_in.equals(process_in.getPid())) ) { + TraceDebug.debug("pid_in != PID! (getSchedChangeHandler)"); + } + + //hashed_process_data = processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num); + TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(),process_in.getCreation_time() ); + + if ( localProcess == null ) { + if ( (pid_in == 0) || (pid_in != process_in.getPpid()) ) { + TmfTimeRange timeRange = traceSt.getInputDataRef().getTraceTimeWindow(); + localProcess = addLocalProcess(process_in, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId()); + } + else { + TraceDebug + .debug("pid_in is not 0 or pid_in == PPID! (getSchedChangeHandler)"); + } + } + + // There is no drawing done by the C code below, only refreshing + // the references to the current hash data to make it ready for + // next event + + // This current implementation does not support the use of + // current hashed data + // although an equivalent would be good in order to improve the + // time to find the currently running process per cpu. + /* + if(ltt_time_compare(hashed_process_data_in->next_good_time, evtime) <= 0) + { + TimeWindow time_window = lttvwindow_get_time_window(control_flow_data->tab); + + #ifdef EXTRA_CHECK + if(ltt_time_compare(evtime, time_window.start_time) == -1 || ltt_time_compare(evtime, time_window.end_time) == 1) + return FALSE; + #endif //EXTRA_CHECK + + Drawing_t *drawing = control_flow_data->drawing; + guint width = drawing->width; + guint new_x; + + convert_time_to_pixels(time_window,evtime,width,&new_x); + + if(hashed_process_data_in->x.middle != new_x) { + hashed_process_data_in->x.middle = new_x; + hashed_process_data_in->x.middle_used = FALSE; + hashed_process_data_in->x.middle_marked = FALSE; + } + }*/ + + return false; + + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_PROCESS_FORK + *

+ * Replace C function "after_process_fork_hook" in eventhooks.c + *

+ * Fields: LTT_FIELD_CHILD_PID + *

+ * + * @return + */ + final IEventProcessing getProcessForkHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_PROCESS_FORK; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + Long child_pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_CHILD_PID); + LttngProcessState process_child = lttv_state_find_process(traceSt, trcEvent.getCpuId(), child_pid ); + + if ( process_child != null ) { + TimeRangeEventProcess localProcess = procContainer.findProcess(process_child.getPid(), process_child.getCpu(), traceSt.getTraceId(), process_child.getCreation_time() ); + + if ( localProcess == null ) { + if ( (child_pid == 0) || (child_pid != process_child.getPpid()) ) { + TmfTimeRange timeRange = traceSt.getInputDataRef().getTraceTimeWindow(); + localProcess = addLocalProcess(process_child, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId()); + } + else { + TraceDebug.debug("localProcess is null with child_pid not 0 or child_pid equals PPID (getProcessForkHandler)"); + } + } else { + // If we found the process, the Ppid and the Tgid might + // be missing, let's add them + localProcess.setPpid(process_child.getPpid()); + localProcess.setTgid(process_child.getTgid()); + } + } + else { + TraceDebug.debug("process_child is null! (getProcessForkHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_PROCESS_EXIT + *

+ * Replace C function "after_process_exit_hook" in eventhooks.c + * + * @return + */ + final IEventProcessing getProcessExitHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_PROCESS_EXIT; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + LttngProcessState process = traceSt.getRunning_process().get(trcEvent.getCpuId()); + + if ( process != null ) { + + // *** TODO: *** + // We shall look into a way to find the current process + // faster, see the c library + // (current_hash) in order to speed up the find. see c-code + // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){ + // hashed_process_data = process_list->current_hash_data[trace_num][cpu]; + // } + TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time()); + + if ( localProcess == null ) { + if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) { + TmfTimeRange timeRange = traceSt.getInputDataRef().getTraceTimeWindow(); + localProcess = addLocalProcess(process, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId()); + } + else { + TraceDebug.debug("process pid is not 0 or pid equals ppid! (getProcessExitHandler)"); + } + } + } + else { + TraceDebug.debug("process is null! (getProcessExitHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + + /** + *

+ * Handles: LTT_EVENT_EXEC + *

+ * Replace C function "after_fs_exec_hook" in eventhooks.c + * + * @return + */ + final IEventProcessing getProcessExecHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_EXEC; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + LttngProcessState process = traceSt.getRunning_process().get(trcEvent.getCpuId()); + + if ( process != null ) { + + TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time()); + + if ( localProcess == null ) { + if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) { + TmfTimeRange timeRange = traceSt.getInputDataRef().getTraceTimeWindow(); + localProcess = addLocalProcess(process, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId()); + } + else { + TraceDebug.debug("process pid is not 0 or pid equals ppid! (getProcessExecHandler)"); + } + } + else { + // If we found the process, the name might be missing. Let's add it here. + localProcess.setName(process.getName()); + } + } + else { + TraceDebug.debug("process is null! (getProcessExecHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + /** + *

+ * LTT_EVENT_THREAD_BRAND + *

+ * Replace C function "after_user_generic_thread_brand_hook" in eventhooks.c + * + * @return + */ + final IEventProcessing GetThreadBrandHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_THREAD_BRAND; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + LttngProcessState process = traceSt.getRunning_process().get(trcEvent.getCpuId()); + + if ( process != null ) { + + // Similar to above comments, implement a faster way to find + // the local process + // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){ + // hashed_process_data = process_list->current_hash_data[trace_num][cpu]; + // } + TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time()); + + if ( localProcess == null ) { + if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) { + TmfTimeRange timeRange = traceSt.getInputDataRef().getTraceTimeWindow(); + localProcess = addLocalProcess(process, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId()); + } + else { + TraceDebug.debug("process pid is not 0 or pid equals ppid! (GetThreadBrandHandler)"); + } + } + else { + // If we found the process, the brand might be missing + // on it, add it. + localProcess.setBrand(process.getBrand()); + } + } + else { + TraceDebug.debug("process is null! (GetThreadBrandHandler)"); + } + + return false; + + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + /** + *

+ * LTT_EVENT_PROCESS_STATE + *

+ * Replace C function "after_event_enum_process_hook" in eventhooks.c + *

+ *

+ * Creates the processlist entry for the child process. Put the last + * position in x at the current time value. + *

+ * + *

+ * Fields: LTT_FIELD_PID + *

+ * + * @return + */ + final IEventProcessing getEnumProcessStateHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_PROCESS_STATE; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + int first_cpu; + int nb_cpus; + + Long pid_in = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_PID); + + // Lttv assume that pid_in will NEVER be null or incoherent + // What if ... ? (let's add some debug) + if ( pid_in != null ) { + if(pid_in == 0L) { + first_cpu = 0; + nb_cpus = traceSt.getNumberOfCPUs(); + } + else { + first_cpu = ANY_CPU.intValue(); + nb_cpus = ANY_CPU.intValue() + 1; + } + + for (int cpu = first_cpu; cpu < nb_cpus; cpu++) { + LttngProcessState process_in = lttv_state_find_process(traceSt, trcEvent.getCpuId(), pid_in ); + + if ( process_in != null ) { + TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(), process_in.getCreation_time()); + + if (localProcess == null) { + if ( (process_in.getPid() == 0) || (process_in.getPid() != process_in.getPpid()) ) { + TmfTimeRange timeRange = traceSt.getInputDataRef().getTraceTimeWindow(); + localProcess = addLocalProcess(process_in, timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue(), traceSt.getTraceId()); + } + else { + TraceDebug.debug("process pid is not 0 or pid equals ppid! (getEnumProcessStateHandler)"); + } + } + else { + // If the process was found, it might be missing informations, add it here + localProcess.setName(process_in.getName()); + localProcess.setPpid(process_in.getPpid()); + localProcess.setTgid(process_in.getTgid()); + } + } + else { + TraceDebug.debug("process_in is null! This should never happen. (getEnumProcessStateHandler)"); + } + } + } + else { + TraceDebug.debug("pid_in is null! This should never happen, really... (getEnumProcessStateHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java new file mode 100644 index 0000000000..cad26eee4e --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java @@ -0,0 +1,427 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.state.StateStrings.Events; +import org.eclipse.linuxtools.lttng.state.StateStrings.Fields; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; +import org.eclipse.linuxtools.lttng.state.model.LttngProcessState; +import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; +import org.eclipse.linuxtools.lttng.ui.TraceDebug; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; +import org.eclipse.linuxtools.tmf.event.TmfTimeRange; + +/** + * Creates instances of specific before state update handlers, per corresponding + * event. + * + * @author alvaro + * + */ +class FlowTRangeBeforeUpdateHandlers { + /** + *

+ * Handles: LTT_EVENT_SYSCALL_ENTRY + *

+ * Replace C function named "before_execmode_hook" in eventhooks.c + * + * @return + */ + final IEventProcessing getStateModesHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + // this method is common to many events + private Events eventType = Events.LTT_EVENT_SYSCALL_ENTRY; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + Long cpu = trcEvent.getCpuId(); + LttngProcessState stateProcess = traceSt.getRunning_process() + .get(cpu); + // TraceDebug.debug("Before handler called"); + String traceId = traceSt.getTraceId(); + + if (stateProcess != null) { + // Find process within the list of registered time-range + // related + // processes + + // key process attributes to look for it or store it + // are: pid, birth, trace_num, note: cpu not relevant since + // it + // may change + TimeRangeEventProcess localProcess = procContainer + .findProcess(stateProcess.getPid(), stateProcess.getCpu(), traceId, stateProcess + .getCreation_time()); + + // Add process to process list if not present + if (localProcess == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localProcess = addLocalProcess(stateProcess, timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceId); + } + + // Do the actual drawing + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + stateProcess, localProcess, params); + } else { + TraceDebug + .debug("Running state process is null! (getStateModesHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_SCHED_SCHEDULE + *

+ * Replace C function named "before_schedchange_hook" in eventhooks.c + *

+ * Fields: LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE (?) + *

+ * + * @return + */ + final IEventProcessing getBeforeSchedChangeHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_SCHED_SCHEDULE; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + Long pid_out = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_PREV_PID); + Long pid_in = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_NEXT_PID); + + // This is useless even in Lttv !! + // Long state_out = getAFieldLong(trcEvent, traceSt, + // Fields.LTT_FIELD_PREV_STATE); + + // We need to process information. + LttngProcessState process = traceSt.getRunning_process().get( + trcEvent.getCpuId()); + + if (process != null) { + if (process.getPid().equals(pid_out) == false) { + // To replace : + // process = lttv_state_find_process(ts,tfs->cpu, + // pid_out); + process = lttv_state_find_process(traceSt, trcEvent + .getCpuId(), pid_out); + // Also, removed : + // guint trace_num = ts->parent.index; + } + + if (process != null) { + // TODO: Implement something similar to current hash in + // order to keep track of the current process and speed + // up finding the local resource. + + // HashedProcessData *hashed_process_data = NULL; + // hashed_process_data = + // processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num); + TimeRangeEventProcess localProcess = procContainer + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process.getCreation_time()); + + // Add process to process list if not present + // Replace C Call : + // processlist_add(process_list,drawing,pid_out,process->tgid,process->cpu,process->ppid,&birth,trace_num,process->name,process->brand,&pl_height,&process_info,&hashed_process_data); + if (localProcess == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localProcess = addLocalProcess(process, timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceSt + .getTraceId()); + } + + // Do the actual drawing + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, + localProcess, params); + } else { + // Process may be null if the process started BEFORE the + // trace start + // TraceDebug.debug("Process is null for pid_out! (getBeforeSchedChangeHandler)"); + } + + // PID_IN section + process = lttv_state_find_process(traceSt, trcEvent + .getCpuId(), pid_in); + + if (process != null) { + // HashedProcessData *hashed_process_data = NULL; + // hashed_process_data = + // processlist_get_process_data(process_list, pid_in, + // tfs->cpu, &birth, trace_num); + TimeRangeEventProcess localProcess = procContainer + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process.getCreation_time()); + + // Add process to process list if not present + // Replace C Call : + // processlist_add(process_list, drawing, pid_in, + // process->tgid, tfs->cpu, process->ppid, &birth, + // trace_num, process->name, process->brand, &pl_height, + // &process_info, &hashed_process_data); + if (localProcess == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localProcess = addLocalProcess(process, timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceSt + .getTraceId()); + } + + // Do the actual drawing + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, + localProcess, params); + + } else { + // Process can be null if it started AFTER the trace + // end. Do nothing... + // TraceDebug.debug("No process found for pid_in! Something is wrong? (getBeforeSchedChangeHandler)"); + } + } else { + TraceDebug + .debug("Running process is null! (getBeforeSchedChangeHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_PROCESS_EXIT + *

+ * Replace C function named "before_process_exit_hook" in eventhooks.c + * + * @return + */ + final IEventProcessing getProcessExitHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_PROCESS_EXIT; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + // We need to process information. + LttngProcessState process = traceSt.getRunning_process().get( + trcEvent.getCpuId()); + + if (process != null) { + // TODO: Implement a similar method to track the current + // local process in order to speed up finding the local + // resource + + // hashed_process_data = + // processlist_get_process_data(process_list, pid, + // process->cpu, &birth,trace_num); + TimeRangeEventProcess localProcess = procContainer + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process.getCreation_time()); + + // Add process to process list if not present + // Replace C Call : + // processlist_add(process_list, drawing, pid, + // process->tgid, process->cpu, process->ppid, &birth, + // trace_num, process->name, process->brand,&pl_height, + // &process_info, &hashed_process_data); + if (localProcess == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localProcess = addLocalProcess(process, timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceSt.getTraceId()); + } + + // Call the function that does the actual drawing + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, localProcess, params); + + } else { + TraceDebug + .debug("Running process is null! (getProcessExitHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_PROCESS_FREE + *

+ * Replace C function named "before_process_release_hook" in eventhooks.c + *

+ * Fields: LTT_FIELD_PID + *

+ * + * @return + */ + final IEventProcessing getProcessFreeHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_PROCESS_FREE; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + // PID of the process to release + Long release_pid = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_PID); + + if ((release_pid != null)) { + LttngProcessState process = lttv_state_find_process( + traceSt, ANY_CPU, release_pid); + if (process != null) { + + // Replace the C call : + // hashed_process_data = + // processlist_get_process_data(process_list,pid,process->cpu,&birth,trace_num); + TimeRangeEventProcess localProcess = procContainer + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process + .getCreation_time()); + + // This is as it was in the C ... ? + if (localProcess == null) { + return false; + } + + // Perform the drawing + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, + localProcess, params); + } + } else { + TraceDebug + .debug("Release_pid is null! (getProcessFreeHandler)"); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_STATEDUMP_END + *

+ * Replace C function named "before_statedump_end" in eventhooks.c + * + * @return + */ + final IEventProcessing getStateDumpEndHandler() { + AbsFlowTRangeUpdate handler = new AbsFlowTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_STATEDUMP_END; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + // What's below should replace the following call in C : + // ClosureData closure_data; + // closure_data.events_request = events_request; + // closure_data.tss = tss; + // closure_data.end_time = evtime; + // convert_time_to_pixels(time_window,evtime,width,&closure_data.x_end); + // g_hash_table_foreach(process_list->process_hash, + // draw_closure,(void*)&closure_data); + // + // And the draw is always the same then... + + // The c-library loops through the local processes, search for + // the local processes in the state provider and then draws + // If it's present is the local processes why shuldn't they be + // present in the state provider? + // This seems more direct. and makes sure all processes are + // reflected in the control flow view. + LttngProcessState[] processes = traceSt.getProcesses(); + for (int pos=0; pos < processes.length; pos++) { + LttngProcessState process = processes[pos]; + + // Replace the C call : + // hashed_process_data = + // processlist_get_process_data(process_list,pid,process->cpu,&birth,trace_num); + TimeRangeEventProcess localProcess = procContainer + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process + .getCreation_time()); + + // Add process to process list if not present + if (localProcess == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localProcess = addLocalProcess(process, timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceSt.getTraceId()); + } + + // Call the function that will does the actual + // drawing + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, localProcess, params); + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java new file mode 100644 index 0000000000..dbaeb542df --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2009 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: Alvaro Sanchez-Leon - Initial implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor; + +import java.util.Vector; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.state.StateStrings.Events; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; +import org.eclipse.linuxtools.lttng.state.model.LttngProcessState; +import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; +import org.eclipse.linuxtools.lttng.ui.TraceDebug; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; + +/** + * Creates specific finish state data request + * + * @author alvaro + * + */ +public class FlowTRangeFinishUpdateHandler extends AbsFlowTRangeUpdate + implements IEventProcessing { + + public Events getEventHandleType() { + // No specific event + return null; + } + + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + // Draw a last known state to the end of the trace + long endReqTime = traceSt.getInputDataRef().getTraceTimeWindow() + .getEndTime().getValue(); + TraceDebug.debug("Number of localProcesses: " + + procContainer.readProcesses().length); + // to identify the process relevant to the traceState + String traceId = traceSt.getTraceId(); + int numLocalFound = 0; + int numLocalNotFound = 0; + int numWithNoChildren = 0; + for (TimeRangeEventProcess localProcess : procContainer.readProcesses()) { + LttngProcessState stateProcess = lttv_state_find_process(traceSt, + localProcess.getCpu(), localProcess.getPid()); + + // Drawing the last state for processes related to the current trace + // id. + if (!localProcess.getTraceID().equals(traceId)) { + continue; + } + + // Check if the process is in the state provider, it is the case + // when the requested time frame did not include any events for a + // process + if (stateProcess == null) { + // Get Start time from the end time of previous event + Vector childrenEvents = localProcess + .getTraceEvents(); + long nextGoodTime; + String stateMode; + if (childrenEvents.size() > 0) { + TimeRangeComponent prevEvent = childrenEvents + .get(childrenEvents.size() - 1); + if (prevEvent instanceof TimeRangeEvent) { + TimeRangeEvent prevTimeRange = (TimeRangeEvent) prevEvent; + // calculate the next good time to draw the event + // nextGoodTime = prevTimeRange.getStopTime() + 1; + nextGoodTime = localProcess.getNext_good_time(); + stateMode = prevTimeRange.getStateMode(); + + // Draw with the Local information since the current + // request did + // not contain events related to this process + makeDraw(traceSt, nextGoodTime, + endReqTime, localProcess, params, stateMode); + } else { + TraceDebug + .debug("previous event not instance of TimeRangeEvent?: " + + prevEvent.getClass().getSimpleName()); + } + } else { + numWithNoChildren++; + } + + numLocalNotFound++; + continue; + } + numLocalFound++; + // Draw the last state for this process + + makeDraw(traceSt, endReqTime, stateProcess, localProcess, params); + } + + TraceDebug.debug("Print Last Event: NumLocalFound " + numLocalFound + + "; NumLocalNotFound: " + numLocalNotFound + + "; NumWithNoChildren: " + numWithNoChildren); + + return false; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeUpdateFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeUpdateFactory.java new file mode 100644 index 0000000000..b5ae367d87 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeUpdateFactory.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.linuxtools.lttng.state.StateStrings; +import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; + +/** + * Builds a Map from string event name to a processing handler object, the + * processors implement the same interface to facilitate transparent methods + * call, + * + * The map key STring is the entry point of the raw events, using a hash speeds + * up the resolution of the appropriate processor + * + * @author alvaro + * + */ +public class FlowTRangeUpdateFactory extends AbsEventProcessorFactory { + // ======================================================================== + // Data + // ======================================================================= + private final Map eventNametoBeforeProcessor = new HashMap(); + private final Map eventNametoAfterProcessor = new HashMap(); + private IEventProcessing finishProcesor = null; + private static FlowTRangeUpdateFactory instance = null; + private FlowTRangeBeforeUpdateHandlers instantiateBeforeHandler = new FlowTRangeBeforeUpdateHandlers(); + private FlowTRangeAfterUpdateHandlers instantiateAfterHandler = new FlowTRangeAfterUpdateHandlers(); + + // ======================================================================== + // Constructors + // ======================================================================= + private FlowTRangeUpdateFactory() { + // Create one instance of each individual event handler and add the + // instance to the map + + // BEFORE HOOKS + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SYSCALL_ENTRY.getInName(), + instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SYSCALL_EXIT.getInName(), + instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY + .getInName(), instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT + .getInName(), instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY.getInName(), + instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT.getInName(), + instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY + .getInName(), instantiateBeforeHandler + .getStateModesHandler()); + + eventNametoBeforeProcessor + .put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT + .getInName(), instantiateBeforeHandler + .getStateModesHandler()); + + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY + .getInName(), instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT + .getInName(), instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY.getInName(), + instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT.getInName(), + instantiateBeforeHandler.getStateModesHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(), + instantiateBeforeHandler.getBeforeSchedChangeHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PROCESS_EXIT.getInName(), + instantiateBeforeHandler.getProcessExitHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PROCESS_FREE.getInName(), + instantiateBeforeHandler.getProcessFreeHandler()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_STATEDUMP_END.getInName(), + instantiateBeforeHandler.getStateDumpEndHandler()); + + + // AFTER HOOKS + eventNametoAfterProcessor.put( + StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(), + instantiateAfterHandler.getSchedChangeHandler()); + + eventNametoAfterProcessor.put( + StateStrings.Events.LTT_EVENT_PROCESS_FORK.getInName(), + instantiateAfterHandler.getProcessForkHandler()); + + eventNametoAfterProcessor.put( + StateStrings.Events.LTT_EVENT_PROCESS_EXIT.getInName(), + instantiateAfterHandler.getProcessExitHandler()); + + eventNametoAfterProcessor.put(StateStrings.Events.LTT_EVENT_EXEC + .getInName(), instantiateAfterHandler.getProcessExecHandler()); + + eventNametoAfterProcessor.put( + StateStrings.Events.LTT_EVENT_THREAD_BRAND.getInName(), + instantiateAfterHandler.GetThreadBrandHandler()); + + eventNametoAfterProcessor.put( + StateStrings.Events.LTT_EVENT_PROCESS_STATE.getInName(), + instantiateAfterHandler.getEnumProcessStateHandler()); + + finishProcesor = new FlowTRangeFinishUpdateHandler(); + } + + // ======================================================================== + // Public methods + // ======================================================================= + /** + * The event processors are common to all traces an multiple instances will + * use more memory unnecessarily + * + * @return + */ + public static AbsEventProcessorFactory getInstance() { + if (instance == null) { + instance = new FlowTRangeUpdateFactory(); + } + return instance; + } + + @Override + public IEventProcessing getAfterProcessor(String eventType) { + return eventNametoAfterProcessor.get(eventType); + } + + @Override + public IEventProcessing getBeforeProcessor(String eventType) { + return eventNametoBeforeProcessor.get(eventType); + } + + @Override + public IEventProcessing getfinishProcessor() { + return finishProcesor; + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/messages.properties b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/messages.properties index 0260851313..13ed41cffc 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/messages.properties +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/messages.properties @@ -20,7 +20,5 @@ ControlFlowView.Action.ZoomIn=Zoom In ControlFlowView.Action.ZoomIn.Tooltip=Zoom In ControlFlowView.Action.ZoomOut=Zoom Out ControlFlowView.Action.ZoomOut.tooltip=Zoom Out -ControlFlowView.Action.ZoomFilter=Zoom Filter -ControlFlowView.Action.ZoomFilter.tooltip=Display elements with events within the zoomed time window ControlFlowView.msgSlogan=Control Flow View ControlFlowView.tmf.UI=org.eclipse.linuxtools.tmf.ui diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java index edcd1073c0..65e0f369a0 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java @@ -15,7 +15,6 @@ import java.util.HashMap; import java.util.Iterator; import org.eclipse.linuxtools.lttng.TraceDebug; -import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; /** @@ -24,7 +23,7 @@ import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; * @author alvaro * */ -public class FlowProcessContainer implements ItemContainer { +public class FlowProcessContainer { // ======================================================================== // Data // ======================================================================== @@ -52,9 +51,9 @@ public class FlowProcessContainer implements ItemContainer iterator = allProcesses.keySet().iterator(); while (iterator.hasNext()) { process = allProcesses.get(iterator.next()); - process.reset(); + + if (process.getTraceID().equals(traceId)) { + // Reset clear childEventComposites() and traceEvents() + // Also restore the nextGoodTime to the insertionTime for the drawing + process.reset(); + } } } /** * Clear all process items */ - public void clearItems() { + public void clearProcesses() { allProcesses.clear(); } @@ -106,7 +112,7 @@ public class FlowProcessContainer implements ItemContainer iterator = allProcesses.keySet().iterator(); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java index 306adfe059..cfea3f645e 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -30,9 +30,9 @@ public class EventsView extends TmfEventsView { public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.events"; - // ------------------------------------------------------------------------ + // ======================================================================== // Table data - // ------------------------------------------------------------------------ + // ======================================================================== // Table column names private final String TIMESTAMP_COLUMN = "Timestamp"; @@ -62,19 +62,18 @@ public class EventsView extends TmfEventsView { }; private ColumnData[] columnData = new ColumnData[] { - new ColumnData(columnProperties[0], 125, SWT.LEFT), + new ColumnData(columnProperties[0], 100, SWT.LEFT), new ColumnData(columnProperties[1], 100, SWT.LEFT), - new ColumnData(columnProperties[2], 200, SWT.LEFT), - new ColumnData(columnProperties[3], 200, SWT.LEFT), + new ColumnData(columnProperties[2], 100, SWT.LEFT), + new ColumnData(columnProperties[3], 100, SWT.LEFT), new ColumnData(columnProperties[4], 100, SWT.LEFT) }; - // ------------------------------------------------------------------------ + // ======================================================================== // Constructor - // ------------------------------------------------------------------------ + // ======================================================================== public EventsView() { - super(1); } /** @@ -83,7 +82,7 @@ public class EventsView extends TmfEventsView { * FIXME: Add support for column selection */ @Override - protected void createColumnHeaders(Table table) { + protected void setColumnHeaders(Table table) { for (int i = 0; i < columnData.length; i++) { final TableColumn column = new TableColumn(table, columnData[i].alignment, i); column.setText(columnData[i].header); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java index 48d73aec04..4de5699b4a 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java @@ -7,966 +7,46 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * William Bourque - Initial API and implementation + * Francois Chouinard - Initial API and implementation *******************************************************************************/ + package org.eclipse.linuxtools.lttng.ui.views.histogram; -import org.eclipse.linuxtools.lttng.event.LttngEvent; -import org.eclipse.linuxtools.lttng.event.LttngTimestamp; -import org.eclipse.linuxtools.tmf.component.ITmfDataProvider.ExecutionType; -import org.eclipse.linuxtools.tmf.event.TmfEvent; -import org.eclipse.linuxtools.tmf.event.TmfTimeRange; -import org.eclipse.linuxtools.tmf.event.TmfTimestamp; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal; -import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal; -import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; -import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.trace.TmfContext; -import org.eclipse.linuxtools.tmf.ui.views.TmfView; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.part.ViewPart; /** * HistogramView *

- * View that contain an visual approach to the window that control the request. - * This is intended to replace the TimeFrameView - *

- * This view is composed of 2 canvas, one for the whole experiment and one for the selectionned window in the experiment. - * It also contain a certain number of controls to print or change informations about the experiment. + * TODO: Implement me. Please. */ -public class HistogramView extends TmfView implements ControlListener { - - // *** TODO *** - // Here is what's left to do in this view - // - // 1- Make sure the interval time is small enought on very big trace (bug 311930) - // The interval time of the content is dynamically assigned from the screen width and trace duration. - // However, on very big trace (more than 1 hour), we could end up with time interval that are > 1 seconds, - // which is not very precise. - // An algorithm need to be implemented to make sure we "increase" the number of interval in the content if - // their precision is getting too bad. - // - // 2- Make sure all control are thread safe (bug 309348) - // Right now, all the basic controls (i.e. Text and Label) are sensible to "Thread Access Exception" if - // updated from different threads; we need to carefully decide when/where to redraw them. - // This is a real problem since there is a lot of thread going on in this view. - // All basic control should be subclassed to offer "Asynchronous" functions. - // - // 3- Implement a "preferences view" for the HistogramView (bug 311935) - // There is a lot of ajustable preferences in the view, however there is no way to ajust them right now - // at run time. There should be a view of some kind of "menu" to allow the user to change them while executing. - // Most of the pertinent values are in HistogramConstant.java or in this file. - +public class HistogramView extends ViewPart { + public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.histogram"; - - // "Minimum" screen width size. On smaller screen, we will apply several space saving technique - private static final int SCREEN_SMALL_IF_SMALLER_THAN = 1600; - - // Size of the "fulll trace" canvas - private static final int FULL_TRACE_CANVAS_HEIGHT = 25; - private static final int FULL_TRACE_BAR_WIDTH = 1; - private static final double FULL_TRACE_DIFFERENCE_TO_AVERAGE = 1.5; - - // Size of the "Selected Window" canvas - private static final int SELECTED_WINDOW_CANVAS_WIDTH = 300; - private static final int SMALL_SELECTED_WINDOW_CANVAS_WIDTH = 200; - private static final int SELECTED_WINDOW_CANVAS_HEIGHT = 60; - private static final int SELECTED_WINDOW_BAR_WIDTH = 1; - private static final double SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE = 10.0; - - // For the two "events" label (Max and min number of events in the selection), we force a width - // This will prevent the control from moving horizontally if the number of events in the selection varies - private static final int NB_EVENTS_FIXED_WIDTH = 50; - - - // The "small font" height used to display time will be "default font" minus this constant - private static final int SMALL_FONT_MODIFIER = 2; - private static final int VERY_SMALL_FONT_MODIFIER = 4; - - // *** TODO *** - // This need to be changed as soon the framework implement a "window" - private static long DEFAULT_WINDOW_SIZE = (1L * 100 * 1000 * 1000); // 0.1sec - - // The last experiment received/used by the view - private TmfExperiment lastUsedExperiment = null; - - // Parent of the view - private Composite parent = null; - - // Request and canvas for the "full trace" part - private HistogramRequest dataBackgroundFullRequest = null; - private ParentHistogramCanvas fullExperimentCanvas = null; - - // Request and canvas for the "selected window" - private HistogramRequest selectedWindowRequest = null; - private ChildrenHistogramCanvas selectedWindowCanvas = null; - - // Content of the timeTextGroup - // Since the user can modify them with erroneous value, - // we will keep track of the value internally - private long selectedWindowTime = 0L; - private long selectedWindowTimerange = 0L; - private long currentEventTime = 0L; - - // *** All the UI control below - // - // NOTE : All textboxes will be READ_ONLY. - // So the user will be able to select/copy the value in them but not to change it - private Text txtExperimentStartTime = null; - private Text txtExperimentStopTime = null; - - private Text txtWindowStartTime = null; - private Text txtWindowStopTime = null; - private Text txtWindowMaxNbEvents = null; - private Text txtWindowMinNbEvents = null; - - private static final String WINDOW_TIMERANGE_LABEL_TEXT = "Window Timerange "; - private static final String WINDOW_CURRENT_TIME_LABEL_TEXT = "Cursor Centered on "; - private static final String EVENT_CURRENT_TIME_LABEL_TEXT = "Current Event Time "; - private TimeTextGroup ntgTimeRangeWindow = null; - private TimeTextGroup ntgCurrentWindowTime = null; - private TimeTextGroup ntgCurrentEventTime = null; - + /** - * Default contructor of the view + * */ public HistogramView() { - super(ID); + // TODO Auto-generated constructor stub } - - /** - * Create the UI controls of this view - * - * @param parent The composite parent of this view + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ @Override - public void createPartControl(Composite newParent) { - // Save the parent - parent = newParent; - - // Default font - Font font = parent.getFont(); - FontData tmpFontData = font.getFontData()[0]; - - - Font smallFont = null; - int nbEventWidth = -1; - int selectedCanvasWidth = -1; - boolean doesTimeTextGroupNeedAdjustment = false; - - // Calculate if we need "small screen" fixes - if ( parent.getDisplay().getBounds().width < SCREEN_SMALL_IF_SMALLER_THAN ) { - // A lot smaller font for timstampe - smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - VERY_SMALL_FONT_MODIFIER, tmpFontData.getStyle()); - - // Smaller selection window canvas - selectedCanvasWidth = SMALL_SELECTED_WINDOW_CANVAS_WIDTH; - // Smaller event number text field - nbEventWidth = NB_EVENTS_FIXED_WIDTH/2; - - // Tell the text group to ajust - doesTimeTextGroupNeedAdjustment = true; - } - else { - // Slightly smaller font for timestamp - smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - SMALL_FONT_MODIFIER, tmpFontData.getStyle()); - // Usual size for selected window and event number text field - nbEventWidth = NB_EVENTS_FIXED_WIDTH; - selectedCanvasWidth = SELECTED_WINDOW_CANVAS_WIDTH; - // No ajustement needed by the text group - doesTimeTextGroupNeedAdjustment = false; - } - - // Layout for the whole view, other elements will be in a child composite of this one - // Contains : - // Composite layoutSelectionWindow - // Composite layoutTimesSpinner - // Composite layoutExperimentHistogram - Composite layoutFullView = new Composite(parent, SWT.NONE); - GridLayout gridFullView = new GridLayout(); - gridFullView.numColumns = 2; - gridFullView.horizontalSpacing = 0; - gridFullView.verticalSpacing = 0; - gridFullView.marginHeight = 0; - gridFullView.marginWidth = 0; - layoutFullView.setLayout(gridFullView); - - - // Layout that contain the SelectionWindow - // Contains : - // Label lblWindowStartTime - // Label lblWindowStopTime - // Label lblWindowMaxNbEvents - // Label lblWindowMinNbEvents - // ChildrenHistogramCanvas selectedWindowCanvas - Composite layoutSelectionWindow = new Composite(layoutFullView, SWT.NONE); - GridLayout gridSelectionWindow = new GridLayout(); - gridSelectionWindow.numColumns = 3; - gridSelectionWindow.marginHeight = 0; - gridSelectionWindow.marginWidth = 0; - gridSelectionWindow.horizontalSpacing = 0; - gridSelectionWindow.verticalSpacing = 0; - layoutSelectionWindow.setLayout(gridSelectionWindow); - GridData gridDataSelectionWindow = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1); - layoutSelectionWindow.setLayoutData(gridDataSelectionWindow); - - - // Layout that contain the time spinner - // Contains : - // NanosecTextGroup spTimeRangeWindow - // NanosecTextGroup spCurrentWindowTime - // NanosecTextGroup spCurrentEventTime - Composite layoutTimesSpinner = new Composite(layoutFullView, SWT.NONE); - GridLayout gridTimesSpinner = new GridLayout(); - gridTimesSpinner.numColumns = 3; - gridTimesSpinner.marginHeight = 0; - gridTimesSpinner.marginWidth = 0; - gridTimesSpinner.horizontalSpacing = 0; - gridTimesSpinner.verticalSpacing = 0; - layoutTimesSpinner.setLayout(gridTimesSpinner); - GridData gridDataTimesSpinner = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); - layoutTimesSpinner.setLayoutData(gridDataTimesSpinner); - - - // Layout that contain the complete experiment histogram and related controls. - // Contains : - // Label lblExperimentStartTime - // Label lblExperimentStopTime - // ParentHistogramCanvas fullTraceCanvas - Composite layoutExperimentHistogram = new Composite(layoutFullView, SWT.NONE); - GridLayout gridExperimentHistogram = new GridLayout(); - gridExperimentHistogram.numColumns = 2; - gridExperimentHistogram.marginHeight = 0; - gridExperimentHistogram.marginWidth = 0; - gridExperimentHistogram.horizontalSpacing = 0; - gridExperimentHistogram.verticalSpacing = 0; - layoutExperimentHistogram.setLayout(gridExperimentHistogram); - GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1); - layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram); - - - - // *** Everything related to the selection window is below - GridData gridDataSelectionWindowCanvas = new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 2); - gridDataSelectionWindowCanvas.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT; - gridDataSelectionWindowCanvas.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT; - gridDataSelectionWindowCanvas.widthHint = selectedCanvasWidth; - gridDataSelectionWindowCanvas.minimumWidth = selectedCanvasWidth; - selectedWindowCanvas = new ChildrenHistogramCanvas(this, layoutSelectionWindow, SWT.BORDER); - selectedWindowCanvas.setLayoutData(gridDataSelectionWindowCanvas); - - GridData gridDataWindowMaxEvents = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1); - // Force a width, to avoid the control to enlarge if the number of events change - gridDataWindowMaxEvents.minimumWidth = nbEventWidth; - txtWindowMaxNbEvents = new Text(layoutSelectionWindow, SWT.READ_ONLY); - txtWindowMaxNbEvents.setFont(smallFont); - txtWindowMaxNbEvents.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); - txtWindowMaxNbEvents.setEditable(false); - txtWindowMaxNbEvents.setText(""); - txtWindowMaxNbEvents.setLayoutData(gridDataWindowMaxEvents); - - GridData gridDataWindowMinEvents = new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1); - // Force a width, to avoid the control to enlarge if the number of events change - gridDataWindowMinEvents.minimumWidth = nbEventWidth; - txtWindowMinNbEvents = new Text(layoutSelectionWindow, SWT.READ_ONLY); - txtWindowMinNbEvents.setFont(smallFont); - txtWindowMinNbEvents.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); - txtWindowMinNbEvents.setEditable(false); - txtWindowMinNbEvents.setText(""); - txtWindowMinNbEvents.setLayoutData(gridDataWindowMinEvents); - - GridData gridDataWindowStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1); - txtWindowStartTime = new Text(layoutSelectionWindow, SWT.READ_ONLY); - txtWindowStartTime.setFont(smallFont); - txtWindowStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); - txtWindowStartTime.setEditable(false); - txtWindowStartTime.setText(""); - txtWindowStartTime.setLayoutData(gridDataWindowStart); - - GridData gridDataWindowStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1); - txtWindowStopTime = new Text(layoutSelectionWindow, SWT.READ_ONLY); - txtWindowStopTime.setFont(smallFont); - txtWindowStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); - txtWindowStopTime.setEditable(false); - txtWindowStopTime.setText(""); - txtWindowStopTime.setLayoutData(gridDataWindowStop); - - GridData gridDataSpacer = new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1); - gridDataSpacer.minimumWidth = nbEventWidth; - // *** HACK *** - // To align properly AND to make sure the canvas size is fixed, we NEED to make sure all "section" of the - // gridlayout are taken (and if possible of a fixed size). - // However, SWT is VERY VERY DUMB and won't consider griddata that contain no control. - // Since there will be missing a section, the SelectedWindowCanvas + NbEventsText will take 3 spaces, but - // startTimeText + stopTimeText will take only 2 (as if empty the other griddata of 1 will get ignored). - // StopTime will then take over the missing space; I want to align "stopTime" right on the end of canvas, so - // the added space to stop time would make it being aligned improperly - // So I NEED the empty griddata to be considered! - // Visually : - // |---------------|---------------|-----------| - // |SelectionCanvas SelectionCanvas|NbEventText| - // |SelectionCanvas SelectionCanvas|NbEventText| - // |---------------|---------------|-----------| - // |StartTime | StopTime| ??? | - // |---------------|---------------|-----------| - // - // So since SWT will only consider griddata with control, - // I need to create a totally useless control in the ??? section. - // That's ugly, useless and it is generally a bad practice. - // - // *** SUB-HACK *** - // Other interesting fact about SWT : the way it draws (Fill/Expand control in grid) will change if - // the control is a Text or a Label. - // A Label here will be "pushed" by startTime/stopTime Text and won't fill the full space as NbEventText. - // A Text here will NOT be "pushed" and would give a nice visual output. - // (NB : No, I am NOT kidding, try it for yourself!) - // - // Soooooo I guess I will use a Text here. Way to go SWT! - // Downside is that disabled textbox has a slightly different color (even if you force it yourself) so if I want - // to make the text "invisible", I have to keep it enabled (but read only), so it can be clicked on. - // - // Label uselessControlToByPassSWTStupidBug = new Label(layoutSelectionWindow, SWT.BORDER); // WON'T align correctly!!! - Text uselessControlToByPassSWTStupidBug = new Text(layoutSelectionWindow, SWT.READ_ONLY); // WILL align correctly!!! - uselessControlToByPassSWTStupidBug.setEditable(false); - uselessControlToByPassSWTStupidBug.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); - uselessControlToByPassSWTStupidBug.setLayoutData(gridDataSpacer); - - - - // *** Everything related to the time text group is below - GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2); - ntgCurrentEventTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment); - ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent); - - GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2); - ntgTimeRangeWindow = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment); - ntgTimeRangeWindow.setLayoutData(gridDataTimeRange); - - GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2); - ntgCurrentWindowTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment); - ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow); - - - - // *** Everything related to the experiment canvas is below - GridData gridDataExperimentCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1); - gridDataExperimentCanvas.heightHint = FULL_TRACE_CANVAS_HEIGHT; - gridDataExperimentCanvas.minimumHeight = FULL_TRACE_CANVAS_HEIGHT; - fullExperimentCanvas = new ParentHistogramCanvas(this, layoutExperimentHistogram, SWT.BORDER); - fullExperimentCanvas.setLayoutData(gridDataExperimentCanvas); - - GridData gridDataExperimentStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1); - txtExperimentStartTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY); - txtExperimentStartTime.setFont(smallFont); - txtExperimentStartTime.setText(""); - txtExperimentStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); - txtExperimentStartTime.setEditable(false); - txtExperimentStartTime.setLayoutData(gridDataExperimentStart); - - GridData gridDataExperimentStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1); - txtExperimentStopTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY); - txtExperimentStopTime.setFont(smallFont); - txtExperimentStopTime.setText(""); - txtExperimentStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); - txtExperimentStopTime.setEditable(false); - txtExperimentStopTime.setLayoutData(gridDataExperimentStop); + public void createPartControl(Composite parent) { + // TODO Auto-generated method stub + } - - // *** FIXME *** - // This is mainly used because of a because in the "experimentSelected()" notification, we shouldn't need this - /** - * Method called when the view receive the focus.

- * If ExperimentSelected didn't send us a request yet, get the current Experiment and fire requests + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() */ - @SuppressWarnings("unchecked") @Override public void setFocus() { - // WARNING : This does not seem to be thread safe - TmfExperiment tmpExperiment = (TmfExperiment)TmfExperiment.getCurrentExperiment(); - - if ( (dataBackgroundFullRequest == null) && (tmpExperiment != null) ) { - createCanvasAndRequests(tmpExperiment); - } - - // Call a redraw for everything - parent.redraw(); - } - - /** - * Method called when the user select (double-click on) an experiment.

- * We will create the needed canvas and fire the requests. - * - * @param signal Signal received from the framework. Contain the experiment. - */ - @SuppressWarnings("unchecked") - @TmfSignalHandler - public void experimentSelected(TmfExperimentSelectedSignal signal) { - TmfExperiment tmpExperiment = (TmfExperiment)signal.getExperiment(); - createCanvasAndRequests(tmpExperiment); - } - - // *** VERIFY *** - // Not sure what this should do since I don't know when it will be called - // Let's do the same thing as experimentSelected for now - // - /** - * Method called when an experiment is updated (??).

- * ...for now, do nothing, as udating an experiment running in the background might cause crash - * - * @param signal Signal received from the framework. Contain the experiment. - */ -// @SuppressWarnings("unchecked") - @TmfSignalHandler - public void experimentUpdated(TmfExperimentUpdatedSignal signal) { -// -// TmfExperiment tmpExperiment = (TmfExperiment)signal.getExperiment(); -// -// // Make sure the UI object are sane -// resetControlsContent(); -// -// // Redraw the canvas right away to have something "clean" as soon as we can -// fullExperimentCanvas.redraw(); -// selectedWindowCanvas.redraw(); -// -// // Recreate the request -// createCanvasAndRequests(tmpExperiment); - } - - /** - * Method called when synchonization is active and that the user select an event.

- * We update the current event timeTextGroup and move the selected window if needed. - * - * @param signal Signal received from the framework. Contain the event. - */ - @TmfSignalHandler - public void currentTimeUpdated(TmfTimeSynchSignal signal) { - // In case we received our own signal - if (signal.getSource() != this) { - TmfTimestamp currentTime = signal.getCurrentTime(); - - // Update the current event controls - currentEventTime = currentTime.getValue(); - updateSelectedEventTime(); - - // If the given event is outside the selection window, recenter the window - if ( isGivenTimestampInSelectedWindow( currentEventTime ) == false) { - fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(currentEventTime) ); - // Notify control that the window changed - windowChangedNotification(); - // Send a broadcast to the framework about the window change - sendTmfRangeSynchSignalBroadcast(); - } - } - } - - @TmfSignalHandler - public void synchToTimeRange(TmfRangeSynchSignal signal) { - if ( (signal != null) && (signal.getSource() != this) ) { - if ( lastUsedExperiment != null ) { - long currentTime = signal.getCurrentTime().getValue(); - long windowStart = signal.getCurrentRange().getStartTime().getValue(); - long windowEnd = signal.getCurrentRange().getEndTime().getValue(); - long windowTimeWidth = (windowEnd - windowStart); - - // Recenter the window - fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(windowStart + (windowTimeWidth/2)) ); - fullExperimentCanvas.setSelectedWindowSize(windowTimeWidth); - - // *** HACK *** - // Views could send us incorrect current event value (event outside the current window) - // Here we make sure the value is sane, otherwise, we force it as the left border of the window - if ( isGivenTimestampInSelectedWindow( currentTime ) == false ) { - currentTime = windowStart; - } - currentEventTime = currentTime; - - // Notify control that the window changed - windowChangedNotification(); - - // Make sure we redraw the change - fullExperimentCanvas.redraw(); - } - } - } - - - /* - * Create the canvas needed and issue the requests - * - * @param newExperiment Experiment we will use for the request - */ - private void createCanvasAndRequests(TmfExperiment newExperiment) { - // Save the experiment we are about to use - lastUsedExperiment = newExperiment; - -// // Create a copy of the trace that will be use only by the full experiment request -// TmfExperiment experimentCopy = newExperiment.createTraceCopy(); - - // Create the content for the full experiment. - // This NEED to be created first, as we use it in the selectedWindowCanvas - fullExperimentCanvas.createNewHistogramContent(fullExperimentCanvas.getSize().x, FULL_TRACE_BAR_WIDTH, FULL_TRACE_CANVAS_HEIGHT, FULL_TRACE_DIFFERENCE_TO_AVERAGE); - fullExperimentCanvas.createNewSelectedWindow(DEFAULT_WINDOW_SIZE); - - TmfTimeRange timeRange = getExperimentTimeRange(newExperiment); - currentEventTime = timeRange.getStartTime().getValue(); - - // Set the window of the fullTrace canvas visible. - fullExperimentCanvas.getCurrentWindow().setSelectedWindowVisible(true); - fullExperimentCanvas.getHistogramContent().resetTable(timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue()); - - // Create the content for the selected window. - selectedWindowCanvas.createNewHistogramContent(selectedWindowCanvas.getSize().x ,SELECTED_WINDOW_BAR_WIDTH, SELECTED_WINDOW_CANVAS_HEIGHT, SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE); - selectedWindowCanvas.getHistogramContent().resetTable(fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition(), fullExperimentCanvas.getCurrentWindow().getTimestampOfRightPosition()); - - // Make sure the UI object are sane - resetControlsContent(); - - // Redraw the canvas right away to have something "clean" as soon as we can - if ( dataBackgroundFullRequest != null ) { - fullExperimentCanvas.redraw(); - selectedWindowCanvas.redraw(); - } - // Nullify the (possible) old request to be sure we start we something clean - // Note : this is very important for the order of the request below, - // see "TODO" in performSelectedWindowEventsRequest - dataBackgroundFullRequest = null; - selectedWindowRequest = null; - - // Perform both request. - // Order is important here, the small/synchronous request for the selection window should go first - performSelectedWindowEventsRequest(newExperiment); -// performAllTraceEventsRequest(experimentCopy); - performAllTraceEventsRequest(newExperiment); - } + // TODO Auto-generated method stub - // Before completing its indexing, the experiment doesn't know start/end time. - // However, LTTng individual traces have this knowledge so we should ask them - // directly. - private TmfTimeRange getExperimentTimeRange(TmfExperiment experiment) { - // Before completing its indexing, the experiment doesn't know start/end time. - // However, LTTng individual traces have this knowledge so we should ask them - // directly. - TmfTimestamp startTime = TmfTimestamp.BigCrunch; - TmfTimestamp endTime = TmfTimestamp.BigBang; - for (ITmfTrace trace : experiment.getTraces()) { - TmfContext context = trace.seekLocation(null); - context.setRank(0); - TmfEvent event = trace.getNextEvent(context); - TmfTimestamp traceStartTime = event.getTimestamp(); - if (traceStartTime.compareTo(startTime, true) < 0) - startTime = traceStartTime; - TmfTimestamp traceEndTime = trace.getEndTime(); - if (traceEndTime.compareTo(endTime, true) > 0) - endTime = traceEndTime; - } - TmfTimeRange tmpRange = new TmfTimeRange(startTime, endTime); - return tmpRange; - } - - /** - * Perform a new request for the Selection window.

- * This assume the full experiment canvas has correct information about the selected window; - * we need the fullExperimentCanvas' HistogramContent to be created and a selection window to be set. - * - * @param experiment The experiment we will select from - */ - public void performSelectedWindowEventsRequest(TmfExperiment experiment) { - - HistogramSelectedWindow curSelectedWindow = fullExperimentCanvas.getCurrentWindow(); - - // If no selection window exists, we will try to create one; - // however this will most likely fail as the content is probably not created either - if ( curSelectedWindow == null ) { - fullExperimentCanvas.createNewSelectedWindow( DEFAULT_WINDOW_SIZE ); - curSelectedWindow = fullExperimentCanvas.getCurrentWindow(); - } - - // The request will go from the Left timestamp of the window to the Right timestamp - // This assume that out-of-bound value are handled by the SelectionWindow itself - LttngTimestamp ts1 = new LttngTimestamp( curSelectedWindow.getTimestampOfLeftPosition() ); - LttngTimestamp ts2 = new LttngTimestamp( curSelectedWindow.getTimestampOfRightPosition() ); - TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2); - - // Set a (dynamic) time interval - long intervalTime = ( (ts2.getValue() - ts1.getValue()) / selectedWindowCanvas.getHistogramContent().getNbElement() ); - - selectedWindowRequest = performRequest(experiment, selectedWindowCanvas, tmpRange, intervalTime, ExecutionType.SHORT); - selectedWindowCanvas.redrawAsynchronously(); - } - - /** - * Perform a new request for the full experiment.

- * NOTE : this is very long, we need to implement a way to run this in parallel (see TODO) - * - * @param experiment The experiment we will select from - */ - public void performAllTraceEventsRequest(TmfExperiment experiment) { - // Create a new time range from "start" to "end" - // That way, we will get "everything" in the trace -// LttngTimestamp ts1 = new LttngTimestamp( experiment.getStartTime() ); -// LttngTimestamp ts2 = new LttngTimestamp( experiment.getEndTime() ); -// TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2); - - TmfTimeRange tmpRange = getExperimentTimeRange(experiment); - TmfTimestamp startTime = tmpRange.getStartTime(); - TmfTimestamp endTime = tmpRange.getEndTime(); - - // Set a (dynamic) time interval - long intervalTime = ( (endTime.getValue() - startTime.getValue()) / fullExperimentCanvas.getHistogramContent().getNbElement() ); - - // *** VERIFY *** - // This would enable "fixed interval" instead of dynamic one. - // ... we don't need it, do we? - // - // long intervalTime = ((long)(0.001 * (double)1000000000)); - - // *** TODO *** - // It would be interesting if there was a way to tell the framework to run the request "in parallel" here. - // Mean a completetly independant copy of the Expereiment would be done and we would proceed on that. - // - dataBackgroundFullRequest = performRequest(experiment, fullExperimentCanvas, tmpRange, intervalTime, ExecutionType.LONG); - fullExperimentCanvas.redrawAsynchronously(); - } - - // *** VERIFY *** - // This function is synchronized, is it a good idea? - // Tis is done to make sure requests arrive somewhat in order, - // this is especially important when request are issued from different thread. - /** - * Create a new request from the given data and send it to the framework.

- * The request will be queued and processed later. - * - * @param experiment The experiment we will process the request on - * @param targetCanvas The canvas that will received the result - * @param newRange The range of the request - * @param newInterval The interval of time we use to store the result into the HistogramContent - */ - private synchronized HistogramRequest performRequest(TmfExperiment experiment, HistogramCanvas targetCanvas, TmfTimeRange newRange, long newInterval, ExecutionType execType) { - HistogramRequest returnedRequest = null; - - // *** FIXME *** - // EVIL BUG! - // We use int.MAX_VALUE because we want every events BUT we don't know the number inside the range. - // HOWEVER, this would cause the request to run forever (or until it reach the end of trace). - // Seeting an EndTime does not seems to stop the request - returnedRequest = new HistogramRequest(newRange, Integer.MAX_VALUE, targetCanvas, newInterval ); - - // Send the request to the framework : it will be queued and processed later - experiment.sendRequest(returnedRequest, execType); - - return returnedRequest; - } - - /** - * Function used to warn that the selection window changed.

- * This might be called because the window moved or because its size changed.

- * - * We will update the different control related to the selection window. - */ - public void windowChangedNotification() { - - if ( lastUsedExperiment != null ) { - // If a request is ongoing, try to stop it - if ( selectedWindowRequest != null && selectedWindowRequest.isCompleted() == false ) { - selectedWindowRequest.cancel(); - } - - // Get the latest window information - selectedWindowTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition(); - selectedWindowTimerange = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth(); - - // If the current event time is outside the new window, change the current event - // The new current event will be the one closest to the LEFT side of the new window - if ( isGivenTimestampInSelectedWindow(currentEventTime) == false ) { - currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition() ); - } - - // Perform a new request to read data about the new window - performSelectedWindowEventsRequest(lastUsedExperiment); - } - } - - /** - * Function used to tell that the current event changed.

- * This might be called because the user changed the current event or - * because the last current event is now outside the selection window.

- * - * We update the related control and send a signal to notify other views of the new current event. - * - * @param newCurrentEventTime - */ - public void currentEventChangeNotification(long newCurrentEventTime) { - - // Notify other views in the framework - if (currentEventTime != newCurrentEventTime) { - currentEventTime = newCurrentEventTime; - - // Update the UI control - updateSelectedEventTime(); - } - } - - public void sendTmfTimeSynchSignalBroadcast() { - -// System.out.println("sendTmfTimeSynchSignalBroadcast " + System.currentTimeMillis()); - - // Send a signal to the framework - LttngTimestamp tmpTimestamp = new LttngTimestamp(currentEventTime); - broadcast(new TmfTimeSynchSignal(this, tmpTimestamp)); - } - - /** - * Function used to tell that the timerange (window) changed.

- * This will most likely be called if the time window is resized. - * - * We send a signal to notify other views of the new timerange. - */ - public void sendTmfRangeSynchSignalBroadcast() { - -// System.out.println("sendTmfRangeSynchSignalBroadcast " + System.currentTimeMillis()); - - // *** TODO *** - // Not very elegant... we need to chance this below. - // - long centerTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition(); - long windowWidth = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth(); - - long startTime = centerTime-windowWidth; - if ( startTime < fullExperimentCanvas.getHistogramContent().getStartTime() ) { - startTime = fullExperimentCanvas.getHistogramContent().getStartTime(); - } - LttngTimestamp tmpStartTime = new LttngTimestamp(startTime); - - long endTime = centerTime+windowWidth; - if ( endTime > fullExperimentCanvas.getHistogramContent().getEndTime() ) { - endTime = fullExperimentCanvas.getHistogramContent().getEndTime(); - } - LttngTimestamp tmpEndTime = new LttngTimestamp(endTime); - - TmfTimeRange tmpTimeRange = new TmfTimeRange(tmpStartTime, tmpEndTime); - LttngTimestamp tmpEventTime = new LttngTimestamp(currentEventTime); - - // Send a signal to the framework - broadcast(new TmfRangeSynchSignal(this, tmpTimeRange, tmpEventTime)); - } - - /** - * Function that will be called when one of the time text group value is changed.

- * Since we don't (and can't unless we subclass them) know which one, we check them all. - */ - public void timeTextGroupChangeNotification() { - - // Get all the time text group value - long newCurrentTime = ntgCurrentEventTime.getValue(); - long newSelectedWindowTime = ntgCurrentWindowTime.getValue(); - long newSelectedWindowTimeRange = ntgTimeRangeWindow.getValue(); - - // If the user changed the current event time, call the notification - if ( newCurrentTime != currentEventTime ) { - currentEventChangeNotification( newCurrentTime ); - // Send a broadcast to the framework about the window change - sendTmfTimeSynchSignalBroadcast(); - } - - // If the user changed the selected window time, recenter the window and call the notification - if ( newSelectedWindowTime != selectedWindowTime ) { - selectedWindowTime = newSelectedWindowTime; - fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(selectedWindowTime) ); - windowChangedNotification(); - // Send a broadcast to the framework about the window change - sendTmfRangeSynchSignalBroadcast(); - } - - // If the user changed the selected window size, resize the window and call the notification - if ( newSelectedWindowTimeRange != selectedWindowTimerange ) { - selectedWindowTimerange = newSelectedWindowTimeRange; - fullExperimentCanvas.resizeWindowByAbsoluteTime(selectedWindowTimerange); - windowChangedNotification(); - // Send a broadcast to the framework about the window change - sendTmfRangeSynchSignalBroadcast(); - } - - } - - /** - * Getter for the last used experiment.

- * This might be different than the current experiment or even null. - * - * @return the last experiment we used in this view - */ - public TmfExperiment getLastUsedExperiment() { - return lastUsedExperiment; - } - - /** - * Check if a given timestamp is inside the selection window.

- * This assume fullExperimentCanvas contain a valid HistogramContent - * - * @param timestamp the timestamp to check - * - * @return if the time is inside the selection window or not - */ - public boolean isGivenTimestampInSelectedWindow(long timestamp) { - boolean returnedValue = true; - - // If the content is not set correctly, this will return weird (or even null) result - if ( (timestamp < fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition() ) || - (timestamp > fullExperimentCanvas.getCurrentWindow().getTimestampOfRightPosition() ) ) - { - returnedValue = false; - } - - return returnedValue; - } - - /** - * Reset the content of all Controls.

- * WARNING : Calls in there are not thread safe and can't be called from different thread than "main" - */ - public void resetControlsContent() { - - TmfExperiment tmpExperiment = getLastUsedExperiment(); - - // Use the previous Start and End time, or default if they are not available - String startTime = null; - String stopTime = null; - if ( tmpExperiment != null ) { - startTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getStartTime().getValue() ); - stopTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getEndTime().getValue() ); - } - else { - startTime = HistogramConstant.formatNanoSecondsTime( 0L ); - stopTime = HistogramConstant.formatNanoSecondsTime( 0L ); - } - - txtExperimentStartTime.setText( startTime ); - txtExperimentStopTime.setText( stopTime ); - txtExperimentStartTime.getParent().layout(); - - txtWindowMaxNbEvents.setText("" + 0); - txtWindowMinNbEvents.setText("" + 0); - txtWindowStartTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) ); - txtWindowStopTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) ); - txtWindowStartTime.getParent().layout(); - - ntgCurrentWindowTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) ); - ntgTimeRangeWindow.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) ); - - // Using "startTime" here can avoid an useless TmfTimeSynchSignal here - // However it look ugly to have only this time - ntgCurrentEventTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) ); - } - - /** - * Update the content of the controls related to the full experiment canvas

- * WARNING : Calls in there are not thread safe and can't be called from different thread than "main" - */ - public void updateFullExperimentInformation() { - - String startTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getStartTime() ); - String stopTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getEndTime() ); - - txtExperimentStartTime.setText( startTime ); - txtExperimentStopTime.setText( stopTime ); - - // Take one of the parent and call its layout to update control size - // Since both control have the same parent, only one call is needed - txtExperimentStartTime.getParent().layout(); - - // Update the selected window, just in case - // This should give a better user experience and it is low cost - updateSelectedWindowInformation(); - } - - /** - * Update the content of the controls related to the selection window canvas

- * WARNING : Calls in there are not thread safe and can't be called from different thread than "main" - */ - public void updateSelectedWindowInformation() { - // Update the timestamp as well - updateSelectedWindowTimestamp(); - - txtWindowMaxNbEvents.setText( Long.toString(selectedWindowCanvas.getHistogramContent().getHeighestEventCount()) ); - txtWindowMinNbEvents.setText(Long.toString(0)); - - // Refresh the layout - txtWindowMaxNbEvents.getParent().layout(); - } - - /** - * Update the content of the controls related to the timestamp of the selection window

- * WARNING : Calls in there are not thread safe and can't be called from different thread than "main" - */ - public void updateSelectedWindowTimestamp() { - String startTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getStartTime() ); - String stopTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getEndTime() ); - txtWindowStartTime.setText( startTime ); - txtWindowStopTime.setText( stopTime ); - - ntgCurrentWindowTime.setValue( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() ); - ntgTimeRangeWindow.setValue( fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth() ); - - // If the current event time is outside the selection window, recenter our window - if ( isGivenTimestampInSelectedWindow(ntgCurrentEventTime.getValue()) == false ) { - currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() ); - } - - // Take one control in each group to call to refresh the layout - // Since both control have the same parent, only one call is needed - txtWindowStartTime.getParent().layout(); - ntgCurrentWindowTime.getParent().layout(); - } - - /** - * Update the controls related current event.

- * The call here SHOULD be thread safe and can be call from any threads. - */ - public void updateSelectedEventTime() { - ntgCurrentEventTime.setValueAsynchronously(currentEventTime); - // Tell the selection canvas which event is currently selected - // This give a nice graphic output - selectedWindowCanvas.getHistogramContent().setSelectedEventTimeInWindow(currentEventTime); - selectedWindowCanvas.redrawAsynchronously(); - } - - /** - * Method called when the view is moved.

- * - * Just redraw everything... - * - * @param event The controle event generated by the move. - */ - public void controlMoved(ControlEvent event) { - parent.redraw(); - } - - /** - * Method called when the view is resized.

- * - * We will make sure that the size didn't change more than the content size.

- * Otherwise we need to perform a new request for the full experiment because we are missing data). - * - * @param event The control event generated by the resize. - */ - public void controlResized(ControlEvent event) { - - // Ouch! The screen enlarged (screen resolution changed?) so far that we miss content to fill the space. - if ( parent.getDisplay().getBounds().width > fullExperimentCanvas.getHistogramContent().getNbElement() ) { - if ( lastUsedExperiment != null ) { - createCanvasAndRequests(lastUsedExperiment); - } - } - } + } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectContentProvider.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectContentProvider.java new file mode 100644 index 0000000000..497ecc4091 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectContentProvider.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project; + +import java.util.Vector; + +import org.eclipse.core.internal.resources.WorkspaceRoot; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentFolder; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProject; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceFolder; + +/** + * LTTngProjectContentProvider + *

+ * TODO: Implement me. Please. + */ +@SuppressWarnings("restriction") +public class LTTngProjectContentProvider implements ITreeContentProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + public Object[] getChildren(Object parentElement) { + + // Children are limited to Traces and Experiments folders + if (parentElement instanceof LTTngProject) { + LTTngProject entry = (LTTngProject) parentElement; + Vector result = new Vector(); + + LTTngTraceFolder traces = entry.getTracesFolder(); + if (entry.getTracesFolder() != null) { + result.add(traces); + } + + LTTngExperimentFolder experiments = entry.getExperimentsFolder(); + if (entry.getExperimentsFolder() != null) { + result.add(experiments); + } + + return result.toArray(); + } + + // Return the list of available traces + if (parentElement instanceof LTTngTraceFolder) { + LTTngTraceFolder entry = (LTTngTraceFolder) parentElement; + return entry.getTraces(); + } + + // Return the list of experiments + if (parentElement instanceof LTTngExperimentFolder) { + LTTngExperimentFolder entry = (LTTngExperimentFolder) parentElement; + return entry.getExperiments(); + } + + // Return the list of traces in the experiment + if (parentElement instanceof LTTngExperimentEntry) { + LTTngExperimentEntry entry = (LTTngExperimentEntry) parentElement; + return entry.getTraces(); + } + + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ + public Object getParent(Object element) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + public boolean hasChildren(Object element) { + + // Children are limited to Traces and Experiments folders + if (element instanceof LTTngProject) { + LTTngProject entry = (LTTngProject) element; + if (entry.getTracesFolder() != null) + return true; + if (entry.getExperimentsFolder() != null) + return true; + } + + // Return the list of available traces + if (element instanceof LTTngTraceFolder) { + LTTngTraceFolder entry = (LTTngTraceFolder) element; + return entry.getTraces().length > 0; + } + + // Return the list of experiments + if (element instanceof LTTngExperimentFolder) { + LTTngExperimentFolder entry = (LTTngExperimentFolder) element; + return entry.getExperiments().length > 0; + } + + // Return the list of traces in the experiment + if (element instanceof LTTngExperimentEntry) { + LTTngExperimentEntry entry = (LTTngExperimentEntry) element; + return entry.getTraces().length > 0; + } + + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + + // Return the list of LTTng projects + if (inputElement instanceof WorkspaceRoot) { + IProject[] projects = ((WorkspaceRoot) inputElement).getProjects(); + Vector tmfProjects = new Vector(); + for (IProject project : projects) { + try { + if (project.isOpen() && project.hasNature(LTTngProjectNature.ID)) { + LTTngProject tmfProject = new LTTngProject(project); + tmfProjects.add(tmfProject); + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return tmfProjects.toArray(); + } + + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // TODO Auto-generated method stub + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectLabelProvider.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectLabelProvider.java new file mode 100644 index 0000000000..9701f49bc6 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectLabelProvider.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project; + +import java.net.URL; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentFolder; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProject; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceEntry; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceFolder; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +/** + * LTTngProjectLabelProvider + *

+ * TODO: Implement me. Please. + * TODO: Find proper icons for traces and experiments + */ +public class LTTngProjectLabelProvider implements ILabelProvider { + + private final String fTraceIconFile = "icons/garland16.png"; +// private final String fExperimentIconFile = "icons/garland16.png"; + + private final Image fProjectIcon; + private final Image fFolderIcon; + private final Image fTraceIcon; + private final Image fExperimentIcon; + + /** + * + */ + public LTTngProjectLabelProvider() { + + fProjectIcon = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT); + fFolderIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); + + fTraceIcon = loadIcon(fTraceIconFile); + fExperimentIcon = fFolderIcon; // loadIcon(fExperimentIconFile); + } + + private Image loadIcon(String url) { + LTTngUiPlugin plugin = LTTngUiPlugin.getDefault(); + Image icon = plugin.getImageRegistry().get(url); + if (icon == null) { + URL imageURL = plugin.getBundle().getEntry(url); + ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL); + icon = descriptor.createImage(); + plugin.getImageRegistry().put(url, icon); + } + return icon; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + + if (element instanceof LTTngProject) { + return fProjectIcon; + } + + if (element instanceof LTTngTraceFolder) { + return fFolderIcon; + } + + if (element instanceof LTTngTraceEntry) { + return fTraceIcon; + } + + if (element instanceof LTTngExperimentFolder) { + return fFolderIcon; + } + + if (element instanceof LTTngExperimentEntry) { + return fExperimentIcon; + } + + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + + if (element instanceof LTTngProject) { + LTTngProject entry = (LTTngProject) element; + return entry.getName(); + } + + if (element instanceof LTTngTraceFolder) { + LTTngTraceFolder entry = (LTTngTraceFolder) element; + return entry.getName(); + } + + if (element instanceof LTTngTraceEntry) { + LTTngTraceEntry entry = (LTTngTraceEntry) element; + return entry.getName(); + } + + if (element instanceof LTTngExperimentFolder) { + LTTngExperimentFolder entry = (LTTngExperimentFolder) element; + return entry.getName(); + } + + if (element instanceof LTTngExperimentEntry) { + LTTngExperimentEntry entry = (LTTngExperimentEntry) element; + return entry.getName(); + } + + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ + public void addListener(ILabelProviderListener listener) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) + */ + public boolean isLabelProperty(Object element, String property) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ + public void removeListener(ILabelProviderListener listener) { + // TODO Auto-generated method stub + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java index 64894c7473..e7ff2f8153 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -19,23 +19,17 @@ import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.linuxtools.lttng.event.LttngEvent; -import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.trace.LTTngTrace; -import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectContentProvider; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectLabelProvider; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectRoot; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceEntry; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.trace.TmfExperiment; +import org.eclipse.linuxtools.tmf.trace.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.ui.views.TmfView; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; @@ -48,167 +42,171 @@ import org.eclipse.swt.widgets.Tree; * ProjectView *

* The ProjectView keeps track of the LTTng projects in the workspace. + * + * TODO: Implement me. Please. + * TODO: Put all actions in a context menu + * TODO: Identify LTTng traces vs. experiments and hook doubleClick properly + * TODO: Handle multiple traces */ public class ProjectView extends TmfView { public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.project"; - // ------------------------------------------------------------------------ - // Main data structures - // ------------------------------------------------------------------------ - + private final IWorkspace fWorkspace; + private final IResourceChangeListener fResourceChangeListener; private TreeViewer fViewer; - private LTTngProjectRoot fProjectRoot; - private TmfExperiment fSelectedExperiment = null; - - private IWorkspace fWorkspace; - private IResourceChangeListener fResourceChangeListener; - - // ------------------------------------------------------------------------ - // View refresher - // ------------------------------------------------------------------------ + private TmfExperiment fExperiment = null; +// private Object fSelection = null; - // Perform updates on the UI thread + // To perform updates on the UI thread private Runnable fViewRefresher = new Runnable() { public void run() { - if (fViewer != null) { - Object[] elements = fViewer.getExpandedElements(); + if (fViewer != null) fViewer.refresh(); - fViewer.setExpandedElements(elements); - } } }; - public LTTngProjectRoot getRoot() { - return fProjectRoot; - } - - // ------------------------------------------------------------------------ - // Constructor - // ------------------------------------------------------------------------ + // ======================================================================== + // Constructor/Destructor + // ======================================================================== + /** + * This view needs to react to workspace resource changes + */ public ProjectView() { - - super("ProjectView"); - fProjectRoot = new LTTngProjectRoot(this); + +// TmfTraceContext.init(); fWorkspace = ResourcesPlugin.getWorkspace(); - fResourceChangeListener = new IResourceChangeListener() { + fResourceChangeListener = new IResourceChangeListener() { public void resourceChanged(IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.POST_CHANGE) { - fProjectRoot.refreshChildren(); - refresh(); + Tree tree = fViewer.getTree(); + if (tree != null && !tree.isDisposed()) + tree.getDisplay().asyncExec(fViewRefresher); } } }; fWorkspace.addResourceChangeListener(fResourceChangeListener); } - public void refresh() { - Tree tree = fViewer.getTree(); - if (tree != null && !tree.isDisposed()) - tree.getDisplay().asyncExec(fViewRefresher); - } - - public void setSelection(ILTTngProjectTreeNode node) { - fViewer.setSelection(new StructuredSelection(node), true); - } - + /** + * + */ @Override public void dispose() { - fWorkspace.removeResourceChangeListener(fResourceChangeListener); + fWorkspace.removeResourceChangeListener(fResourceChangeListener); } + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ @Override public void createPartControl(Composite parent) { fViewer = new TreeViewer(parent, SWT.SINGLE); - fViewer.setContentProvider(new LTTngProjectContentProvider()); - fViewer.setSorter(new ViewerSorter()); fViewer.setLabelProvider(new LTTngProjectLabelProvider()); - fViewer.setInput(fProjectRoot); + fViewer.setContentProvider(new LTTngProjectContentProvider()); + fViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); - getSite().setSelectionProvider(fViewer); hookMouse(); - + hookDragAndDrop(); createContextMenu(); } - // ------------------------------------------------------------------------ - // ViewPart - // ------------------------------------------------------------------------ - - @Override - public String toString() { - return "[ProjectView]"; - } - - // ------------------------------------------------------------------------ - // hookMouse - // ------------------------------------------------------------------------ - + /** + * + */ private void hookMouse() { fViewer.getTree().addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent event) { TreeSelection selection = (TreeSelection) fViewer.getSelection(); Object element = selection.getFirstElement(); - if (element instanceof LTTngExperimentNode) { - LTTngExperimentNode experiment = (LTTngExperimentNode) element; + if (element instanceof LTTngExperimentEntry) { + LTTngExperimentEntry experiment = (LTTngExperimentEntry) element; selectExperiment(experiment); } } }); } + private void hookDragAndDrop() { + new TraceDragSource(fViewer); + new TraceDropTarget(fViewer); + } + + /** + * @param experiment + * + * TODO: Tie the proper parser to the trace + */ + // FIXME: Troubleshooting hack - start private boolean waitForCompletion = true; + // FIXME: Troubleshooting hack - end - /** - * @param experiment - */ - public void selectExperiment(LTTngExperimentNode experiment) { + private void selectExperiment(LTTngExperimentEntry experiment) { String expId = experiment.getName(); - if (fSelectedExperiment != null) { - System.out.println(fSelectedExperiment.getName() + ": nbEvents=" + fSelectedExperiment.getNbEvents() + - ", nbReads=" + ((LTTngTrace) fSelectedExperiment.getTraces()[0]).nbEventsRead); - fSelectedExperiment.dispose(); - } + if (fExperiment != null) + fExperiment.dispose(); try { - LTTngTraceNode[] traceEntries = experiment.getTraces(); + LTTngTraceEntry[] traceEntries = experiment.getTraces(); int nbTraces = traceEntries.length; ITmfTrace[] traces = new ITmfTrace[nbTraces]; for (int i = 0; i < nbTraces; i++) { - IResource res = traceEntries[i].getFolder(); + IResource res = traceEntries[i].getResource(); String location = res.getLocation().toOSString(); ITmfTrace trace = new LTTngTrace(location, waitForCompletion); traces[i] = trace; } - fSelectedExperiment = new TmfExperiment(LttngEvent.class, expId, traces); - - // Make sure the lttng-core, experiment selection context is ready - // for an event request from any view - StateManagerFactory.getExperimentManager().experimentSelected_prep( - (TmfExperiment) fSelectedExperiment); - - broadcast(new TmfExperimentSelectedSignal(this, fSelectedExperiment)); + fExperiment = new TmfExperiment(expId, traces, waitForCompletion); + broadcastSignal(new TmfExperimentSelectedSignal(this, fExperiment)); } catch (FileNotFoundException e) { + // TODO: Why not tell the user? He would appreciate... +// e.printStackTrace(); return; } catch (Exception e) { e.printStackTrace(); } } - // ------------------------------------------------------------------------ - // createContextMenu - // ------------------------------------------------------------------------ - - // Populated from the plug-in + /** + * + */ private void createContextMenu() { MenuManager menuManager = new MenuManager("#PopupMenu"); menuManager.setRemoveAllWhenShown(true); + menuManager.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + ProjectView.this.fillContextMenu(manager); + } + }); + Menu menu = menuManager.createContextMenu(fViewer.getControl()); fViewer.getControl().setMenu(menu); getSite().registerContextMenu(menuManager, fViewer); } - -} \ No newline at end of file + + /** + * @param manager + */ + private void fillContextMenu(IMenuManager manager) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "[ProjectView]"; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDragSource.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDragSource.java new file mode 100644 index 0000000000..6ebbab2a23 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDragSource.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DragSource; +import org.eclipse.swt.dnd.DragSourceEvent; +import org.eclipse.swt.dnd.DragSourceListener; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.ui.part.ResourceTransfer; + +/** + * TraceDragSource + *

+ * TODO: Implement me. Please. + */ +public class TraceDragSource implements DragSourceListener { + + private final TreeViewer fViewer; + + /** + * @param viewer + */ + public TraceDragSource(TreeViewer viewer) { + fViewer = viewer; + DragSource source = new DragSource(fViewer.getControl(), DND.DROP_COPY); + source.setTransfer(new Transfer[] { + ResourceTransfer.getInstance() + }); + source.addDragListener(this); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished(org.eclipse.swt.dnd.DragSourceEvent) + */ + public void dragFinished(DragSourceEvent event) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) + */ + public void dragSetData(DragSourceEvent event) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent) + */ + public void dragStart(DragSourceEvent event) { + // TODO Auto-generated method stub + event.doit = false; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDropTarget.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDropTarget.java new file mode 100644 index 0000000000..198016a342 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/TraceDropTarget.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.dnd.DropTargetAdapter; + +/** + * TraceDropTarget + *

+ * TODO: Implement me. Please. + */ +public class TraceDropTarget extends DropTargetAdapter { + + @SuppressWarnings("unused") + private final TreeViewer fViewer; + + /** + * @param viewer + */ + public TraceDropTarget(TreeViewer viewer) { + fViewer = viewer; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/AddTraceActionDelegate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/AddTraceActionDelegate.java new file mode 100644 index 0000000000..05ffe6b326 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/AddTraceActionDelegate.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.AddTraceWizard; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProject; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * AddTraceActionDelegate + *

+ * TODO: Implement me. Please. + */ +public class AddTraceActionDelegate implements IWorkbenchWindowActionDelegate { + + public static final String ID = "org.eclipse.linuxtools.lttng.ui.view.project.menu.addTrace"; + + @SuppressWarnings("unused") + private IWorkbenchWindow fWindow; + private IStructuredSelection fSelection; + private LTTngExperimentEntry fEntry; + private LTTngProject fProject; + + /** + * + */ + public AddTraceActionDelegate() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + fWindow = window; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + // Open the trace addition wizard + IWorkbench workbench = PlatformUI.getWorkbench(); + Shell shell = workbench.getActiveWorkbenchWindow().getShell(); + + AddTraceWizard wizard = new AddTraceWizard(fProject); + wizard.init(PlatformUI.getWorkbench(), fSelection); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + fSelection = (IStructuredSelection) selection; + Object sel = fSelection.getFirstElement(); + if (sel instanceof LTTngExperimentEntry) { + fEntry = (LTTngExperimentEntry) sel; + fProject = fEntry.getProject(); + } + } + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteExperimentActionDelegate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteExperimentActionDelegate.java new file mode 100644 index 0000000000..46a84c8226 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteExperimentActionDelegate.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * DeleteExperimentActionDelegate + *

+ * TODO: Implement me. Please. + */ +public class DeleteExperimentActionDelegate implements IWorkbenchWindowActionDelegate { + + public static final String ID = "org.eclipse.linuxtools.lttng.ui.view.project.menu.deleteExperiment"; + + @SuppressWarnings("unused") + private IWorkbenchWindow fWindow; + private IStructuredSelection fSelection; + @SuppressWarnings("unused") + private LTTngExperimentEntry fEntry; + + /** + * + */ + public DeleteExperimentActionDelegate() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + fWindow = window; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + IWorkbench workbench = PlatformUI.getWorkbench(); + Shell shell = workbench.getActiveWorkbenchWindow().getShell(); + MessageDialog dialog = new MessageDialog(shell, "Delete Experiment", null, + "Sorry, this feature is not implemented yet.\n\n" + + "In the mean time, you can use the standard Eclipse Navigator View.", + MessageDialog.INFORMATION, new String[] { "OK" }, 0); + dialog.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + fSelection = (IStructuredSelection) selection; + fEntry = null; + Object sel = fSelection.getFirstElement(); + if (sel instanceof LTTngExperimentEntry) { + fEntry = (LTTngExperimentEntry) sel; + } + } + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteProjectActionDelegate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteProjectActionDelegate.java new file mode 100644 index 0000000000..44ded66392 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteProjectActionDelegate.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * DeleteProjectActionDelegate + *

+ * TODO: Implement me. Please. + */ +public class DeleteProjectActionDelegate implements IWorkbenchWindowActionDelegate { + + public static final String ID = "org.eclipse.linuxtools.lttng.ui.view.project.menu.deleteProject"; + + /** + * + */ + public DeleteProjectActionDelegate() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + // Open the project creation wizard + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + String title = "Delete Project"; + String message = "Are you sure you want to delete TBD"; + String ok = "OK"; + String cancel = " No, thanks."; + MessageDialog dialog = new MessageDialog(shell, title, null, message, + MessageDialog.QUESTION, new String[] { ok, cancel }, 1); + int rc = dialog.open(); + if (rc == 0) { + System.out.println("Delete project"); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + // TODO Auto-generated method stub + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteTraceActionDelegate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteTraceActionDelegate.java new file mode 100644 index 0000000000..192a91cb54 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/DeleteTraceActionDelegate.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceEntry; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * DeleteTraceActionDelegate + *

+ * TODO: Implement me. Please. + */ +public class DeleteTraceActionDelegate implements IWorkbenchWindowActionDelegate { + + public static final String ID = "org.eclipse.linuxtools.lttng.ui.view.project.menu.deleteTrace"; + + @SuppressWarnings("unused") + private IWorkbenchWindow fWindow; + private IStructuredSelection fSelection; + @SuppressWarnings("unused") + private LTTngTraceEntry fEntry; + + /** + * + */ + public DeleteTraceActionDelegate() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + fWindow = window; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + IWorkbench workbench = PlatformUI.getWorkbench(); + Shell shell = workbench.getActiveWorkbenchWindow().getShell(); + MessageDialog dialog = new MessageDialog(shell, "Delete Trace", null, + "Sorry, this feature is not implemented yet.\n\n" + + "In the mean time, you can use the standard Eclipse Navigator View.", + MessageDialog.INFORMATION, new String[] { "OK" }, 0); + dialog.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + fSelection = (IStructuredSelection) selection; + fEntry = null; + Object sel = fSelection.getFirstElement(); + if (sel instanceof LTTngTraceEntry) { + fEntry = (LTTngTraceEntry) sel; + } + } + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/ImportTraceActionDelegate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/ImportTraceActionDelegate.java new file mode 100644 index 0000000000..5c752ea3b2 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/ImportTraceActionDelegate.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.ImportTraceWizard; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * ImportTraceActionDelegate + *

+ * TODO: Implement me. Please. + */ +public class ImportTraceActionDelegate implements IWorkbenchWindowActionDelegate { + + public static final String ID = "org.eclipse.linuxtools.lttng.ui.view.project.menu.newProject"; + + @SuppressWarnings("unused") + private IWorkbenchWindow fWindow; + private IStructuredSelection fSelection; + + /** + * + */ + public ImportTraceActionDelegate() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + fWindow = window; + } + + /** + * + */ + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + // Open the project creation wizard + IWorkbench workbench = PlatformUI.getWorkbench(); + Shell shell = workbench.getActiveWorkbenchWindow().getShell(); + + ImportTraceWizard wizard = new ImportTraceWizard(); + wizard.init(PlatformUI.getWorkbench(), fSelection); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) + fSelection = (IStructuredSelection) selection; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewExperimentActionDelegate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewExperimentActionDelegate.java new file mode 100644 index 0000000000..832098ad66 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewExperimentActionDelegate.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.NewExperimentDialog; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentFolder; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * NewExperimentActionDelegate + *

+ * TODO: Implement me. Please. + */ +public class NewExperimentActionDelegate implements IWorkbenchWindowActionDelegate { + + private LTTngExperimentFolder fFolder; + + /** + * + */ + public NewExperimentActionDelegate() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + // Open the experiment creation dialog + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + NewExperimentDialog dialog = new NewExperimentDialog(shell, fFolder.getFolder()); + dialog.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof StructuredSelection) { + StructuredSelection sel = (StructuredSelection) selection; + Object first = sel.getFirstElement(); + if (first instanceof LTTngExperimentFolder) + fFolder = (LTTngExperimentFolder) sel.getFirstElement(); + } + + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewProjectActionDelegate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewProjectActionDelegate.java new file mode 100644 index 0000000000..7e07d6dd63 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/actions/NewProjectActionDelegate.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.NewProjectWizard; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * NewProjectActionDelegate + *

+ * TODO: Implement me. Please. + */ +public class NewProjectActionDelegate implements IWorkbenchWindowActionDelegate { + + public static final String ID = "org.eclipse.linuxtools.lttng.ui.view.project.menu.newProject"; + + /** + * + */ + public NewProjectActionDelegate() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + // Open the project creation wizard + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + NewProjectWizard wizard = new NewProjectWizard(); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + // TODO Auto-generated method stub + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizard.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizard.java index eac20e8704..e7c69b6c52 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizard.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -20,9 +20,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProject; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceEntry; import org.eclipse.ui.IImportWizard; import org.eclipse.ui.IWorkbench; @@ -33,22 +33,25 @@ import org.eclipse.ui.IWorkbench; */ public class AddTraceWizard extends Wizard implements IImportWizard { - private LTTngProjectNode fProject; - private LTTngExperimentNode fExperiment; + @SuppressWarnings("unused") + private IWorkbench fWorkbench; + private LTTngProject fProject; + private IStructuredSelection fSelection; private AddTraceWizardPage fMainPage; /** * @param project */ - public AddTraceWizard(LTTngProjectNode project, LTTngExperimentNode experiment) { + public AddTraceWizard(LTTngProject project) { fProject = project; - fExperiment = experiment; } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ public void init(IWorkbench workbench, IStructuredSelection selection) { + fWorkbench = workbench; + fSelection = selection; setWindowTitle("Adding traces to experiment"); } @@ -60,6 +63,7 @@ public class AddTraceWizard extends Wizard implements IImportWizard { super.addPages(); fMainPage = new AddTraceWizardPage(fProject, "Some string"); addPage(fMainPage); + fMainPage.init(fSelection); } /* (non-Javadoc) @@ -68,27 +72,37 @@ public class AddTraceWizard extends Wizard implements IImportWizard { @Override public boolean performFinish() { + Object selection = fSelection.getFirstElement(); + if (!(selection instanceof LTTngExperimentEntry)) { + return true; + } + IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IFolder experimentFolder = fExperiment.getFolder(); - LTTngTraceNode[] traces = fMainPage.getSelection(); - for (LTTngTraceNode trace : traces) { + LTTngExperimentEntry experiment = (LTTngExperimentEntry) selection; + IFolder experimentFolder = experiment.getFolder(); + + LTTngTraceEntry[] traces = fMainPage.getSelection(); + for (LTTngTraceEntry trace : traces) { try { IFolder folder = experimentFolder.getFolder(trace.getName()); - IPath location = trace.getFolder().getLocation(); + IPath location = trace.getResource().getLocation(); if (workspace.validateLinkLocation(folder, location).isOK()) { folder.createLink(location, IResource.REPLACE, null); - fExperiment.addTrace(folder); + experiment.addTrace(trace); } else { System.out.println("Problem"); } } catch (CoreException e) { + // TODO Auto-generated catch block e.printStackTrace(); } } return true; - } + } + + } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizardPage.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizardPage.java index ded48a0279..e7f6f5e65a 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizardPage.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/AddTraceWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -15,9 +15,11 @@ package org.eclipse.linuxtools.lttng.ui.views.project.dialogs; import java.util.Vector; import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceNode; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProject; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceEntry; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; @@ -33,10 +35,12 @@ import org.eclipse.swt.widgets.TableColumn; */ public class AddTraceWizardPage extends WizardPage { - private LTTngProjectNode fProject; + private LTTngProject fProject; + @SuppressWarnings("unused") + private LTTngExperimentEntry fExperiment; private CheckboxTableViewer fCheckboxTableViewer; - protected AddTraceWizardPage(LTTngProjectNode project, String pageName) { + protected AddTraceWizardPage(LTTngProject project, String pageName) { super(pageName); setTitle("Select traces"); setDescription("Select the traces to add to the experiment"); @@ -49,8 +53,8 @@ public class AddTraceWizardPage extends WizardPage { setControl(container); fCheckboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER); - fCheckboxTableViewer.setContentProvider(new DialogTraceContentProvider()); - fCheckboxTableViewer.setLabelProvider(new DialogTraceLabelProvider()); + fCheckboxTableViewer.setContentProvider(new LTTngTraceContentProvider()); + fCheckboxTableViewer.setLabelProvider(new LTTngTraceLabelProvider()); final Table table = fCheckboxTableViewer.getTable(); final FormData formData = new FormData(); @@ -68,14 +72,21 @@ public class AddTraceWizardPage extends WizardPage { fCheckboxTableViewer.setInput(fProject.getTracesFolder()); } - public LTTngTraceNode[] getSelection() { - Vector traces = new Vector(); + public void init(IStructuredSelection selection) { + Object sel = selection.getFirstElement(); + if (sel instanceof LTTngExperimentEntry) { + fExperiment = (LTTngExperimentEntry) sel; + } + } + + public LTTngTraceEntry[] getSelection() { + Vector traces = new Vector(); Object[] selection = fCheckboxTableViewer.getCheckedElements(); for (Object sel : selection) { - if (sel instanceof LTTngTraceNode) - traces.add((LTTngTraceNode) sel); + if (sel instanceof LTTngTraceEntry) + traces.add((LTTngTraceEntry) sel); } - LTTngTraceNode[] result = new LTTngTraceNode[traces.size()]; + LTTngTraceEntry[] result = new LTTngTraceEntry[traces.size()]; traces.toArray(result); return result; } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizard.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizard.java index 77dd476c0a..2126212587 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizard.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizard.java @@ -38,7 +38,7 @@ public class ImportTraceWizard extends Wizard implements IImportWizard { private IStructuredSelection fSelection; private ImportTraceWizardPage fMainPage; - /** + /** * */ public ImportTraceWizard() { @@ -47,7 +47,6 @@ public class ImportTraceWizard extends Wizard implements IImportWizard { if (section == null) { section = workbenchSettings.addNewSection("LTTngTraceImportWizard"); } - setDialogSettings(section); } @@ -64,7 +63,7 @@ public class ImportTraceWizard extends Wizard implements IImportWizard { /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ - @SuppressWarnings("rawtypes") + @SuppressWarnings("unchecked") public void init(IWorkbench workbench, IStructuredSelection selection) { fWorkbench = workbench; fSelection = selection; @@ -73,45 +72,18 @@ public class ImportTraceWizard extends Wizard implements IImportWizard { if (!selectedResources.isEmpty()) { fSelection = new StructuredSelection(selectedResources); } - + setWindowTitle(DataTransferMessages.DataTransfer_importTitle); setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png")); setNeedsProgressMonitor(true); } - - public ImportTraceWizardPage getMainPage() { - return fMainPage; - } - - /** - * performFinish is called after the "finish" button is pressed in the import wizard - * If we return "false", the wizard will not close. - * - * We perform here version check on the imported LTTng trace - * - */ + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ @Override public boolean performFinish() { - - if ( fMainPage.getDestination().equals( fMainPage.getInitialContainerString() ) ) { - - String errMessage[] = { "Error : import destination is wrong." }; - errMessage = fMainPage.extendErrorMessage(errMessage, ""); - errMessage = fMainPage.extendErrorMessage(errMessage, "You cannot import your trace directly into the \"" + fMainPage.getInitialContainerString() + "\""); - errMessage = fMainPage.extendErrorMessage(errMessage, "The trace has to be into a subdirectly, like \"" + fMainPage.getInitialContainerString() + "/MyTrace\"" ); - errMessage = fMainPage.extendErrorMessage(errMessage, ""); - errMessage = fMainPage.extendErrorMessage(errMessage, "Please change the destination folder."); - fMainPage.showVersionErrorPopup(errMessage); - - return false; - } - - return fMainPage.finish(); - } - - @Override - public boolean canFinish() { - return fMainPage.isSelectedElementsValidLttngTraces(); + return fMainPage.finish(); } } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizardPage.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizardPage.java index 5c8e041633..a5f1a596aa 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizardPage.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/ImportTraceWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -13,10 +13,7 @@ package org.eclipse.linuxtools.lttng.ui.views.project.dialogs; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.linuxtools.lttng.LttngException; -import org.eclipse.linuxtools.lttng.trace.LTTngTraceVersion; -import org.eclipse.linuxtools.lttng.ui.views.project.handlers.TraceErrorHandler; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceFolder; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImportPage1; @@ -27,316 +24,11 @@ import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImpo */ @SuppressWarnings("restriction") public class ImportTraceWizardPage extends WizardFileSystemResourceImportPage1 { - - private boolean isContainerSet = false; - private String initialContainerString = ""; - private String selectedSourceDirectory = ""; - + public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) { super(workbench, selection); - - LTTngProjectNode folder = (LTTngProjectNode) selection.getFirstElement(); - String path = folder.getTracesFolder().getFolder().getFullPath().toOSString(); - - initialContainerString = path; + LTTngTraceFolder folder = (LTTngTraceFolder) selection.getFirstElement(); + String path = folder.getFolder().getFullPath().toOSString(); setContainerFieldValue(path); } - - - public String getTraceDirectory() { - String tmpPath = ""; - if ( (getSourceDirectory() != null) && (getSourceDirectory().getName() != null) ) { - tmpPath = this.getSourceDirectory().getName().toString(); - } - - return tmpPath; - } - - public String getInitialContainerString() { - return initialContainerString; - } - - public String getTracepath() { - String tmpPath = ""; - if ( (getSourceDirectory() != null) && (getSourceDirectory().getPath() != null) ) { - tmpPath = this.getSourceDirectory().getPath().toString(); - } - - return tmpPath; - } - - public String getDestination() { - String returnPath = null; - - if ( getContainerFullPath() != null ) { - returnPath = getContainerFullPath().toString(); - } - return returnPath; - } - - public boolean isSelectedElementsValidLttngTraces() { - boolean returnedValue = true; - - // We don't want to test until something is selected - if ( selectionGroup.getCheckedElementCount() > 0 ) { - - // We don't want to revalidate each time, only want a new directory is selected - if ( ! selectedSourceDirectory.equals(getSourceDirectory().getAbsolutePath().toString()) ) - { - try { - if ( isPathLttngTrace( getSourceDirectory().getAbsolutePath() ) == false ) { - returnedValue = false; - selectedSourceDirectory = ""; - - String errMessage[] = { "Couldn't get LTTng version number for the path : " }; - errMessage = extendErrorMessage(errMessage, getSourceDirectory().getAbsolutePath() ); - errMessage = extendErrorMessage(errMessage, ""); - errMessage = extendErrorMessage(errMessage, "Verify that the directory is a valid LTTng trace directory."); - errMessage = extendErrorMessage(errMessage, "Make sure the top directory is the trace itself and not any of its parent."); - showVersionErrorPopup(errMessage); - selectionGroup.setAllSelections(false); - } - else { - selectedSourceDirectory = getSourceDirectory().getAbsolutePath(); - - if ( isContainerSet == false ) { - isContainerSet = true; - - if ( ! getDestination().toString().equals( getInitialContainerString() + "/" + getTraceDirectory() ) ) { - // *** HACK *** - // Force a sane destination to avoid imported files to end up in the root of the "Traces/" directory - setContainerFieldValue(getInitialContainerString() + "/" + getTraceDirectory()); - } - } - } - } - catch (LttngException e) { - String[] errorMessages = e.toString().split("\n"); - String exceptionMessage[] = { "Version check failed for the path : ", this.getTracepath(), "", "Returned error was :" }; - - for ( int pos=0; pos 0) { -// // Call import ressources (code is below) -// return importResources(listRealFiles); -// } -// -// MessageDialog.openInformation(getContainer().getShell(), -// DataTransferMessages.DataTransfer_information, -// DataTransferMessages.FileImport_noneSelected); -// return false; -// } -// -// @Override -// protected boolean importResources(List fileSystemObjects) { -// // *** Explanation of the hackssss -// // We want the import wizard to import everything in the form of : -// // trace1/ -> tracefiles* -// // -// // However, the wizard is too dumb to do the following and will recreate the full architecture the user selected. -// // So, depending what the user select, we could end up with something like : -// // home/user/somewhere/trace1/ -> tracefiles* -// // -// // Since there is nothing to do with that, we need to change the "source" and the "to-import files" to reflect this. -// // Basically, from the case above, the "source" should be changed to "trace1/" and "to-import files" -// // should have the correct parent so the wizard can still find them -// // -// // Let's see how fun it is to do with mr. import wizard. -// -// -// List listRealFilesShortPath = new ArrayList(); -// java.io.File newFullSource = getSourceDirectory(); -// -// // We will loop for every "to-import full path files" we have and recreate "short path" files -// // Mean, the current path of the file is currently something like : -// // Path : /home/billybob/mytraces/trace1/metadata_0 Parent : null -// // And we want something less dumb like : -// // Path : metadata_0 Parent : /home/billybob/mytraces/trace1/ -// for (int pos=0; pos /home/billybob/mytraces/trace1/ -// String newParent = oldFile.getAbsolutePath().substring(0, oldFile.getAbsolutePath().lastIndexOf("/") ); -// -// // Create a "short path file" with the good parent from it. This give : -// // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/ -// newShortPathFile = new java.io.File(newParent, oldFile.getName() ); -// -// // Create a new "full source" directory -> /home/billybob/mytraces/trace1/ -// newFullSource = new java.io.File( newParent ); -// -// // Add our pretty file to the new List -// listRealFilesShortPath.add(newShortPathFile); -// } -// -// // *** -// // HACK #3 -// // Now that we have everything, we need to AJUST THE DESTINATION -// // To do so, we ajust the "ContainerValue" text field. -// // -// // Right now we have something like : -// // Path -> /where/to/import/ -// // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/ -// // We want something like : -// // Path -> /where/to/import/trace1/ -// // (Files) Path : metadata_0 Parent : /home/billybob/mytraces/trace1/ -// // -// -// // We take the current text field and we add the "full source" name -// // Note : the "name" is the last directory name so "trace1" is returned for a path like "/home/billybob/mytraces/trace1/" -// setContainerFieldValue(getContainerFullPath() + "/" + newFullSource.getName()); -// -// /* -// System.out.println("\n\n" + getContainerFullPath()); -// System.out.println(newFullSource); -// System.out.println(FileSystemStructureProvider.INSTANCE); -// System.out.println(this.getContainer()); -// System.out.println(fileSystemObjects); -// */ -// -// // Finally import !! -// ImportOperation operation = new ImportOperation(getContainerFullPath(), newFullSource, FileSystemStructureProvider.INSTANCE, this, listRealFilesShortPath); -// -// operation.setContext(getShell()); -// return executeImportOperation(operation); -// } -// -// // This function test if the selected directory are LTTng traces -// // This one is made to work with the madness above. -// public boolean isSelectedElementsValidLttngTraces() { -// boolean returnedValue = true; -// -// String errMessage[] = { "Couldn't get LTTng version number for the path : " }; -// -// // We don't want to test until something is selected -// if ( selectionGroup.getCheckedElementCount() > 0 ) { -// try { -// List selectionList = selectionGroup.getAllWhiteCheckedItems(); -// MinimizedFileSystemElement tmpSelectedElement = null; -// -// for ( int x=0; xLTTngTracesContentProvider + *

+ * TODO: Implement me. Please. + */ +public class LTTngTraceContentProvider implements IStructuredContentProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + if (inputElement instanceof LTTngTraceFolder) { + LTTngTraceFolder folder = (LTTngTraceFolder) inputElement; + return folder.getTraces(); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // TODO Auto-generated method stub + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/LTTngTraceLabelProvider.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/LTTngTraceLabelProvider.java new file mode 100644 index 0000000000..3015daf86d --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/LTTngTraceLabelProvider.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.dialogs; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceEntry; +import org.eclipse.swt.graphics.Image; + +/** + * LTTngTracesLabelProvider + *

+ * TODO: Implement me. Please. + */ +public class LTTngTraceLabelProvider extends LabelProvider implements ITableLabelProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) + */ + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) + */ + public String getColumnText(Object element, int columnIndex) { + if (element instanceof LTTngTraceEntry) { + LTTngTraceEntry entry = (LTTngTraceEntry) element; + switch (columnIndex) { + case 0: + return entry.getName(); + default: + return null; + } + } + return null; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewExperimentDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewExperimentDialog.java index 1cb3929dbb..8bfee691f2 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewExperimentDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewExperimentDialog.java @@ -30,7 +30,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentFolderNode; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; @@ -69,9 +68,9 @@ public class NewExperimentDialog extends SelectionStatusDialog { * @param parentShell parent of the new dialog * @param container parent of the new folder */ - public NewExperimentDialog(Shell parentShell, LTTngExperimentFolderNode experimentFolder) { + public NewExperimentDialog(Shell parentShell, IContainer container) { super(parentShell); - this.container = experimentFolder.getFolder(); + this.container = container; setTitle("LTTng Experiment"); setStatusLineAboveButtons(true); } @@ -113,11 +112,6 @@ public class NewExperimentDialog extends SelectionStatusDialog { public String getValue() { return folderNameField.getText(); } - - public IResource getResource() { - // TODO Auto-generated method stub - return null; - } }); } @@ -332,4 +326,4 @@ public class NewExperimentDialog extends SelectionStatusDialog { super.okPressed(); } -} \ No newline at end of file +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectWizard.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectWizard.java index e0bd8a303c..167bfa2543 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectWizard.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectWizard.java @@ -26,12 +26,12 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin; import org.eclipse.linuxtools.lttng.ui.views.project.LTTngProjectNature; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; /** * NewProjectWizard *

+ * * TODO: Implement me. Please. */ public class NewProjectWizard extends BasicNewResourceWizard { @@ -97,10 +97,6 @@ public class NewProjectWizard extends BasicNewResourceWizard { return true; } - public IProject getProject() { - return fProject; - } - /** * @param projectName * @param projectLocation @@ -128,11 +124,11 @@ public class NewProjectWizard extends BasicNewResourceWizard { description.setNatureIds(new String[] { LTTngProjectNature.ID } ); project.setDescription(description, null); - IFolder folder = project.getFolder(LTTngProjectNode.TRACE_FOLDER_NAME); + IFolder folder = project.getFolder("Traces"); if (!folder.exists()) folder.create(true, true, null); - folder = project.getFolder(LTTngProjectNode.EXPER_FOLDER_NAME); + folder = project.getFolder("Experiments"); if (!folder.exists()) folder.create(true, true, null); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentEntry.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentEntry.java new file mode 100644 index 0000000000..190a5703c8 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentEntry.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.model; + +import java.util.Vector; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * LTTngExperimentEntry + *

+ * TODO: Implement me. Please. + */ +public class LTTngExperimentEntry { + + private final IFolder fResource; + private final LTTngProject fProject; + private Vector traces = new Vector(); + + /** + * @param name + */ + public LTTngExperimentEntry(LTTngProject project, IFolder resource) { + fResource = resource; + fProject = project; + try { + IResource[] resources = resource.members(); + int nbTraces = resources.length; + for (int i = 0; i < nbTraces; i++) { + if (resources[i] instanceof IFolder) + traces.add(new LTTngTraceEntry(fProject, (IFolder) resources[i])); + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * @return + */ + public String getName() { + return fResource.getName(); + } + + /** + * @return + */ + public IFolder getFolder() { + return fResource; + } + + /** + * @return + */ + public void addTrace(LTTngTraceEntry trace) { + traces.add(new LTTngTraceEntry(fProject, (IFolder) trace.getResource())); + } + + /** + * + */ + public LTTngTraceEntry[] getTraces() { + LTTngTraceEntry[] entries = new LTTngTraceEntry[traces.size()]; + return traces.toArray(entries); + } + + /** + * @return + */ + public LTTngProject getProject() { + return fProject; + } + +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentFolder.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentFolder.java new file mode 100644 index 0000000000..3e22ceaf0d --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngExperimentFolder.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.model; + +import org.eclipse.core.internal.resources.Folder; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * LTTngExperimentFolder + *

+ * TODO: Implement me. Please. + */ +@SuppressWarnings("restriction") +public class LTTngExperimentFolder { + + private final Folder fExperimentFolder; + private final LTTngProject fProject; + private LTTngExperimentEntry[] experiments = new LTTngExperimentEntry[0]; + + /** + * @param resource + */ + public LTTngExperimentFolder(LTTngProject project, Folder folder) { + fExperimentFolder = folder; + fProject = project; + try { + IResource[] resources = folder.members(); + int nbExperiments = resources.length; + experiments = new LTTngExperimentEntry[nbExperiments]; + for (int i = 0; i < nbExperiments; i++) { + if (resources[i] instanceof IFolder) { + experiments[i] = new LTTngExperimentEntry(project, (IFolder) resources[i]); + } + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * + */ + public LTTngProject getProject() { + return fProject; + } + + /** + * + */ + public Folder getFolder() { + return fExperimentFolder; + } + + /** + * + */ + public String getName() { + return fExperimentFolder.getName(); + } + /** + * + */ + public LTTngExperimentEntry[] getExperiments() { + return experiments; + } + + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProject.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProject.java new file mode 100644 index 0000000000..39ad9e1a8a --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProject.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.model; + +import org.eclipse.core.internal.resources.Folder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * LTTngProject + *

+ * TODO: Implement me. Please. + */ +@SuppressWarnings("restriction") +public class LTTngProject { + + private final IProject fProject; + private LTTngTraceFolder fTracesFolder; + private LTTngExperimentFolder fExperimentsFolder; + + /** + * @param project + */ + public LTTngProject(IProject project) { + + fProject = project; + fTracesFolder = null; + fExperimentsFolder = null; + try { + IResource[] resources = project.members(); + for (IResource resource : resources) { + if (resource.getType() == IResource.FOLDER) { + String name = resource.getName(); + if (name.equals("Traces")) { + fTracesFolder = new LTTngTraceFolder(this, (Folder) resource); + } + if (name.equals("Experiments")) { + fExperimentsFolder = new LTTngExperimentFolder(this, (Folder) resource); + } + } + } + } catch (CoreException e) { + } + } + + /** + * @return + */ + public IProject getProject() { + return fProject; + } + + /** + * @return + */ + public String getName() { + return fProject.getName(); + } + + /** + * @return + */ + public LTTngTraceFolder getTracesFolder() { + return fTracesFolder; + } + + /** + * @return + */ + public LTTngExperimentFolder getExperimentsFolder() { + return fExperimentsFolder; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceEntry.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceEntry.java new file mode 100644 index 0000000000..309017cbf9 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceEntry.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.model; + +import org.eclipse.core.resources.IFolder; + +/** + * LTTngTraceEntry + *

+ * TODO: Implement me. Please. + */ +public class LTTngTraceEntry { + + private final LTTngProject fProject; + private final IFolder fFolder; + + /** + * @param name + */ + public LTTngTraceEntry(LTTngProject project, IFolder folder) { + fProject = project; + fFolder = folder; + } + + /** + * @return + */ + public LTTngProject getProject() { + return fProject; + } + + /** + * @return + */ + public String getName() { + return fFolder.getName(); + } + + /** + * @return + */ + public IFolder getResource() { + return fFolder; + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceFolder.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceFolder.java new file mode 100644 index 0000000000..3261949f28 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngTraceFolder.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2009 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.lttng.ui.views.project.model; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * LTTngTraceFolder + *

+ * TODO: Implement me. Please. + */ +public class LTTngTraceFolder { + + private final IFolder fTraceFolder; + private final LTTngProject fProject; + private LTTngTraceEntry[] traces = new LTTngTraceEntry[0]; + + /** + * @param resource + */ + public LTTngTraceFolder(LTTngProject project, IFolder folder) { + fTraceFolder = folder; + fProject = project; + try { + IResource[] resources = folder.members(); + int nbTraces = resources.length; + traces = new LTTngTraceEntry[nbTraces]; + for (int i = 0; i < nbTraces; i++) { + if (resources[i] instanceof IFolder) + traces[i] = new LTTngTraceEntry(project, (IFolder) resources[i]); + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * + */ + public LTTngProject getProject() { + return fProject; + } + + /** + * + */ + public IFolder getFolder() { + return fTraceFolder; + } + + /** + * + */ + public String getName() { + return fTraceFolder.getName(); + } + + /** + * + */ + public LTTngTraceEntry[] getTraces() { + return traces; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java index 8dde5f3b35..00db512902 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which @@ -10,29 +10,33 @@ *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.resources; +import java.util.Arrays; + import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest; -import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor; +import org.eclipse.linuxtools.lttng.event.LttngTimestamp; +import org.eclipse.linuxtools.lttng.state.StateDataRequest; +import org.eclipse.linuxtools.lttng.state.StateManager; +import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy; +import org.eclipse.linuxtools.lttng.state.experiment.StateExperimentManager; +import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.ui.TraceDebug; -import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeViewerProvider; import org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView; import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; -import org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor.ResourcesEventToHandlerFactory; +import org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor.ResourcesTRangeUpdateFactory; import org.eclipse.linuxtools.lttng.ui.views.resources.model.ResourceModelFactory; -import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; -import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; +import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory; +import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; @@ -71,7 +75,9 @@ public class ResourcesView extends AbsTimeUpdateView implements private Action filterTraces; private Action zoomIn; private Action zoomOut; - private Action zoomFilter; + private Action synch; + + private ITimeAnalysisViewer tsfviewer; private Composite top; // private static SimpleDateFormat stimeformat = new SimpleDateFormat( @@ -128,29 +134,39 @@ public class ResourcesView extends AbsTimeUpdateView implements hookContextMenu(); contributeToActionBars(); + // Register the updater in charge to refresh elements as we update the + // time ranges + // FlowParamsUpdater listener = FlowModelFactory.getParamsUpdater(); + // tsfviewer.addWidgetTimeScaleSelectionListner(listener); + + // TODO: re-factor registration / notification process + // Register this view to receive updates when the model is updated with + // fresh info + // ModelListenFactory.getRegister().addFlowModelUpdatesListener(this); + + // Register the event processor factory in charge of event handling + EventProcessorProxy.getInstance().addEventProcessorFactory( + ResourcesTRangeUpdateFactory.getInstance()); + + // set the initial view parameter values + // Experiment start and end time + // as well as time space width in pixels, used by the time analysis + // widget + ParamsUpdater paramUpdater = ResourceModelFactory.getParamsUpdater(); + StateExperimentManager experimentManger = StateManagerFactory + .getExperimentManager(); // Read relevant values int timeSpaceWidth = tsfviewer.getTimeSpace(); - if (timeSpaceWidth < 0) { - timeSpaceWidth = -timeSpaceWidth; + TmfTimeRange timeRange = experimentManger.getExperimentTimeRange(); + if (timeRange != null) { + long time0 = timeRange.getStartTime().getValue(); + long time1 = timeRange.getEndTime().getValue(); + paramUpdater.update(time0, time1, timeSpaceWidth); } - TmfExperiment experiment = TmfExperiment.getCurrentExperiment(); - if (experiment != null) { - TmfTimeRange experimentTRange = experiment.getTimeRange(); - if (experimentTRange != null) { - long time0 = experimentTRange.getStartTime().getValue(); - long time1 = experimentTRange.getEndTime().getValue(); - ParamsUpdater paramUpdater = getParamsUpdater(); - paramUpdater.update(time0, time1, timeSpaceWidth); - } - // send the initial request and obtained the adjusted time used - TmfTimeRange adjustedTimeRange = initialExperimentDataRequest(this, experimentTRange); - - // initialize widget time boundaries and filtering parameters - ModelUpdateInit(experimentTRange, adjustedTimeRange, this); - } else { - TraceDebug.debug("No selected experiment information available"); - } + // Read current data if any available + StateManagerFactory.getExperimentManager().readExperiment( + "resourceView", this); } private void hookContextMenu() { @@ -186,7 +202,7 @@ public class ResourcesView extends AbsTimeUpdateView implements // manager.add(filterTraces); manager.add(zoomIn); manager.add(zoomOut); - manager.add(zoomFilter); + manager.add(synch); manager.add(new Separator()); } @@ -202,7 +218,7 @@ public class ResourcesView extends AbsTimeUpdateView implements // manager.add(filterTraces); manager.add(zoomIn); manager.add(zoomOut); - manager.add(zoomFilter); + manager.add(synch); manager.add(new Separator()); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } @@ -218,7 +234,7 @@ public class ResourcesView extends AbsTimeUpdateView implements // manager.add(filterTraces); manager.add(zoomIn); manager.add(zoomOut); - manager.add(zoomFilter); + manager.add(synch); manager.add(new Separator()); } @@ -373,21 +389,29 @@ public class ResourcesView extends AbsTimeUpdateView implements Messages.getString("ResourcesView.tmf.UI"), "icons/zoomout_nav.gif")); - // zoomFilter - zoomFilter = new Action() { + // action11 + synch = new Action() { @Override public void run() { - // Nothing to do, however the selection status is needed by the - // application + // Note: No action since the synch flag is used by Control flow + // view + // the actual viewer is set to accept api selections in + // createpartcontrol. + + // if (synch.isChecked()) { + // tsfviewer.setAcceptSelectionAPIcalls(true); + // } else { + // tsfviewer.setAcceptSelectionAPIcalls(false); + // } } }; - - zoomFilter.setText(Messages.getString("ResourcesView.Action.ZoomFilter")); //$NON-NLS-1$ - zoomFilter.setToolTipText(Messages.getString("ResourcesView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$ - zoomFilter.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Messages - .getString("ResourcesView.tmf.UI"), "icons/filter_items.gif")); - zoomFilter.setChecked(false); - + synch.setText(Messages.getString("ResourcesView.Action.Synchronize")); //$NON-NLS-1$ + synch.setToolTipText(Messages + .getString("ResourcesView.Action.Synchronize.ToolTip")); //$NON-NLS-1$ + synch.setChecked(false); + synch.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin( + Messages.getString("ResourcesView.tmf.UI"), + "icons/synced.gif")); // PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED); } @@ -399,18 +423,44 @@ public class ResourcesView extends AbsTimeUpdateView implements tsfviewer.getControl().setFocus(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * tsfTmProcessSelEvent - * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent - * ) - */ - @Override public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event) { - // common implementation - super.tsfTmProcessSelEvent(event); + Object source = event.getSource(); + if (source == null) { + return; + } + + // TmfTimeAnalysisViewer rViewer = (TmfTimeAnalysisViewer) + // event.getSource(); + // TmfTimeAnalysisViewer synchViewer = null; + // Synchronize viewer selections if Enabled, + // make sure the selection does not go in loops + // if (tsfviewer == rViewer) { + // synchViewer = tsfviewer2; + // } else { + // synchViewer = tsfviewer; + // } + // Notify listener views. + + ParamsUpdater paramUpdater = ResourceModelFactory.getParamsUpdater(); + Long savedSelTime = paramUpdater.getSelectedTime(); + + long selTimens = event.getSelectedTime(); + + // make sure the new selected time is different than saved before + // executing update + if (savedSelTime == null || savedSelTime != selTimens) { + // Notify listener views. + synchTimeNotification(selTimens); + + // Update the parameter updater to save the selected time + paramUpdater.setSelectedTime(selTimens); + + if (TraceDebug.isDEBUG()) { + // Object selection = event.getSelection(); + TraceDebug.debug("Selected Time in Resource View: " + + new LttngTimestamp(selTimens)); + } + } } /* @@ -421,34 +471,63 @@ public class ResourcesView extends AbsTimeUpdateView implements * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent) */ - @Override public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { - super.tsfTmProcessTimeScaleEvent(event); + // source needed to keep track of source values + Object source = event.getSource(); + + if (source != null) { + // Update the parameter updater before carrying out a read request + ParamsUpdater paramUpdater = ResourceModelFactory + .getParamsUpdater(); + boolean newParams = paramUpdater.processTimeScaleEvent(event); + + if (newParams) { + // Read the updated time window + TmfTimeRange trange = paramUpdater.getTrange(); + // Either send a new request or queue for next opportunity + dataRequest(trange); + } + } } - /* - * (non-Javadoc) + /** + * Obtains the remainder fraction on unit Seconds of the entered value in + * nanoseconds. e.g. input: 1241207054171080214 ns The number of seconds can + * be obtain by removing the last 9 digits: 1241207054 the fractional + * portion of seconds, expressed in ns is: 171080214 * - * @see - * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel - * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. - * ITmfTimeAnalysisEntry[], long, long, boolean, long, long, - * java.lang.Object) + * @param v + * @return */ - @Override - public void displayModel(final ITmfTimeAnalysisEntry[] items, final long startBoundTime, - final long endBoundTime, final boolean updateTimeBounds, final long startVisibleWindow, - final long endVisibleWindow, final Object source) { + public String formatNs(long v) { + StringBuffer str = new StringBuffer(); + boolean neg = v < 0; + if (neg) { + v = -v; + str.append('-'); + } + + String strVal = String.valueOf(v); + if (v < 1000000000) { + return strVal; + } + + // Extract the last nine digits (e.g. fraction of a S expressed in ns + return strVal.substring(strVal.length() - 9); + } - Display display = tsfviewer.getControl().getDisplay(); - display.asyncExec(new Runnable() { + /** + * @param items + * @param startTime + * @param endTime + * @param timeUpdate - Time bounds updated needed e.g. if a new Experiment or trace is selected + */ + public void resourceModelUpdates(final ITmfTimeAnalysisEntry[] items, + final long startTime, final long endTime, final boolean timeUpdate) { + tsfviewer.getControl().getDisplay().asyncExec(new Runnable() { public void run() { - tsfviewer.display(items, startBoundTime, endBoundTime, updateTimeBounds); - // validate visible boundaries - if (startVisibleWindow > -1 && endVisibleWindow > -1) { - tsfviewer.setSelectVisTimeWindow(startVisibleWindow, endVisibleWindow, source); - } + tsfviewer.display(items, startTime, endTime, timeUpdate); tsfviewer.resizeControls(); } }); @@ -458,6 +537,9 @@ public class ResourcesView extends AbsTimeUpdateView implements public void dispose() { // dispose parent resources super.dispose(); + // Remove the event processor factory + EventProcessorProxy.getInstance().removeEventProcessorFactory( + ResourcesTRangeUpdateFactory.getInstance()); tsfviewer.removeWidgetSelectionListner(this); tsfviewer.removeWidgetTimeScaleSelectionListner(this); @@ -465,101 +547,148 @@ public class ResourcesView extends AbsTimeUpdateView implements } /** - * Registers as listener of time selection from other tmf views + * Trigger time synchronisation to other views this method shall be called + * when a check has been performed to note that an actual change of time has + * been performed vs a pure re-selection of the same time * - * @param signal + * @param time */ - @Override - @TmfSignalHandler - public void synchToTime(TmfTimeSynchSignal signal) { - super.synchToTime(signal); + private void synchTimeNotification(long time) { + // if synchronisation selected + if (synch.isChecked()) { + // Notify other views + TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(this, + new LttngTimestamp(time))); + } } /** - * Annotation Registers as listener of time range selection from other views - * The implementation handles the entry of the signal. + * Registers as listener of time selection from other tmf views * * @param signal */ @TmfSignalHandler - public void synchToTimeRange(TmfRangeSynchSignal signal) { - if (zoomFilter != null) { - synchToTimeRange(signal, zoomFilter.isChecked()); + public void synchToTime(TmfTimeSynchSignal signal) { + if (synch.isChecked()) { + Object source = signal.getSource(); + if (signal != null && source != null && source != this) { + // Internal value is expected in nano seconds. + long selectedTime = signal.getCurrentTime().getValue(); + if (tsfviewer != null) { + tsfviewer.setSelectedTime(selectedTime, true, source); + } + } } } - @Override - public void modelIncomplete(ILttngSyntEventRequest request) { - // Nothing to do - // The data will be refreshed on the next request - } - /* * (non-Javadoc) * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * getEventProcessor() + * @see + * org.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView#waitCursor + * (boolean) */ @Override - public ITransEventProcessor getEventProcessor() { - return ResourcesEventToHandlerFactory.getInstance(); - } - - /** - * @param signal - */ - @TmfSignalHandler - public void experimentSelected(TmfExperimentSelectedSignal signal) { - if (signal != null) { - TmfTimeRange experimentTRange = signal.getExperiment().getTimeRange(); - - // prepare time intervals in widget - ModelUpdateInit(experimentTRange, experimentTRange, signal.getSource()); - - // request initial data - initialExperimentDataRequest(signal.getSource(), experimentTRange); - } - } - - /** - * @param source - * @param experimentTRange - * @return Adjusted time window used for the request (smaller window to - * initialize view) - */ - private TmfTimeRange initialExperimentDataRequest(Object source, TmfTimeRange experimentTRange) { - // Adjust the initial time window to a shorter interval to allow - // user to select the interesting area based on the perspective - TmfTimeRange initTimeWindow = getInitTRange(experimentTRange); - - dataRequest(initTimeWindow, experimentTRange, true); - if (TraceDebug.isDEBUG()) { - TraceDebug.debug("Initialization request time range is: " + initTimeWindow.getStartTime().toString() + "-" - + initTimeWindow.getEndTime().toString()); + protected void waitCursor(final boolean waitInd) { + if (tsfviewer != null) { + Display display = tsfviewer.getControl().getDisplay(); + + // Perform the updates on the UI thread + display.asyncExec(new Runnable() { + public void run() { + tsfviewer.waitCursor(waitInd); + } + }); } - - return initTimeWindow; } /* * (non-Javadoc) * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * getParamsUpdater() + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# + * ModelUpdatePrep(java.lang.String, boolean) */ @Override - protected ParamsUpdater getParamsUpdater() { - return ResourceModelFactory.getParamsUpdater(); + public void ModelUpdatePrep(String traceId, boolean clearAllData, + TmfTimeRange trange) { + if (clearAllData) { + ResourceModelFactory.getResourceContainer().clearResources(); + } else { + ResourceModelFactory.getResourceContainer().clearChildren(traceId); + } + + ParamsUpdater updater = ResourceModelFactory.getParamsUpdater(); + // Start over + updater.setEventsDiscarded(0); + + // Update new visible time range if available + if (trange != null) { + updater.update(trange.getStartTime().getValue(), trange + .getEndTime().getValue()); + } } /* * (non-Javadoc) * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * getItemContainer() + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# + * ModelUpdateComplete(org.eclipse.linuxtools.lttng.state.StateDataRequest) */ @Override - protected ItemContainer getItemContainer() { - return ResourceModelFactory.getResourceContainer(); + public void ModelUpdateComplete(StateDataRequest request) { + StateManager smanager = request.getStateManager(); + long experimentStartTime = -1; + long experimentEndTime = -1; + TmfTimeRange experimentTimeRange = smanager.getExperimentTimeWindow(); + if (experimentTimeRange != null) { + experimentStartTime = experimentTimeRange.getStartTime().getValue(); + experimentEndTime = experimentTimeRange.getEndTime().getValue(); + } + + // Obtain the current resource list + TimeRangeEventResource[] resourceArr = ResourceModelFactory + .getResourceContainer().readResources(); + + // Sort the array by pid + Arrays.sort(resourceArr); + + // Update the view part + resourceModelUpdates(resourceArr, experimentStartTime, + experimentEndTime, request.isclearDataInd()); + + // reselect to original time + ParamsUpdater paramUpdater = ResourceModelFactory.getParamsUpdater(); + final Long selTime = paramUpdater.getSelectedTime(); + if (selTime != null) { + Display display = tsfviewer.getControl().getDisplay(); + display.asyncExec(new Runnable() { + public void run() { + tsfviewer.setSelectedTime(selTime, false, this); + } + }); + } + + if (TraceDebug.isDEBUG()) { + Long count = smanager.getEventCount(); + int eventCount = 0; + for (TimeRangeEventResource resource : resourceArr) { + eventCount += resource.getTraceEvents().size(); + } + + int discarded = ResourceModelFactory.getParamsUpdater() + .getEventsDiscarded(); + int discardedOutofOrder = ResourceModelFactory.getParamsUpdater() + .getEventsDiscardedWrongOrder(); + TraceDebug + .debug("Events handled: " + + count + + " Events loaded in Resource view: " + + eventCount + + " Number of events discarded: " + + discarded + + "\n\tNumber of events discarded with start time earlier than next good time: " + + discardedOutofOrder); + } + } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/AbsResourcesTRangeUpdate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/AbsResourcesTRangeUpdate.java index fa92ab1dbb..e0110d9a3c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/AbsResourcesTRangeUpdate.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/AbsResourcesTRangeUpdate.java @@ -14,15 +14,14 @@ package org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor; import java.util.Vector; import org.eclipse.linuxtools.lttng.event.LttngEvent; -import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; -import org.eclipse.linuxtools.lttng.ui.TraceDebug; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent; -import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent.Type; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource; -import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource.ResourceTypes; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeResourceFactory; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent.Type; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource.ResourceTypes; import org.eclipse.linuxtools.lttng.ui.views.common.AbsTRangeUpdate; import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; import org.eclipse.linuxtools.lttng.ui.views.resources.model.ResourceContainer; @@ -30,7 +29,7 @@ import org.eclipse.linuxtools.lttng.ui.views.resources.model.ResourceModelFactor import org.eclipse.linuxtools.tmf.event.TmfTimeRange; public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate - implements ILttngEventProcessor { + implements IEventProcessing { // ======================================================================== // Data @@ -54,7 +53,7 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate .getInstance().createResource(resContainer.getUniqueId(), traceStartTime, traceEndTime, resourceName, traceId, "", type, resId, insertionTime); - resContainer.addItem(localRessource); + resContainer.addResource(localRessource); return localRessource; } @@ -68,35 +67,20 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate long windowStartTime = params.getStartTime(); long windowEndTime = params.getEndTime(); - if (stime == 13589765052286L) { - TraceDebug.debug("Debug event catched"); - } - - // Start of event is already out of range - if (stime > windowEndTime) { - return false; + // start time is within window + if (stime >= windowStartTime && stime <= windowEndTime) { + // The event or part of it shall be displayed. + return true; } - // End time within or beyond start of window as long as the start time - // is before the end of the window (condition above) - if (etime >= windowStartTime) { + // end time is within window + if (etime >= windowStartTime && etime <= windowEndTime) { + // The event or part of it shall be displayed. return true; } - // // start time is within window - // if (stime >= windowStartTime && stime <= windowEndTime) { - // // The event or part of it shall be displayed. - // return true; - // } - // - // // end time is within window - // if (etime >= windowStartTime && etime <= windowEndTime) { - // // The event or part of it shall be displayed. - // return true; - // } - - // crosses the window - if (stime <= windowStartTime && etime >= windowEndTime) { + // check that a portion is within the window + if (stime < windowStartTime && etime > windowEndTime) { // The time range is bigger than the selected time window and // crosses it return true; @@ -146,7 +130,7 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate public TimeRangeEventResource resourcelist_obtain_generic(Long resourceId, ResourceTypes resourceType, String traceId) { - return resContainer.findItem(resourceId, resourceType, traceId); + return resContainer.findResource(resourceId, resourceType, traceId); } protected boolean globalProcessBeforeExecmode(LttngEvent trcEvent, @@ -163,7 +147,7 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate trcEvent.getCpuId()); Long cpu = trcEvent.getCpuId(); if (localResource == null) { - TmfTimeRange timeRange = traceSt.getContext() + TmfTimeRange timeRange = traceSt.getInputDataRef() .getTraceTimeWindow(); localResource = addLocalResource(timeRange.getStartTime() .getValue(), timeRange.getEndTime().getValue(), traceSt @@ -191,28 +175,27 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate * @param stateMode * @return */ - protected boolean makeDraw(LttngTraceState traceSt, long stime, long etime, - TimeRangeEventResource localResource, + protected boolean makeDraw(LttngTraceState traceSt, long startTime, + long endTime, TimeRangeEventResource localResource, ParamsUpdater params, String stateMode) { - // Check if the event is out of range - if (!withinViewRange(stime, etime)) { - params.incrementEventsDiscarded(); - return false; - } - // Check if the time range is consistent. - if (etime < stime) { + if (endTime < startTime) { params.incrementEventsDiscardedWrongOrder(); return false; } - // Store the next good time to start drawing the next event - // this is done this early to display an accurate start time of the - // first event - // within the display window - // Moved at the end since it produces space gaps among events - // localResource.setNext_good_time(etime); + // Determine start and end times to establish duration + long stime = startTime; + long windowEndTime = params.getEndTime(); + long etime = endTime < windowEndTime ? endTime : windowEndTime; + + if (etime < stime || !withinViewRange(stime, etime)) { + // No use to process the event since it's outside + // the visible time range of the window + params.incrementEventsDiscarded(); + return false; + } // Determine if the time range event will fit it the current // pixel map @@ -220,6 +203,10 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate double k = getPixelsPerNs(traceSt, params); double pixels = duration * k; + // ***VERIFY*** + // Is all this equivalent to this call in C?? + // if(ltt_time_compare(hashed_process_data->next_good_time,evtime) > 0) + // *** // Visibility check // Display a "more information" indication by allowing non visible event // as long as its previous event is visible. @@ -235,6 +222,12 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate .size() - 1); prevEventVisibility = prevEvent.isVisible(); + // ***VERIFY*** + // This replace all C Call like this one ? + // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime, + // time_window.start_time) == -1 || ltt_time_compare(evtime, + // time_window.end_time) == 1) + // if previous event visibility is false and the time span // between events less than two pixels, there is no need to // load it in memory i.e. not visible and a more indicator is @@ -258,10 +251,19 @@ public abstract class AbsResourcesTRangeUpdate extends AbsTRangeUpdate TimeRangeEvent time_window = new TimeRangeEvent(stime, etime, localResource, eventType, stateMode); + // *** VERIFY *** + // This is added to replace the multiple draw and gtk/glib command + // but + // I'm not sure about it time_window.setVisible(visible); localResource.addChildren(time_window); - + // Store the next good time to start drawing the event. localResource.setNext_good_time(etime); + // *** VERIFY *** + // Missing checks like this one? + // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime, + // time_window.start_time) == -1 || ltt_time_compare(evtime, + // time_window.end_time) == 1) } return false; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeAfterUpdateHandlers.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeAfterUpdateHandlers.java new file mode 100644 index 0000000000..58d4a13c88 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeAfterUpdateHandlers.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.state.StateStrings.Events; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; +import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; + +/** + * Creates instances of specific after state update handlers, per corresponding + * event. + * + * @author alvaro + * + */ +public class ResourcesTRangeAfterUpdateHandlers { + + /** + *

+ * Handles: LTT_EVENT_SCHED_SCHEDULE + *

+ * Replace C function named "after_schedchange_hook" in eventhooks.c + *

+ * Fields: LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE + *

+ * + * @return + */ + final IEventProcessing getAfterSchedChangeHandler() { + AbsResourcesTRangeUpdate handler = new AbsResourcesTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_SCHED_SCHEDULE; + + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + // TODO: After sched scheduler handler should implement an + // update to the current resource data, similar to + // current_hash_data in C + // We don't keep track of current hashed resource, we look in + // the hash table every time. keeping track of current hash may + // improve performance, although needs to be bench marked to + // verify + // if there's is a real gain. + + // process_list->current_hash_data[trace_num][process_in->cpu] = + // hashed_process_data_in; + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } + + /** + * Drawing stuff ? + */ + // int after_request(void *hook_data, void *call_data) + // int after_chunk(void *hook_data, void *call_data) + // int before_statedump_end(void *hook_data, void *call_data) +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeBeforeUpdateHandlers.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeBeforeUpdateHandlers.java new file mode 100644 index 0000000000..3ac29a5bd5 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeBeforeUpdateHandlers.java @@ -0,0 +1,414 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.state.StateStrings.Channels; +import org.eclipse.linuxtools.lttng.state.StateStrings.Events; +import org.eclipse.linuxtools.lttng.state.StateStrings.Fields; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; +import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource.ResourceTypes; +import org.eclipse.linuxtools.tmf.event.TmfTimeRange; + +/** + * Creates instances of specific before state update handlers, per corresponding + * event. + * + * @author alvaro + * + */ +public class ResourcesTRangeBeforeUpdateHandlers { + + /** + *

+ * Handles: LTT_EVENT_SCHED_SCHEDULE + *

+ * Replace C function named "before_schedchange_hook" in eventhooks.c + *

+ * Fields: LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID(?), LTT_FIELD_PREV_STATE + * (?) + *

+ * + * @return + */ + final IEventProcessing getBeforeSchedChangeHandler() { + AbsResourcesTRangeUpdate handler = new AbsResourcesTRangeUpdate() { + + private Events eventType = Events.LTT_EVENT_SCHED_SCHEDULE; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + // Create a time range for the cpu. + globalProcessBeforeExecmode(trcEvent, traceSt); + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_IRQ_ENTRY, LTT_EVENT_IRQ_EXIT + *

+ * Replace C function named "before_execmode_hook_irq" in eventhooks.c + * + * @return + */ + final IEventProcessing getBeforeExecutionModeIrq() { + AbsResourcesTRangeUpdate handler = new AbsResourcesTRangeUpdate() { + + // This method is common to TWO types of events + private Events eventType = Events.LTT_EVENT_IRQ_ENTRY; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + Long irqId = null; + + // According to Ltt, we should not draw anything if the channel + // is the kernel one + if (trcEvent.getChannelName().equals( + Channels.LTT_CHANNEL_KERNEL)) { + return false; + } else { + + if (trcEvent.getMarkerName().equals( + Events.LTT_EVENT_IRQ_ENTRY.getInName())) { + irqId = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_IRQ_ID); + } else if (trcEvent.getMarkerName().equals( + Events.LTT_EVENT_IRQ_EXIT.getInName())) { + long cpu = trcEvent.getCpuId(); + irqId = traceSt.getCpu_states().get(cpu) + .peekFromIrqStack(); + if (irqId.equals(-1L)) { + // nothing to update + return false; + } + } + + + // softIrqId is the resource id here + TimeRangeEventResource localResource = resourcelist_obtain_irq( + traceSt, irqId); + + // If the resource is missing in the list, add it + if (localResource == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localResource = addLocalResource(timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceSt.getTraceId(), + ResourceTypes.IRQ, irqId, trcEvent + .getTimestamp().getValue()); + } + + // get the start time + long stime = localResource.getNext_good_time(); + + // Get the resource state mode + String irqStateMode = localResource.getStateMode(traceSt); + + // Call the makeDraw function + makeDraw(traceSt, stime, + trcEvent.getTimestamp().getValue(), localResource, + params, irqStateMode); + + // Call the globalProcessBeforeExecmode() after, as + // it is needed by all + // getBeforeExecmode*SOMETHING*() + globalProcessBeforeExecmode(trcEvent, traceSt); + } + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_SOFT_IRQ_RAISE, LTT_EVENT_SOFT_IRQ_ENTRY, + * LTT_EVENT_SOFT_IRQ_EXIT, + *

+ * Replace C function named "before_execmode_hook_soft_irq" in eventhooks.c + *

+ * Fields: LTT_FIELD_SOFT_IRQ_ID + *

+ * + * @return + */ + final IEventProcessing getBeforeExecutionModeSoftIrq() { + AbsResourcesTRangeUpdate handler = new AbsResourcesTRangeUpdate() { + + // This method is common to SEVERAL types of events + private Events eventType = Events.LTT_EVENT_TRAP_ENTRY; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + Long softIrqId = null; + + // According to Ltt, we should not draw anything if the channel + // is the kernel one + if (trcEvent.getChannelName().equals( + Channels.LTT_CHANNEL_KERNEL)) { + return false; + } else { + + if ((trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_SOFT_IRQ_RAISE.getInName())) + || (trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_SOFT_IRQ_ENTRY + .getInName()))) { + softIrqId = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_SOFT_IRQ_ID); + } else if (trcEvent.getMarkerName().equals( + Events.LTT_EVENT_SOFT_IRQ_EXIT.getInName())) { + long cpu = trcEvent.getCpuId(); + softIrqId = traceSt.getCpu_states().get(cpu) + .peekFromSoftIrqStack(); + if (softIrqId < 0) { + // nothing to update + return false; + } + } + + // Add the resource to the resource list + // softIrqId is the resource id here + TimeRangeEventResource localResource = resourcelist_obtain_soft_irq( + traceSt, softIrqId); + + // If the resource is missing in the list, add it + if (localResource == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localResource = addLocalResource(timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceSt.getTraceId(), + ResourceTypes.SOFT_IRQ, softIrqId, trcEvent + .getTimestamp().getValue()); + } + + // get the start time + long stime = localResource.getNext_good_time(); + + // Get the resource state mode + String softIrqStateMode = localResource + .getStateMode(traceSt); + + // Call the makeDraw function + makeDraw(traceSt, stime, + trcEvent.getTimestamp().getValue(), localResource, + params, softIrqStateMode); + + // Call the globalProcessBeforeExecmode() after, as + // it is needed by all + // getBeforeExecmode*SOMETHING*() + globalProcessBeforeExecmode(trcEvent, traceSt); + + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_TRAP_ENTRY, LTT_EVENT_TRAP_EXIT, + * LTT_EVENT_PAGE_FAULT_ENTRY, LTT_EVENT_PAGE_FAULT_EXIT, + * LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY, LTT_EVENT_PAGE_FAULT_NOSEM_EXIT + *

+ * Replace C function named "before_execmode_hook_trap" in eventhooks.c + *

+ * Fields: LTT_FIELD_TRAP_ID + *

+ * + * @return + */ + final IEventProcessing getBeforeExecutionModeTrap() { + AbsResourcesTRangeUpdate handler = new AbsResourcesTRangeUpdate() { + + // This method is common to SEVERAL types of events + private Events eventType = Events.LTT_EVENT_TRAP_ENTRY; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + + Long trapId = null; + + // According to Ltt, we should not draw anything if the channel + // is the kernel one + if (trcEvent.getChannelName().equals( + Channels.LTT_CHANNEL_KERNEL)) { + return false; + } else { + + if ((trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_TRAP_ENTRY.getInName())) + || (trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_PAGE_FAULT_ENTRY + .getInName())) + || (trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY + .getInName()))) { + trapId = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_TRAP_ID); + } else if ((trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_TRAP_EXIT.getInName())) + || (trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_PAGE_FAULT_EXIT + .getInName())) + || (trcEvent.getMarkerName() + .equals(Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT + .getInName()))) { + long cpu = trcEvent.getCpuId(); + trapId = traceSt.getCpu_states().get(cpu) + .peekFromTrapStack(); + + if (trapId.equals(-1L)) { + // Nothing to update + return false; + } + } else { + return false; + } + + // Add the resource to the resource list + // trapId is the resource id here + TimeRangeEventResource localResource = resourcelist_obtain_trap( + traceSt, trapId); + + // If the resource is missing in the list, add it + if (localResource == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localResource = addLocalResource(timeRange + .getStartTime().getValue(), timeRange + .getEndTime().getValue(), traceSt.getTraceId(), + ResourceTypes.TRAP, trapId, trcEvent + .getTimestamp().getValue()); + } + + // Determine the trap state. + String trapStateMode = localResource.getStateMode(traceSt); + + long stime = localResource.getNext_good_time(); + makeDraw(traceSt, stime, + trcEvent.getTimestamp().getValue(), localResource, + params, trapStateMode); + + // Call the globalProcessBeforeExecmode() after, as + // it is needed by all + // getBeforeExecmode*SOMETHING*() + globalProcessBeforeExecmode(trcEvent, traceSt); + + } + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } + + /** + *

+ * Handles: LTT_EVENT_REQUEST_ISSUE, LTT_EVENT_REQUEST_COMPLETE + *

+ * Replace C function named "before_bdev_event_hook" in eventhooks.c + *

+ * Fields: LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION (?) + *

+ * + * @return + */ + final IEventProcessing getBeforeBdevEvent() { + AbsResourcesTRangeUpdate handler = new AbsResourcesTRangeUpdate() { + + // This method is common for LTT_EVENT_REQUEST_ISSUE and + // LTT_EVENT_REQUEST_COMPLETE + private Events eventType = Events.LTT_EVENT_REQUEST_COMPLETE; + + // @Override + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + Long major = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_MAJOR); + Long minor = getAFieldLong(trcEvent, traceSt, + Fields.LTT_FIELD_MINOR); + // This is useless even in LTTv! + // Long oper = getAFieldLong(trcEvent, traceSt, + // Fields.LTT_FIELD_OPERATION); + + Long bdevId = getMkdevId(major, minor); + + // According to Lttv, bdevId (obtain from MKDEV macro) is + // the id here + TimeRangeEventResource localResource = resourcelist_obtain_bdev( + traceSt, bdevId); + + if (localResource == null) { + TmfTimeRange timeRange = traceSt.getInputDataRef() + .getTraceTimeWindow(); + localResource = addLocalResource(timeRange.getStartTime() + .getValue(), timeRange.getEndTime().getValue(), + traceSt.getTraceId(), ResourceTypes.BDEV, bdevId, + trcEvent.getTimestamp().getValue()); + } + + // get the start time + long stime = localResource.getNext_good_time(); + // Get the resource state mode + String bdevStateMode = localResource.getStateMode(traceSt); + // Call the makeDraw function + makeDraw(traceSt, stime, trcEvent.getTimestamp().getValue(), + localResource, params, bdevStateMode); + + return false; + } + + // @Override + public Events getEventHandleType() { + return eventType; + } + }; + + return handler; + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeFinishUpdateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeFinishUpdateHandler.java new file mode 100644 index 0000000000..5d01c755a8 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeFinishUpdateHandler.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.state.StateStrings.Events; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; +import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; +import org.eclipse.linuxtools.lttng.ui.TraceDebug; +import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource; +import org.eclipse.linuxtools.tmf.event.TmfTimestamp; + +/** + * Creates specific finish state data request + * + * @author alvaro + * + */ +public class ResourcesTRangeFinishUpdateHandler extends + AbsResourcesTRangeUpdate + implements IEventProcessing { + + public Events getEventHandleType() { + // No specific event + return null; + } + + public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { + // Draw a last known state to the end of the trace + TmfTimestamp endReqTime = traceSt.getInputDataRef() + .getTraceTimeWindow().getEndTime(); + + TraceDebug.debug("Number of localResources: " + + resContainer.readResources().length); + + // for each existing resource + for (TimeRangeEventResource localResource : resContainer + .readResources()) { + + // get the start time + long stime = localResource.getNext_good_time(); + + // Get the resource state mode + String stateMode = localResource.getStateMode(traceSt); + + // Insert an instance from previous time to end request time with + // the current state + makeDraw(traceSt, stime, endReqTime.getValue(), + localResource, params, stateMode); + } + + return false; + } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java new file mode 100644 index 0000000000..14b67caa0f --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.linuxtools.lttng.state.StateStrings; +import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; + +/** + * Builds a Map from string event name to a processing handler object, the + * processors implement the same interface to facilitate transparent methods + * call, + * + * The map key String is the entry point of the raw events. Using a hash speeds + * up the resolution of the appropriate processor + * + * @author alvaro + * + */ +public class ResourcesTRangeUpdateFactory extends AbsEventProcessorFactory { + // ======================================================================== + // Data + // ======================================================================= + private final Map eventNametoBeforeProcessor = new HashMap(); + private final Map eventNametoAfterProcessor = new HashMap(); + private ResourcesTRangeFinishUpdateHandler finishProcessor = null; + private static ResourcesTRangeUpdateFactory instance = null; + private ResourcesTRangeBeforeUpdateHandlers instantiateBeforeHandler = new ResourcesTRangeBeforeUpdateHandlers(); + private ResourcesTRangeAfterUpdateHandlers instantiateAfterHandler = new ResourcesTRangeAfterUpdateHandlers(); + + private ResourcesTRangeUpdateFactory() { + // Create one instance of each individual event handler and add the + // instance to the map + + // *** BEFORE HOOKS *** + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(), + instantiateBeforeHandler.getBeforeSchedChangeHandler()); + + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY + .getInName(), instantiateBeforeHandler + .getBeforeExecutionModeTrap()); + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT + .getInName(), instantiateBeforeHandler + .getBeforeExecutionModeTrap()); + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY.getInName(), + instantiateBeforeHandler.getBeforeExecutionModeTrap()); + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT.getInName(), + instantiateBeforeHandler.getBeforeExecutionModeTrap()); + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY + .getInName(), instantiateBeforeHandler + .getBeforeExecutionModeTrap()); + eventNametoBeforeProcessor + .put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT + .getInName(), instantiateBeforeHandler + .getBeforeExecutionModeTrap()); + + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY + .getInName(), instantiateBeforeHandler + .getBeforeExecutionModeIrq()); + eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT + .getInName(), instantiateBeforeHandler + .getBeforeExecutionModeIrq()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE.getInName(), + instantiateBeforeHandler.getBeforeExecutionModeSoftIrq()); + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY.getInName(), + instantiateBeforeHandler.getBeforeExecutionModeSoftIrq()); + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT.getInName(), + instantiateBeforeHandler.getBeforeExecutionModeSoftIrq()); + + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_REQUEST_ISSUE.getInName(), + instantiateBeforeHandler.getBeforeBdevEvent()); + eventNametoBeforeProcessor.put( + StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE.getInName(), + instantiateBeforeHandler.getBeforeBdevEvent()); + + // *** AFTER HOOKS *** + eventNametoAfterProcessor.put( + StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(), + instantiateAfterHandler.getAfterSchedChangeHandler()); + + finishProcessor = new ResourcesTRangeFinishUpdateHandler(); + } + + /** + * + */ + public static AbsEventProcessorFactory getInstance() { + if (instance == null) { + instance = new ResourcesTRangeUpdateFactory(); + } + return instance; + } + + @Override + public IEventProcessing getAfterProcessor(String eventType) { + return eventNametoAfterProcessor.get(eventType); + } + + @Override + public IEventProcessing getBeforeProcessor(String eventType) { + return eventNametoBeforeProcessor.get(eventType); + } + + @Override + public IEventProcessing getfinishProcessor() { + return finishProcessor; + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/messages.properties b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/messages.properties index 032d20a3ef..46dabb0cdc 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/messages.properties +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/messages.properties @@ -20,7 +20,5 @@ ResourcesView.Action.ZoomIn=Zoom In ResourcesView.Action.ZoomIn.Tooltip=Zoom In ResourcesView.Action.ZoomOut=Zoom Out ResourcesView.Action.ZoomOut.tooltip=Zoom Out -ResourcesView.Action.ZoomFilter=Zoom Filter -ResourcesView.Action.ZoomFilter.tooltip=Display elements with events within the zoomed time window ResourcesView.msgSlogan=Resources View ResourcesView.tmf.UI=org.eclipse.linuxtools.tmf.ui diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java index 472876444a..2f9545d1ab 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java @@ -15,7 +15,6 @@ import java.util.HashMap; import java.util.Iterator; import org.eclipse.linuxtools.lttng.TraceDebug; -import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource.ResourceTypes; @@ -25,7 +24,7 @@ import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource.Resou * @author alvaro * */ -public class ResourceContainer implements ItemContainer { +public class ResourceContainer { // ======================================================================== // Data // ======================================================================== @@ -41,63 +40,73 @@ public class ResourceContainer implements ItemContainer */ public ResourceContainer() { } - - /* - * (non-Javadoc) + /** + * Interface to add resources. * - * @see - * org.eclipse.linuxtools.lttng.ui.views.resources.model.ItemContainer#addItem - * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. - * ITmfTimeAnalysisEntry) + * @param process */ - public void addItem(TimeRangeEventResource newItem) { - if (newItem != null) { - resources.put( new ResourceKey(newItem),newItem); + public void addResource(TimeRangeEventResource newResource) { + if (newResource != null) { + resources.put( new ResourceKey(newResource),newResource); } } // ======================================================================== // Methods // ======================================================================== - /* (non-Javadoc) - * @see org.eclipse.linuxtools.lttng.ui.views.resources.model.ItemContainer#getUniqueId() - */ + /** + * Request a unique ID + * + * @return Integer + */ public Integer getUniqueId() { return uniqueId++; } - /* (non-Javadoc) - * @see org.eclipse.linuxtools.lttng.ui.views.resources.model.ItemContainer#readItems() + /** + * This method is intended for read only purposes in order to keep the + * internal data structure in Synch + * + * @return */ - public TimeRangeEventResource[] readItems() { + public TimeRangeEventResource[] readResources() { return resources.values().toArray( new TimeRangeEventResource[resources.size()]); } - /* (non-Javadoc) - * @see org.eclipse.linuxtools.lttng.ui.views.resources.model.ItemContainer#clearChildren() + /** + * Clear the children information for resources related to a specific trace + * e.g. just before refreshing data with a new time range + * + * @param traceId */ - public void clearChildren() { + public void clearChildren(String traceId) { TimeRangeEventResource newRes = null; Iterator iterator = resources.keySet().iterator(); while (iterator.hasNext()) { - newRes = resources.get(iterator.next()); - newRes.reset(); + newRes = resources.get(iterator.next()); + + if (newRes.getTraceId().equals(traceId)) { + newRes.reset(); + } } } - /* (non-Javadoc) - * @see org.eclipse.linuxtools.lttng.ui.views.resources.model.ItemContainer#clearItems() + /** + * Clear all resources items e.g. when a new experiment is selected */ - public void clearItems() { + public void clearResources() { resources.clear(); } - /* (non-Javadoc) - * @see org.eclipse.linuxtools.lttng.ui.views.resources.model.ItemContainer#removeItems(java.lang.String) + /** + * Remove the resources related to a specific trace e.g. during trace + * removal + * + * @param traceId */ - public void removeItems(String traceId) { + public void removeResources(String traceId) { ResourceKey newKey = null; Iterator iterator = resources.keySet().iterator(); @@ -112,22 +121,18 @@ public class ResourceContainer implements ItemContainer /** - * Search by keys (resourceId, traceId and type) - *

- * - * A match is returned if the three arguments received match an entry - * Otherwise null is returned + * Search by keys (resourceId, traceId and type)

* - * @param searchedId - * The ressourceId we are looking for - * @param searchedType - * The ressourceType we are looking for - * @param searchedTraceId - * The traceId (trace name?) we are looking for - * - * @return TimeRangeEventResource - */ - public TimeRangeEventResource findItem(Long searchedId, ResourceTypes searchedType, String searchedTraceId) { + * A match is returned if the three arguments received match an entry + * Otherwise null is returned + * + * @param searchedId The ressourceId we are looking for + * @param searchedType The ressourceType we are looking for + * @param searchedTraceId The traceId (trace name?) we are looking for + * + * @return TimeRangeEventResource + */ + public TimeRangeEventResource findResource(Long searchedId, ResourceTypes searchedType, String searchedTraceId) { // Get the EventResource associated to a key we create here TimeRangeEventResource foundResource = resources.get( new ResourceKey(searchedId, searchedTraceId, searchedType) ); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java index 269b0beb68..e01aa1e5ec 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java @@ -24,31 +24,25 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewerColumn; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest; -import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventToHandlerResolver; -import org.eclipse.linuxtools.lttng.ui.TraceDebug; -import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer; -import org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView; -import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; +import org.eclipse.linuxtools.lttng.state.IStateDataRequestListener; +import org.eclipse.linuxtools.lttng.state.RequestCompletedSignal; +import org.eclipse.linuxtools.lttng.state.RequestStartedSignal; +import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy; +import org.eclipse.linuxtools.lttng.state.experiment.StateExperimentManager; +import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; +import org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor.StatsEventCountHandlerFactory; import org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor.StatsTimeCountHandlerFactory; +import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeFactory; import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeNode; -import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeRootFactory; -import org.eclipse.linuxtools.tmf.event.TmfEvent; -import org.eclipse.linuxtools.tmf.event.TmfTimeRange; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; +import org.eclipse.linuxtools.tmf.ui.views.TmfView; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.ISharedImages; @@ -64,8 +58,11 @@ import org.eclipse.ui.PlatformUI; * TreeViewer. - The controller that keeps model and view synchronised is an * observer of the model. */ -public class StatisticsView extends AbsTimeUpdateView { +public class StatisticsView extends TmfView implements + IStateDataRequestListener { + public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.statistics"; + private TreeViewer treeViewer; // Table column names @@ -92,7 +89,6 @@ public class StatisticsView extends AbsTimeUpdateView { .asList(new String[] { "Event Types" })); private DecimalFormat decimalFormat = new DecimalFormat("0.#########"); - private Cursor fwaitCursor = null; // Used to draw bar charts in columns. private interface ColumnPercentageProvider { @@ -325,14 +321,6 @@ public class StatisticsView extends AbsTimeUpdateView { } } - public StatisticsView(String viewName) { - super(viewName); - } - - public StatisticsView() { - this("StatisticsView"); - } - /* * (non-Javadoc) * @@ -342,6 +330,11 @@ public class StatisticsView extends AbsTimeUpdateView { */ @Override public void createPartControl(Composite parent) { + EventProcessorProxy.getInstance().addEventProcessorFactory( + StatsTimeCountHandlerFactory.getInstance()); + EventProcessorProxy.getInstance().addEventProcessorFactory( + StatsEventCountHandlerFactory.getInstance()); + parent.setLayout(new FillLayout()); treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL @@ -444,24 +437,23 @@ public class StatisticsView extends AbsTimeUpdateView { treeViewer.getTree().setSortColumn(treeViewer.getTree().getColumn(0)); treeViewer.getTree().setSortDirection(SWT.DOWN); + treeViewer.setInput(StatisticsTreeFactory + .getStatisticsTree("Experiment")); + // Read current data if any available - TmfExperiment experiment = TmfExperiment.getCurrentExperiment(); - if (experiment != null) { - requestData(experiment); - } else { - TraceDebug.debug("No selected experiment information available"); - } - } + StateExperimentManager experimentManger = StateManagerFactory + .getExperimentManager(); + experimentManger.readExperiment("statisticsView", this); + } @Override public void dispose() { super.dispose(); - if (fwaitCursor != null) { - fwaitCursor.dispose(); - } + EventProcessorProxy.getInstance().removeEventProcessorFactory( + StatsTimeCountHandlerFactory.getInstance()); + EventProcessorProxy.getInstance().removeEventProcessorFactory( + StatsEventCountHandlerFactory.getInstance()); - // clean the model - StatisticsTreeRootFactory.removeAll(); } /* @@ -474,61 +466,14 @@ public class StatisticsView extends AbsTimeUpdateView { treeViewer.getTree().setFocus(); } + @TmfSignalHandler + public void processingStarted(RequestStartedSignal request) { + // Nothing to do for the time being - /** - * @return - */ - @Override - public AbsEventToHandlerResolver getEventProcessor() { - return StatsTimeCountHandlerFactory.getInstance(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#waitCursor - * (boolean) - */ - @Override - protected void waitCursor(final boolean waitInd) { - if (treeViewer == null) { - return; - } - - Display display = treeViewer.getControl().getDisplay(); - if (fwaitCursor == null) { - fwaitCursor = new Cursor(display, SWT.CURSOR_WAIT); - } - - // Perform the updates on the UI thread - display.asyncExec(new Runnable() { - public void run() { - Cursor cursor = null; /* indicates default */ - if (waitInd) { - cursor = fwaitCursor; - } - treeViewer.getControl().setCursor(cursor); - } - }); - } - - @Override - public void ModelUpdatePrep(TmfTimeRange timeRange, boolean clearAllData) { - Object input = treeViewer.getInput(); - if (input != null && input instanceof StatisticsTreeNode) { - ((StatisticsTreeNode) input).reset(); - treeViewer.getTree().getDisplay().asyncExec(new Runnable() { - // @Override - public void run() { - treeViewer.refresh(); - } - }); - } } - @Override - public void modelInputChanged(ILttngSyntEventRequest request, boolean complete) { + @TmfSignalHandler + public void processingCompleted(RequestCompletedSignal signal) { treeViewer.getTree().getDisplay().asyncExec(new Runnable() { // @Override public void run() { @@ -536,122 +481,4 @@ public class StatisticsView extends AbsTimeUpdateView { } }); } - - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * modelIncomplete - * (org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest) - */ - @Override - public void modelIncomplete(ILttngSyntEventRequest request) { - Object input = treeViewer.getInput(); - if (input != null && input instanceof StatisticsTreeNode) { - // The data from this experiment is invalid and shall be removed to - // refresh upon next selection - String name = ((StatisticsTreeNode) input).getKey(); - StatisticsTreeRootFactory.removeStatTreeRoot(name); - } - } - - /** - * @param signal - */ - @TmfSignalHandler - public void experimentSelected(TmfExperimentSelectedSignal signal) { - if (signal != null) { - TmfExperiment experiment = signal.getExperiment(); - String experimentName = experiment.getName(); - - if (StatisticsTreeRootFactory.containsTreeRoot(experimentName)) { - // The experiment root is already present - StatisticsTreeNode experimentTreeNode = StatisticsTreeRootFactory.getStatTreeRoot(experimentName); - - ITmfTrace[] traces = experiment.getTraces(); - - // check if there is partial data loaded in the experiment - int numTraces = experiment.getTraces().length; - int numNodeTraces = experimentTreeNode.getNbChildren(); - - if (numTraces == numNodeTraces) { - boolean same = true; - // Detect if the experiment contains the same traces as when - // previously selected - for (int i = 0; i < numTraces; i++) { - String traceName = traces[i].getName(); - if (!experimentTreeNode.containsChild(traceName)) { - same = false; - break; - } - } - - if (same) { - // no need to reload data, all traces are already loaded - treeViewer.setInput(experimentTreeNode); - return; - } - } - } - - // if the data is not available or has changed, reload it - requestData(experiment); - } - } - - /** - * @param experiment - */ - private void requestData(TmfExperiment experiment) { - if (experiment != null) { - StatisticsTreeNode treeModelRoot = StatisticsTreeRootFactory.getStatTreeRoot(experiment.getName()); - - // if the model has contents, clear to start over - if (treeModelRoot.hasChildren()) { - treeModelRoot.reset(); - } - - // set input to a clean data model - treeViewer.setInput(treeModelRoot); - TmfTimeRange experimentTRange = experiment.getTimeRange(); - - // send the initial request, to start filling up model - dataRequest(experimentTRange, experimentTRange, true); - } else { - TraceDebug.debug("No selected experiment information available"); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel - * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. - * ITmfTimeAnalysisEntry[], long, long, boolean, long, long, - * java.lang.Object) - */ - @Override - protected void displayModel(ITmfTimeAnalysisEntry[] items, long startBoundTime, long endBoundTime, - boolean updateTimeBounds, long startVisibleWindow, long endVisibleWindow, Object source) { - // No applicable to statistics view - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# - * getParamsUpdater() - */ - @Override - protected ParamsUpdater getParamsUpdater() { - // Not applicable to statistics view - return null; - } - - @Override - protected ItemContainer getItemContainer() { - // Not applicable to statistics view - return null; - } } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java index 91a02369b0..57c99b906b 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java @@ -15,13 +15,13 @@ import org.eclipse.linuxtools.lttng.event.LttngEvent; import org.eclipse.linuxtools.lttng.state.StateStrings.Events; import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode; import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus; -import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; import org.eclipse.linuxtools.lttng.state.model.LttngProcessState; import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; -import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeRootFactory; +import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeFactory; import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeNode; -abstract class AbstractStatsEventHandler implements ILttngEventProcessor { +abstract class AbstractStatsEventHandler implements IEventProcessing { private Events eventType; public AbstractStatsEventHandler(Events eventType) { @@ -32,9 +32,8 @@ abstract class AbstractStatsEventHandler implements ILttngEventProcessor { /** * @return root of of the tree for this experiment. */ - protected StatisticsTreeNode getStatisticsTree(LttngTraceState trcState) { - String experimentName = trcState.getContext().getExperimentName(); - StatisticsTreeNode tree = StatisticsTreeRootFactory.getStatTreeRoot(experimentName); + protected StatisticsTreeNode getStatisticsTree(LttngEvent trcEvent) { + StatisticsTreeNode tree = StatisticsTreeFactory.getStatisticsTree("Experiment"); return tree; } @@ -43,7 +42,7 @@ abstract class AbstractStatsEventHandler implements ILttngEventProcessor { */ protected String[][] getRelevantPaths(LttngEvent event, LttngTraceState traceState) { - String trace = traceState.getContext().getTraceId(); + String trace = traceState.getInputDataRef().getTraceId(); Long cpu = event.getCpuId(); @@ -83,7 +82,7 @@ abstract class AbstractStatsEventHandler implements ILttngEventProcessor { */ protected String[][] getRelevantEventTypesPaths(LttngEvent event, LttngTraceState traceState) { - String trace = traceState.getContext().getTraceId(); + String trace = traceState.getInputDataRef().getTraceId(); Long cpu = event.getCpuId(); @@ -219,25 +218,5 @@ abstract class AbstractStatsEventHandler implements ILttngEventProcessor { public Events getEventHandleType() { return eventType; } - - protected void stepCount(LttngEvent event, LttngTraceState traceState) { - StatisticsTreeNode root = getStatisticsTree(traceState); - - String[][] paths = getRelevantPaths(event, traceState); - - for (String[] path : paths) { - StatisticsTreeNode node = root.getOrCreateChildFromPath(path); - - increaseNbEvents(node); - } - - String[][] eventTypesPaths = getRelevantEventTypesPaths(event, traceState); - - for (String[] path : eventTypesPaths) { - StatisticsTreeNode node = root.getOrCreateChildFromPath(path); - - increaseNbEvents(node); - } - } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandler.java new file mode 100644 index 0000000000..03d041cc53 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandler.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.state.StateStrings.Events; +import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; +import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeNode; + +class StatsEventCountHandler extends AbstractStatsEventHandler { + + public StatsEventCountHandler(Events eventType) { + super(eventType); + } + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState) + */ + public boolean process(LttngEvent event, LttngTraceState traceState) { + StatisticsTreeNode root = getStatisticsTree(event); + + String[][] paths = getRelevantPaths(event, traceState); + + for (String[] path : paths) { + StatisticsTreeNode node = root.getOrCreateChildFromPath(path); + + increaseNbEvents(node); + } + + String[][] eventTypesPaths = getRelevantEventTypesPaths(event, traceState); + + for (String[] path : eventTypesPaths) { + StatisticsTreeNode node = root.getOrCreateChildFromPath(path); + + increaseNbEvents(node); + } + + return false; + } + +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandlerFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandlerFactory.java new file mode 100644 index 0000000000..bb22bac6f1 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsEventCountHandlerFactory.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor; + +import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; + +/** + * Provide the handlers that will count the number of events and update the + * appropriate tree. + * + * Builds a Map from string event name to a processing handler object, the + * processors implement the same interface to facilitate transparent methods + * call, + * + * The map key STring is the entry point of the raw events, using a hash speeds + * up the resolution of the appropriate processor + * + * @author yann + * + */ +public class StatsEventCountHandlerFactory extends AbsEventProcessorFactory{ + // ======================================================================== + // Data + // ======================================================================== + private static StatsEventCountHandlerFactory instance = null; + + private final IEventProcessing handler = new StatsEventCountHandler(null); + + // ======================================================================== + // Public methods + // ======================================================================= + /** + * The event processors are common to all traces an multiple instances will + * use more memory unnecessarily + * + * @return + */ + public static AbsEventProcessorFactory getInstance() { + if (instance == null) { + instance = new StatsEventCountHandlerFactory(); + } + return instance; + } + + + @Override + public IEventProcessing getAfterProcessor(String eventType) { + return handler; + } + + @Override + public IEventProcessing getBeforeProcessor(String eventType) { + return null; + } + + @Override + public IEventProcessing getfinishProcessor() { + // No finishing processor used + return null; + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java index 0e0b861882..b5e3a7a89e 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java @@ -26,7 +26,7 @@ class StatsModeChangeHandler extends AbstractStatsEventHandler { * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState) */ public boolean process(LttngEvent event, LttngTraceState traceState) { - StatisticsTreeNode root = getStatisticsTree(traceState); + StatisticsTreeNode root = getStatisticsTree(event); String[][] paths = getRelevantPaths(event, traceState); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java index 265b92ef4b..06afafdc91 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java @@ -26,7 +26,7 @@ class StatsModeEndHandler extends AbstractStatsEventHandler { * @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState) */ public boolean process(LttngEvent event, LttngTraceState traceState) { - StatisticsTreeNode root = getStatisticsTree(traceState); + StatisticsTreeNode root = getStatisticsTree(event); String[][] paths = getRelevantPaths(event, traceState); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java index 97236913e2..20c62e494d 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java @@ -16,8 +16,8 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.linuxtools.lttng.state.StateStrings; -import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventToHandlerResolver; -import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; +import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; /** * Provide the handlers that will count the CPU Time, Cumulative CPU Time and @@ -33,12 +33,12 @@ import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; * @author alvaro * */ -public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver { +public class StatsTimeCountHandlerFactory extends AbsEventProcessorFactory{ // ======================================================================== // Data // ======================================================================= - private final Map eventNametoBeforeProcessor = new HashMap(); - ILttngEventProcessor afterhandler; + private final Map eventNametoBeforeProcessor = new HashMap(); + private final Map eventNametoAfterProcessor = new HashMap(); private static StatsTimeCountHandlerFactory instance = null; private StatsTimeCountHandlers instantiateHandler = new StatsTimeCountHandlers(); @@ -46,7 +46,6 @@ public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver { // Constructors // ======================================================================= private StatsTimeCountHandlerFactory() { - super(); //create one instance of each individual event handler and add the instance to the map eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_ENTRY .getInName(), instantiateHandler.getSyscallEntryBeforeHandler()); @@ -93,7 +92,8 @@ public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver { eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE .getInName(), instantiateHandler.getSchedChangeBeforeHandler()); - afterhandler = instantiateHandler.getAfterHandler(); + eventNametoAfterProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE + .getInName(), instantiateHandler.getSchedChangeAfterHandler()); } @@ -106,7 +106,7 @@ public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver { * * @return */ - public static AbsEventToHandlerResolver getInstance() { + public static AbsEventProcessorFactory getInstance() { if (instance == null) { instance = new StatsTimeCountHandlerFactory(); } @@ -115,23 +115,18 @@ public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver { @Override - public ILttngEventProcessor getAfterProcessor(String eventType) { - return afterhandler; + public IEventProcessing getAfterProcessor(String eventType) { + return eventNametoAfterProcessor.get(eventType); } @Override - public ILttngEventProcessor getBeforeProcessor(String eventType) { + public IEventProcessing getBeforeProcessor(String eventType) { return eventNametoBeforeProcessor.get(eventType); } @Override - public ILttngEventProcessor getfinishProcessor() { + public IEventProcessing getfinishProcessor() { // No finishing processor used return null; } - - @Override - public ILttngEventProcessor getStateUpdaterProcessor(String eventType) { - return null; - } } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java index 8890829489..f3eade8766 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java @@ -11,11 +11,8 @@ *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor; -import org.eclipse.linuxtools.lttng.event.LttngEvent; -import org.eclipse.linuxtools.lttng.state.StateStrings; import org.eclipse.linuxtools.lttng.state.StateStrings.Events; -import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; -import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; +import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; /** * Process the system call entry event @@ -30,7 +27,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getSyscallEntryBeforeHandler() { + final IEventProcessing getSyscallEntryBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeChangeHandler(Events.LTT_EVENT_SYSCALL_ENTRY); return handler; } @@ -40,7 +37,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getsySyscallExitBeforeHandler() { + final IEventProcessing getsySyscallExitBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeEndHandler(Events.LTT_EVENT_SYSCALL_EXIT); return handler; } @@ -50,7 +47,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getTrapEntryBeforeHandler() { + final IEventProcessing getTrapEntryBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeChangeHandler(Events.LTT_EVENT_TRAP_ENTRY); return handler; } @@ -60,7 +57,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getTrapExitBeforeHandler() { + final IEventProcessing getTrapExitBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeEndHandler(Events.LTT_EVENT_TRAP_EXIT); return handler; } @@ -70,7 +67,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getIrqEntryBeforeHandler() { + final IEventProcessing getIrqEntryBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeChangeHandler(Events.LTT_EVENT_IRQ_ENTRY); return handler; } @@ -80,7 +77,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getIrqExitBeforeHandler() { + final IEventProcessing getIrqExitBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeEndHandler(Events.LTT_EVENT_IRQ_EXIT); return handler; } @@ -90,7 +87,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getSoftIrqEntryBeforeHandler() { + final IEventProcessing getSoftIrqEntryBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeChangeHandler(Events.LTT_EVENT_SOFT_IRQ_ENTRY); return handler; } @@ -100,7 +97,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getSoftIrqExitBeforeHandler() { + final IEventProcessing getSoftIrqExitBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeEndHandler(Events.LTT_EVENT_SOFT_IRQ_EXIT); return handler; } @@ -115,7 +112,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getFunctionEntryBeforeHandler() { + final IEventProcessing getFunctionEntryBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeChangeHandler(Events.LTT_EVENT_FUNCTION_ENTRY); return handler; } @@ -124,7 +121,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getFunctionExitBeforeHandler() { + final IEventProcessing getFunctionExitBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeEndHandler(Events.LTT_EVENT_FUNCTION_EXIT); return handler; } @@ -139,7 +136,7 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getSchedChangeBeforeHandler() { + final IEventProcessing getSchedChangeBeforeHandler() { AbstractStatsEventHandler handler = new StatsModeChangeHandler(Events.LTT_EVENT_SCHED_SCHEDULE); return handler; } @@ -154,25 +151,8 @@ class StatsTimeCountHandlers { * * @return */ - final ILttngEventProcessor getAfterHandler() { - AbstractStatsEventHandler handler = new StatsModeChangeHandler(null) { - int sched_hash = StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName().hashCode(); - @Override - public boolean process(LttngEvent event, LttngTraceState traceState) { - // Step the event counter for any after event - stepCount(event, traceState); - - int eventNameHash = event.getMarkerName().hashCode(); - // specific processing for after sched schedule - if (sched_hash == eventNameHash - && event.getMarkerName().equals(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName())) { - return super.process(event, traceState); - } - - return false; - } - }; - + final IEventProcessing getSchedChangeAfterHandler() { + AbstractStatsEventHandler handler = new StatsModeChangeHandler(Events.LTT_EVENT_SCHED_SCHEDULE); return handler; } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeFactory.java new file mode 100644 index 0000000000..1b986d5385 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeFactory.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.statistics.model; + +import java.util.HashMap; +import java.util.Map; + +public class StatisticsTreeFactory { + // ======================================================================== + // Data + // ======================================================================= + + private static final Map instanceBook = new HashMap(); + + // ======================================================================== + // Methods + // ======================================================================= + + /** + * Provide a statisticsTree instance per trace + * + * @return + */ + public static StatisticsTreeNode getStatisticsTree(String traceUniqueId) { + if (traceUniqueId == null) { + return null; + } + + if (instanceBook.containsKey(traceUniqueId)) { + return instanceBook.get(traceUniqueId); + } + + StatisticsTreeNode tree = new StatisticsTreeNode(traceUniqueId, new Statistics()); + + instanceBook.put(traceUniqueId, tree); + + return tree; + } + + /** + * Remove previously registered statistics tree. + * @param traceUniqueId + */ + public static void removeStatisticsTree(String traceUniqueId) { + if (traceUniqueId != null && instanceBook.containsKey(traceUniqueId)) { + instanceBook.remove(traceUniqueId); + } + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java index 172e05e3ad..2a10f5546c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java @@ -35,20 +35,21 @@ public class StatisticsTreeNode { private AbstractMap children; /* - * Construct a node with the given key + * Construct a node with the given key and value. */ - public StatisticsTreeNode(String key) { - this(null, key); + public StatisticsTreeNode(String key, Statistics value) { + this(null, key, value); } /* * Construct a node with the given parent, key and value. */ - public StatisticsTreeNode(StatisticsTreeNode parent, String key) { + public StatisticsTreeNode(StatisticsTreeNode parent, String key, + Statistics value) { super(); this.parent = parent; this.key = key; - this.value = new Statistics(); + this.value = value; this.children = new HashMap(); } @@ -78,8 +79,8 @@ public class StatisticsTreeNode { * * @return children node that was created. */ - public StatisticsTreeNode addChild(String key) { - StatisticsTreeNode created = new StatisticsTreeNode(this, key); + public StatisticsTreeNode addChild(String key, Statistics value) { + StatisticsTreeNode created = new StatisticsTreeNode(this, key, value); this.children.put(key, created); @@ -129,7 +130,8 @@ public class StatisticsTreeNode { StatisticsTreeNode current = this; for (String key : path) { if (!current.children.containsKey(key)) { - current.children.put(key, new StatisticsTreeNode(current, key)); + current.children.put(key, new StatisticsTreeNode(current, key, + new Statistics())); } // previous = current; @@ -150,7 +152,8 @@ public class StatisticsTreeNode { StatisticsTreeNode current = this; for (String key : path.split("/")) { if (!current.children.containsKey(key)) { - current.children.put(key, new StatisticsTreeNode(previous, key)); + current.children.put(key, new StatisticsTreeNode(previous, key, + new Statistics())); } previous = current; @@ -193,23 +196,4 @@ public class StatisticsTreeNode { public static String unescapeKey(String key) { return key.replace("%2F", "/").replace("%25", "%"); } - - /** - * Start from creation time i.e. keep key and parent but new statistics and - * no children - */ - public void reset() { - this.value = new Statistics(); - this.children = new HashMap(); - } - - /** - * - * @param key - * @return true: if child with given key is present, false: if no child - * exists with given key name - */ - public boolean containsChild(String key) { - return children.containsKey(key); - } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/SpinnerGroup.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/SpinnerGroup.java index be2a5e7622..ff99f154a7 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/SpinnerGroup.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/SpinnerGroup.java @@ -66,7 +66,6 @@ public class SpinnerGroup { private int currentSeconds; private int currentNanosec; - @SuppressWarnings("unused") private TimeFrameView fOwner; /** @@ -138,7 +137,7 @@ public class SpinnerGroup { long newCurrentTime = ((long) currentSeconds) * NS_PER_SECOND + currentNanosec; TmfTimestamp ts = new TmfTimestamp(newCurrentTime, NS_SCALING_FACTOR, 0); currentTime = ts; -// fOwner.synchTimeFrameWidgets(this); + fOwner.synchTimeFrameWidgets(this); } // ==================================================================== @@ -158,7 +157,7 @@ public class SpinnerGroup { } public TmfTimestamp getSpan() { - TmfTimestamp span = new TmfTimestamp(startTime.getAdjustment(endTime, NS_SCALING_FACTOR), NS_SCALING_FACTOR, 0); + TmfTimestamp span = new TmfTimestamp(startTime.getAdjustment(endTime), NS_SCALING_FACTOR, 0); return span; } @@ -217,7 +216,7 @@ public class SpinnerGroup { if (range != null) { // Extract the time range TmfTimestamp start = range.getStartTime(); - TmfTimestamp end = range.getEndTime(); + TmfTimestamp end = range.getEndTime(); // Assume start time is OK setStartTime(start); @@ -305,10 +304,8 @@ public class SpinnerGroup { // Refresh the spinners (value, range, increments, ...) // To ensure that the spinners are properly set, the range has to be > 0 -// seconds.setValues(currentSeconds, startSeconds - 1, endSeconds + 1, 0, 1, 10); -// nanosec.setValues(currentNanosec, startns - 1, endns + 1, 0, 1, 1000000); - seconds.setValues(currentSeconds, startSeconds, endSeconds, 0, 1, 10); - nanosec.setValues(currentNanosec, startns, endns, 0, 100000, 10000000); + seconds.setValues(currentSeconds, startSeconds - 1, endSeconds + 1, 0, 1, 10); + nanosec.setValues(currentNanosec, startns - 1, endns + 1, 0, 1, 1000000); // If start == end (i.e. no range), disable the spinner // (if start == end, the spinner widget range is set to [0..100] by default) diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java index 1ee55437bd..fb0a72ef23 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 2010 Ericsson + * Copyright (c) 2009 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -12,15 +12,13 @@ package org.eclipse.linuxtools.lttng.ui.views.timeframe; -import org.eclipse.linuxtools.lttng.event.LttngEvent; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal; -import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; +import org.eclipse.linuxtools.tmf.trace.TmfExperiment; +import org.eclipse.linuxtools.tmf.trace.TmfExperimentSelectedSignal; +import org.eclipse.linuxtools.tmf.trace.TmfExperimentUpdatedSignal; import org.eclipse.linuxtools.tmf.ui.views.TmfView; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -73,9 +71,9 @@ public class TimeFrameView extends TmfView { private byte fScale = 0; // Labels - private static final String START_TIME_LABEL = "Window Start Time"; - private static final String END_TIME_LABEL = "Window End Time"; - private static final String TIME_RANGE_LABEL = "Window Range"; + private static final String START_TIME_LABEL = "Start Time"; + private static final String END_TIME_LABEL = "End Time"; + private static final String TIME_RANGE_LABEL = "Interval"; private static final String CURRENT_TIME_LABEL = "Current Time"; private static final int SLIDER_RANGE = 10000; @@ -89,17 +87,13 @@ public class TimeFrameView extends TmfView { private Slider fSlider; // The current experiment - TmfExperiment fExperiment = null; - // notify external listeners may not be needed if the update originated - // externally - private boolean fupdateExternalListeners = true; - + TmfExperiment fExperiment = null; /** * Constructor */ public TimeFrameView() { - super("TimeFrameView"); + super(); } /* (non-Javadoc) @@ -137,7 +131,6 @@ public class TimeFrameView extends TmfView { * One of the spinners has been updated. Synchronize the other widgets. */ public void synchTimeFrameWidgets(SpinnerGroup trigger) { - boolean trangeUpdated = false; // Collect the data TmfTimestamp startTime = fStartGroup.getCurrentTime(); @@ -149,7 +142,6 @@ public class TimeFrameView extends TmfView { if (trigger == fStartGroup) { if (startTime.compareTo(endTime, false) > 0) { endTime = startTime; - trangeUpdated = true; } } @@ -157,7 +149,6 @@ public class TimeFrameView extends TmfView { if (trigger == fEndGroup) { if (endTime.compareTo(startTime, false) < 0) { startTime = endTime; - trangeUpdated = true; } } @@ -170,13 +161,11 @@ public class TimeFrameView extends TmfView { ts = fTraceEndTime.synchronize(fTraceEndTime.getValue(), startTime.getScale()); } endTime = ts; - trangeUpdated = true; } // Compute the new time range TmfTimeRange subrange = new TmfTimeRange(startTime, endTime); - byte scale = startTime.getScale(); - TmfTimestamp interval = new TmfTimestamp(startTime.getAdjustment(endTime, scale), scale, 0); + TmfTimestamp interval = new TmfTimestamp(startTime.getAdjustment(endTime), startTime.getScale(), 0); // Update the spinner groups fStartGroup.setContent(fTraceTimeRange, startTime); @@ -185,18 +174,11 @@ public class TimeFrameView extends TmfView { fCurrentGroup.setContent(subrange, currentTime); updateSlider(subrange, currentTime); - // Notify other views, only if the update originated from this view - if (fupdateExternalListeners) { - if (!fCurrentTime.equals(currentTime)) { - fCurrentTime = currentTime; - broadcast(new TmfTimeSynchSignal(this, currentTime)); - } - // Notify the views if the time range has been impacted - if (trangeUpdated) { - TmfTimeRange trange = new TmfTimeRange(startTime, endTime); - broadcast(new TmfRangeSynchSignal(this, trange, currentTime)); - } + // Notify other views + if (!fCurrentTime.equals(currentTime)) { + fCurrentTime = currentTime; + broadcastSignal(new TmfTimeSynchSignal(this, currentTime)); } } @@ -240,9 +222,8 @@ public class TimeFrameView extends TmfView { private void updateSlider(TmfTimeRange range, TmfTimestamp timestamp) { // Determine the new relative position - byte scale = range.getEndTime().getScale(); - long total = range.getStartTime().getAdjustment(range.getEndTime(), scale); - long relative = range.getStartTime().getAdjustment(timestamp, scale); + long total = range.getStartTime().getAdjustment(range.getEndTime()); + long relative = range.getStartTime().getAdjustment(timestamp); // Set the slider value final long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0; @@ -270,15 +251,14 @@ public class TimeFrameView extends TmfView { // TMF Signal Handling // ======================================================================== - /** + /** * @param signal */ - @SuppressWarnings("unchecked") @TmfSignalHandler - public void experimentSelected(TmfExperimentSelectedSignal signal) { + public void experimentSelected(TmfExperimentSelectedSignal signal) { // Update the trace reference - fExperiment = (TmfExperiment) signal.getExperiment(); + fExperiment = signal.getExperiment(); // Update the time frame fTraceTimeRange = fExperiment.getTimeRange(); @@ -293,11 +273,9 @@ public class TimeFrameView extends TmfView { fCurrentTime = fTraceStartTime; - TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0); + TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime), fScale, 0); fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta); -// fRangeGroup.setContent(fTraceSpan, delta); - TmfTimestamp start = new TmfTimestamp(1, (byte) -1, 0); - fRangeGroup.setContent(fTraceSpan, start); + fRangeGroup.setContent(fTraceSpan, delta); } /** @@ -317,51 +295,17 @@ public class TimeFrameView extends TmfView { fEndGroup.setContent(fTraceTimeRange, fTraceEndTime); fCurrentGroup.setContent(fTraceTimeRange, fCurrentGroup.getCurrentTime()); - TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0); + TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime), fScale, 0); fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta); fRangeGroup.setContent(fTraceSpan, delta); } - /** - * @param signal - */ - @TmfSignalHandler - public void currentTimeRangeUpdated(TmfRangeSynchSignal signal) { - if (signal.getSource() != this) { - // Update the time frame - TmfTimeRange selTimeRange = signal.getCurrentRange(); - TmfTimestamp selStart = selTimeRange.getStartTime().synchronize(0, - fScale); - TmfTimestamp selEnd = selTimeRange.getEndTime().synchronize(0, - fScale); - - fupdateExternalListeners = false; - // Update the widgets and prevent broadcast notifications to - // the views which have been notified already. - { - fStartGroup.setContent(fTraceTimeRange, selStart); - fEndGroup.setContent(fTraceTimeRange, selEnd); - - TmfTimestamp delta = new TmfTimestamp(selStart.getAdjustment( - selEnd, fScale), fScale, 0); - - fRangeGroup.setContent(fTraceSpan, delta); - } - - // restore the external notification flag - fupdateExternalListeners = true; - - } - } - /** * @param signal */ @TmfSignalHandler public void currentTimeUpdated(TmfTimeSynchSignal signal) { if (signal.getSource() != this) { - // prevent loop to external notifications - fupdateExternalListeners = false; fCurrentTime = signal.getCurrentTime().synchronize(0, fStartGroup.getCurrentTime().getScale()); if (fStartGroup.getCurrentTime().compareTo(fCurrentTime, false) > 0) { fStartGroup.setContent(new TmfTimeRange(fCurrentTime, fEndGroup.getCurrentTime()), fCurrentTime); @@ -371,9 +315,6 @@ public class TimeFrameView extends TmfView { } fCurrentGroup.setContent(null, fCurrentTime); updateSlider(fCurrentGroup.getTimeRange(), fCurrentTime); - - // Enable external notifications - fupdateExternalListeners = true; } } diff --git a/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java b/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java new file mode 100644 index 0000000000..6902bbdc12 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2009 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 (fchouinard@gmail.com) - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.lttng.stubs; + +import java.io.IOException; + +import org.eclipse.linuxtools.tmf.event.TmfEvent; +import org.eclipse.linuxtools.tmf.trace.ITmfEventParser; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; + +/** + * TmfEventParserStub + *

+ * TODO: Implement me. Please. + */ +public class LTTngEventParserStub implements ITmfEventParser { + + public TmfEvent parseNextEvent(ITmfTrace stream, TmfTraceContext context) + throws IOException { + // TODO Auto-generated method stub + return null; + } + +// // ======================================================================== +// // Attributes +// // ======================================================================== +// +// private final int NB_FORMATS = 10; +// private final TmfEventFormat[] fFormats; +// +// // ======================================================================== +// // Constructors +// // ======================================================================== +// +// public LTTngEventParserStub() { +// fFormats = new TmfEventFormat[NB_FORMATS]; +// for (int i = 0; i < NB_FORMATS; i++) { +// Vector format = new Vector(); +// for (int j = 1; j <= i; j++) { +// format.add(new String("Fmt-" + i + "-Fld-" + j)); +// } +// String[] fields = new String[i]; +// fFormats[i] = new TmfEventFormat(format.toArray(fields)); +// } +// } +// +// // ======================================================================== +// // Accessors +// // ======================================================================== +// +// // ======================================================================== +// // Operators +// // ======================================================================== +// +// /* (non-Javadoc) +// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent() +// */ +// static final String typePrefix = "Type-"; +// public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException { +// +// if (! (eventStream instanceof LTTngTraceStub)) { +// return null; +// } +// +// // Highly inefficient... +// RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream(); +// String name = eventStream.getName(); +// name = name.substring(name.lastIndexOf('/') + 1); +// +// synchronized(stream) { +// long location = 0; +// if (context != null) +// location = (Long) (context.getLocation()); +// stream.seek(location); +// +// try { +// // Read the individual fields +// long ts = stream.readLong(); +// String source = stream.readUTF(); +// String type = stream.readUTF(); +// @SuppressWarnings("unused") +// int reference = stream.readInt(); +// +// // Read the event parts +// int typeIndex = Integer.parseInt(type.substring(typePrefix.length())); +// String[] fields = new String[typeIndex]; +// for (int i = 0; i < typeIndex; i++) { +// fields[i] = stream.readUTF(); +// } +// +// // Format the content from the individual fields +// String content = "["; +// if (typeIndex > 0) { +// content += fields[0]; +// } +// for (int i = 1; i < typeIndex; i++) { +// content += ", " + fields[i]; +// } +// content += "]"; +// +// // Update the context +// context.setLocation(stream.getFilePointer()); +// context.incrIndex(); +// try { +// long ts2 = stream.readLong(); +// context.setTimestamp(new LTTngTimestampStub(ts2)); +// } catch (EOFException e) { +// context.setTimestamp(null); +// } +// +// // Create the event +// TmfEvent event = new TmfEvent( +// new LTTngTimestampStub(ts), +// new TmfEventSource(source), +// new TmfEventType(type, fFormats[typeIndex]), +// new TmfEventContent(content, fFormats[typeIndex]), +// new TmfEventReference(name)); +// +// return event; +// +// } catch (EOFException e) { +// context.setTimestamp(null); +// } +// } +// return null; +// } + +} diff --git a/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTimestampStub.java b/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTimestampStub.java new file mode 100644 index 0000000000..77cdee6a59 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTimestampStub.java @@ -0,0 +1,52 @@ +/** + * + */ +package org.eclipse.linuxtools.lttng.stubs; + +import org.eclipse.linuxtools.tmf.event.TmfTimestamp; + +/** + * @author francois + * + */ +public class LTTngTimestampStub extends TmfTimestamp { + + /** + * + */ + private static final long serialVersionUID = 216576768443708259L; + + /** + * @param value + * @param scale + * @param precision + */ + public LTTngTimestampStub(long value) { + super(value, (byte) -3, 0); // millisecs + } + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp#toString() + */ + @Override + public String toString() { + + // If we are dealing with units of seconds (or higher), + // use the plain formatter + if (fScale >= 0) { + Double value = fValue * Math.pow(10, fScale); + return value.toString(); + } + + // Define a format string + String format = String.format("%%1d.%%0%dd", -fScale); + + // And format the timestamp value + double scale = Math.pow(10, fScale); + long seconds = (long) (fValue * scale); + long fracts = fValue - (long) ((double) seconds / scale); + String result = String.format(format, seconds, fracts); + + return result; + } +} diff --git a/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java b/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java new file mode 100644 index 0000000000..e9cf908507 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2009 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 (fchouinard@gmail.com) - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.lttng.stubs; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + +import org.eclipse.linuxtools.tmf.event.TmfEvent; +import org.eclipse.linuxtools.tmf.trace.ITmfEventParser; +import org.eclipse.linuxtools.tmf.trace.TmfTrace; +import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; + +/** + * LTTngTraceStub + *

+ * Dummy test trace. Use in conjunction with LTTngEventParserStub. + */ +public class LTTngTraceStub extends TmfTrace { + + // ======================================================================== + // Attributes + // ======================================================================== + + // The actual stream + private final RandomAccessFile fTrace; + + // The associated event parser + private final ITmfEventParser fParser; + + // ======================================================================== + // Constructors + // ======================================================================== + + /** + * @param filename + * @param parser + * @throws FileNotFoundException + */ + public LTTngTraceStub(String filename) throws FileNotFoundException { + this(filename, DEFAULT_CACHE_SIZE); + } + + /** + * @param filename + * @param parser + * @param cacheSize + * @throws FileNotFoundException + */ + public LTTngTraceStub(String filename, int cacheSize) throws FileNotFoundException { + super(filename, cacheSize, false); + fTrace = new RandomAccessFile(filename, "r"); + fParser = new LTTngEventParserStub(); + indexStream(); + } + + // ======================================================================== + // Accessors + // ======================================================================== + + public RandomAccessFile getStream() { + return fTrace; + } + + // ======================================================================== + // Operators + // ======================================================================== + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object) + */ + public TmfTraceContext seekLocation(Object location) { + TmfTraceContext context = null; + try { + synchronized(fTrace) { + fTrace.seek((location != null) ? (Long) location : 0); + context = new TmfTraceContext(getCurrentLocation(), null, 0); + TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), null, 0); + TmfEvent event = parseEvent(context2); + context.setTimestamp(event.getTimestamp()); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return context; + } + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation() + */ + @Override + public Object getCurrentLocation() { + try { + return new Long(fTrace.getFilePointer()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent() + */ + @Override + public TmfEvent parseEvent(TmfTraceContext context) { + try { + // paserNextEvent updates the context + TmfEvent event = fParser.parseNextEvent(this, context); +// if (event != null) { +// context.setTimestamp(event.getTimestamp()); +// } + return event; + } + catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "[LTTngTraceStub]"; + } + +// // ======================================================================== +// // Helper functions +// // ======================================================================== +// +// /* (non-Javadoc) +// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes() +// */ +// public Map getAttributes() { +// // TODO Auto-generated method stub +// return null; +// } + +} -- 2.34.1