From 12c155f58b96b570d98927ffcf3e49ac4b0176ec Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Sat, 15 Oct 2011 13:44:50 -0400 Subject: [PATCH] Contribute CNF based TMF project handling --- .../resource/LTTngStateResourceTest.java | 2 +- .../tests/trace/LTTngExperimentTest.java | 11 +- .../lttng/tests/headless/TmfTraceTest.java | 3 +- .../META-INF/MANIFEST.MF | 1 + .../lttng/stubs/LTTngEventParserStub.java | 2 +- .../lttng/stubs/LTTngTraceStub.java | 4 +- .../META-INF/MANIFEST.MF | 3 +- .../build.properties | 2 +- .../plugin.properties | 3 + org.eclipse.linuxtools.lttng.ui/plugin.xml | 22 +- .../dialogs/ImportTraceDialog.java | 2 +- .../tracecontrol/dialogs/NewTraceDialog.java | 2 +- .../lttng/ui/views/PerspectiveFactory.java | 60 +- .../lttng/ui/views/control/ControlView.java | 49 +- .../lttng/ui/views/events/EventsView.java | 2 +- .../ui/views/histogram/HistogramView.java | 24 +- .../ui/views/project/LTTngProjectNature.java | 64 - .../lttng/ui/views/project/ProjectView.java | 143 +- .../views/project/dialogs/AddTraceWizard.java | 1 + .../project/dialogs/AddTraceWizardPage.java | 1 + .../dialogs/DialogTraceContentProvider.java | 1 + .../dialogs/DialogTraceLabelProvider.java | 1 + .../project/dialogs/ImportTraceWizard.java | 1 + .../dialogs/ImportTraceWizardPage.java | 3 +- .../project/dialogs/NewExperimentDialog.java | 1 + .../project/dialogs/NewProjectWizard.java | 4 +- .../dialogs/TraceLibraryPathPropertyPage.java | 2 +- .../views/project/model/LTTngProjectNode.java | 2 +- .../ui/views/timeframe/TimeFrameView.java | 395 ++- .../META-INF/MANIFEST.MF | 2 +- org.eclipse.linuxtools.lttng/build.properties | 2 +- .../linuxtools/lttng/LTTngProjectNature.java | 26 + .../linuxtools/lttng}/TraceHelper.java | 40 +- .../linuxtools/lttng/event/LttngEvent.java | 147 +- .../experiment/StateExperimentManager.java | 878 ++++--- .../state/experiment/StateManagerFactory.java | 245 +- .../state/resource/ILttngStateContext.java | 2 +- .../lttng/state/trace/IStateTraceManager.java | 2 +- .../lttng/trace/LTTngExperiment.java | 15 +- .../lttng/trace/LTTngTextTrace.java | 7 +- .../linuxtools/lttng/trace/LTTngTrace.java | 2301 +++++++++-------- .../META-INF/MANIFEST.MF | 5 +- .../linuxtools/tmf/trace/TmfTraceStub.java | 7 +- .../META-INF/MANIFEST.MF | 3 +- .../plugin.properties | 4 +- .../META-INF/MANIFEST.MF | 13 +- .../icons/dlcl16/open.gif | Bin 0 -> 223 bytes .../icons/dlcl16/refresh.gif | Bin 0 -> 247 bytes .../icons/dlcl16/rename.gif | Bin 0 -> 211 bytes .../icons/dlcl16/set_trace_type.gif | Bin 0 -> 337 bytes .../icons/dtool16/import.gif | Bin 0 -> 143 bytes .../icons/dtool16/new.gif | Bin 0 -> 354 bytes .../icons/elcl16/new_tracing_prj.gif | Bin 607 -> 628 bytes .../icons/elcl16/open.gif | Bin 0 -> 359 bytes .../icons/elcl16/refresh.gif | Bin 0 -> 368 bytes .../icons/elcl16/rename.gif | Bin 0 -> 346 bytes .../icons/elcl16/set_trace_type.gif | Bin 0 -> 346 bytes .../icons/etool16/import.gif | Bin 0 -> 327 bytes .../icons/etool16/new.gif | Bin 0 -> 612 bytes .../icons/ovr16/link_ovr.gif | Bin 0 -> 169 bytes .../icons/ovr16/trace_type_ovr.gif | Bin 0 -> 76 bytes .../icons/wizban/trace_import_wiz.png | Bin 0 -> 6650 bytes .../plugin.properties | 150 +- org.eclipse.linuxtools.tmf.ui/plugin.xml | 851 ++++-- .../linuxtools/tmf/ui/TmfUiPlugin.java | 44 +- .../ui/dialogs/ManageCustomParsersDialog.java | 61 +- .../tmf/ui/editors/ITmfTraceEditor.java | 2 +- .../tmf/ui/editors/TmfEventsEditor.java | 119 +- .../linuxtools/tmf/ui/internal/Messages.java | 7 - .../tmf/ui/internal/messages.properties | 8 - .../tmf/ui/parsers/IParserProvider.java | 6 +- .../parsers/custom/CustomParserProvider.java | 6 +- .../tmf/ui/parsers/custom/CustomTxtTrace.java | 3 +- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 3 +- .../CustomTxtParserInputWizardPage.java | 2 +- .../CustomTxtParserOutputWizardPage.java | 4 +- .../wizards/CustomTxtParserWizard.java | 2 +- .../CustomXmlParserInputWizardPage.java | 2 +- .../CustomXmlParserOutputWizardPage.java | 4 +- .../wizards/CustomXmlParserWizard.java | 2 +- .../handlers/CopyExperimentHandler.java | 88 + .../ui/project/handlers/CopyTraceHandler.java | 89 + .../handlers/DeleteExperimentHandler.java | 85 + .../project/handlers/DeleteTraceHandler.java | 146 ++ .../project/handlers/ImportTraceHandler.java | 81 + .../tmf/ui/project/handlers/Messages.java | 41 + .../handlers/NewExperimentHandler.java | 70 + .../handlers/OpenExperimentHandler.java | 128 + .../ui/project/handlers/OpenTraceHandler.java | 157 ++ .../ui/project/handlers/PropertyTester.java | 36 + .../ui/project/handlers/RefreshHandler.java | 76 + .../handlers/RenameExperimentHandler.java | 86 + .../project/handlers/RenameTraceHandler.java | 181 ++ .../SelectTraceTypeContributionItem.java | 124 + .../handlers/SelectTraceTypeHandler.java | 185 ++ .../project/handlers/SelectTracesHandler.java | 97 + .../ui/project/handlers/messages.properties | 16 + .../model/ITmfProjectModelElement.java | 49 + .../project/model/TmfExperimentElement.java | 138 + .../ui/project/model/TmfExperimentFolder.java | 82 + .../model/TmfNavigatorContentProvider.java | 367 +++ .../model/TmfNavigatorLabelProvider.java | 167 ++ .../ui/project/model/TmfProjectElement.java | 110 + .../project/model/TmfProjectModelElement.java | 136 + .../ui/project/model/TmfProjectRegistry.java | 37 + .../tmf/ui/project/model/TmfTraceElement.java | 290 +++ .../tmf/ui/project/model/TmfTraceFolder.java | 146 ++ .../model/TraceFolderContentProvider.java | 54 + .../model/TraceFolderLabelProvider.java | 44 + .../project/wizards/CopyExperimentDialog.java | 223 ++ .../ui/project/wizards/CopyTraceDialog.java | 225 ++ .../ui/project/wizards/ImportTraceWizard.java | 92 + .../wizards/ImportTraceWizardPage.java | 839 ++++++ .../tmf/ui/project/wizards/Messages.java | 77 + .../project/wizards/NewExperimentDialog.java | 213 ++ .../wizards}/NewProjectMainWizardPage.java | 2 +- .../wizards}/NewProjectWizard.java | 58 +- .../wizards/RenameExperimentDialog.java | 223 ++ .../ui/project/wizards/RenameTraceDialog.java | 230 ++ .../project/wizards/SelectTracesWizard.java | 66 + .../wizards/SelectTracesWizardPage.java | 217 ++ .../ui/project/wizards/messages.properties | 57 + .../events/ITmfEventsFilterListener.java | 4 +- .../tmf/ui/viewers/events/TmfEventsTable.java | 2052 ++++++++------- .../ui/views/TracingPerspectiveFactory.java | 96 + .../ui/views/{ => events}/TmfEventsView.java | 3 +- .../tmf/ui/views/project/ProjectView.java | 404 --- .../views/project/dialogs/AddTraceWizard.java | 107 - .../project/dialogs/AddTraceWizardPage.java | 85 - .../dialogs/DialogTraceContentProvider.java | 54 - .../dialogs/DialogTraceLabelProvider.java | 52 - .../project/dialogs/IDEWorkbenchMessages.java | 16 - .../project/dialogs/ImportTraceWizard.java | 90 - .../dialogs/ImportTraceWizardPage.java | 35 - .../project/dialogs/NewExperimentDialog.java | 335 --- .../project/handlers/CloseProjectHandler.java | 75 - .../handlers/DeleteExperimentHandler.java | 85 - .../handlers/DeleteProjectHandler.java | 84 - .../project/handlers/DeleteTraceHandler.java | 101 - .../project/handlers/ImportTraceHandler.java | 103 - .../handlers/NewExperimentHandler.java | 97 - .../project/handlers/NewProjectHandler.java | 97 - .../handlers/OpenExperimentHandler.java | 79 - .../project/handlers/OpenProjectHandler.java | 75 - .../project/handlers/OpenTraceHandler.java | 120 - .../project/handlers/RefreshHandler.java | 84 - .../handlers/RenameExperimentHandler.java | 55 - .../handlers/RenameProjectHandler.java | 73 - .../project/handlers/RenameTraceHandler.java | 55 - .../SelectParserContributionItem.java | 106 - .../project/handlers/SelectParserHandler.java | 108 - .../project/handlers/SelectTracesHandler.java | 85 - .../project/model/ITmfProjectTreeNode.java | 41 - .../model/TmfExperimentFolderNode.java | 131 - .../project/model/TmfExperimentNode.java | 126 - .../model/TmfProjectContentProvider.java | 58 - .../model/TmfProjectLabelProvider.java | 179 -- .../views/project/model/TmfProjectNode.java | 204 -- .../views/project/model/TmfProjectRoot.java | 118 - .../project/model/TmfProjectTreeNode.java | 89 - .../project/model/TmfTraceFolderNode.java | 143 - .../ui/views/project/model/TmfTraceNode.java | 77 - .../META-INF/MANIFEST.MF | 3 +- org.eclipse.linuxtools.tmf/build.properties | 4 +- org.eclipse.linuxtools.tmf/plugin.properties | 2 +- org.eclipse.linuxtools.tmf/plugin.xml | 5 + .../org.eclipse.linuxtools.tmf.tracetype.exsd | 211 ++ .../eclipse/linuxtools/tmf/TmfCorePlugin.java | 14 +- .../linuxtools/tmf}/TmfProjectNature.java | 20 +- .../org/eclipse/linuxtools/tmf/Tracer.java | 335 +-- .../tmf/component/TmfComponent.java | 18 +- .../tmf/component/TmfDataProvider.java | 71 +- .../tmf/component/TmfEventProvider.java | 84 +- .../linuxtools/tmf/event/TmfEvent.java | 158 +- .../tmf/experiment/TmfExperiment.java | 121 +- .../tmf/parser/ITmfEventParser.java | 4 +- .../tmf/request/TmfDataRequest.java | 371 +-- .../tmf/signal/TmfTraceUpdatedSignal.java | 6 +- .../linuxtools/tmf/trace/ITmfTrace.java | 104 +- .../linuxtools/tmf/trace/TmfTrace.java | 464 ++-- .../tmf/util/TmfSortedArrayList.java | 36 + 181 files changed, 11348 insertions(+), 8278 deletions(-) delete mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectNature.java create mode 100644 org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/LTTngProjectNature.java rename {org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui => org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng}/TraceHelper.java (78%) create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/dlcl16/open.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/dlcl16/refresh.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/dlcl16/rename.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/dlcl16/set_trace_type.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/dtool16/import.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/dtool16/new.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/elcl16/open.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/elcl16/refresh.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/elcl16/rename.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/elcl16/set_trace_type.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/etool16/import.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/etool16/new.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/ovr16/link_ovr.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/ovr16/trace_type_ovr.gif create mode 100644 org.eclipse.linuxtools.tmf.ui/icons/wizban/trace_import_wiz.png rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{ => parsers}/wizards/CustomTxtParserInputWizardPage.java (97%) rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{ => parsers}/wizards/CustomTxtParserOutputWizardPage.java (96%) rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{ => parsers}/wizards/CustomTxtParserWizard.java (93%) rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{ => parsers}/wizards/CustomXmlParserInputWizardPage.java (97%) rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{ => parsers}/wizards/CustomXmlParserOutputWizardPage.java (96%) rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{ => parsers}/wizards/CustomXmlParserWizard.java (93%) create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyExperimentHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyTraceHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteExperimentHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteTraceHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/ImportTraceHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/Messages.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/NewExperimentHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenExperimentHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenTraceHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/PropertyTester.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RefreshHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameExperimentHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameTraceHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTracesHandler.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/messages.properties create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfProjectModelElement.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentFolder.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectElement.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectModelElement.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceFolder.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderContentProvider.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderLabelProvider.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyTraceDialog.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewExperimentDialog.java rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{views/project/dialogs => project/wizards}/NewProjectMainWizardPage.java (93%) rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/{views/project/dialogs => project/wizards}/NewProjectWizard.java (73%) create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameTraceDialog.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizard.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/messages.properties create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TracingPerspectiveFactory.java rename org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/{ => events}/TmfEventsView.java (97%) delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/ProjectView.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizard.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizardPage.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceContentProvider.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceLabelProvider.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/IDEWorkbenchMessages.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizard.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizardPage.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewExperimentDialog.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserContributionItem.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/ITmfProjectTreeNode.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentFolderNode.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentNode.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectContentProvider.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectLabelProvider.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectNode.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectRoot.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectTreeNode.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceFolderNode.java delete mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceNode.java create mode 100644 org.eclipse.linuxtools.tmf/plugin.xml create mode 100644 org.eclipse.linuxtools.tmf/schema/org.eclipse.linuxtools.tmf.tracetype.exsd rename {org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project => org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf}/TmfProjectNature.java (67%) create mode 100644 org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/util/TmfSortedArrayList.java diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/state/resource/LTTngStateResourceTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/state/resource/LTTngStateResourceTest.java index 8bd67d1322..a16040a5cf 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/state/resource/LTTngStateResourceTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/state/resource/LTTngStateResourceTest.java @@ -105,7 +105,7 @@ public class LTTngStateResourceTest extends TestCase { } @Override - public ITmfTrace getTraceIdRef() { + public ITmfTrace getTraceIdRef() { return null; } diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngExperimentTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngExperimentTest.java index 5e151f210c..81604cd356 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngExperimentTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngExperimentTest.java @@ -21,10 +21,10 @@ import junit.framework.TestCase; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; +import org.eclipse.linuxtools.lttng.event.LttngEvent; import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.trace.LTTngExperiment; import org.eclipse.linuxtools.lttng.trace.LTTngTrace; -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.trace.ITmfTrace; @@ -46,14 +46,15 @@ public class LTTngExperimentTest extends TestCase { private static final TmfTimestamp fStartTime = new TmfTimestamp(13589759412128L, (byte) -9); private static final TmfTimestamp fEndTime = new TmfTimestamp(13589907059242L, (byte) -9); - private static ITmfTrace[] fTraces; - private static LTTngExperiment fExperiment; + private static ITmfTrace[] fTraces; + private static LTTngExperiment fExperiment; // ------------------------------------------------------------------------ // Housekeeping // ------------------------------------------------------------------------ - private synchronized static ITmfTrace[] setupTrace(String path) { + @SuppressWarnings("unchecked") + private synchronized static ITmfTrace[] setupTrace(String path) { if (fTraces == null) { fTraces = new ITmfTrace[1]; try { @@ -74,7 +75,7 @@ public class LTTngExperimentTest extends TestCase { private synchronized static void setupExperiment() { if (fExperiment == null) { - fExperiment = new LTTngExperiment(TmfEvent.class, EXPERIMENT, fTraces, TmfTimestamp.Zero, 1000, true); + fExperiment = new LTTngExperiment(LttngEvent.class, EXPERIMENT, fTraces, TmfTimestamp.Zero, 1000, true); } } diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxxtools/lttng/tests/headless/TmfTraceTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxxtools/lttng/tests/headless/TmfTraceTest.java index 4499038139..50997e037f 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxxtools/lttng/tests/headless/TmfTraceTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxxtools/lttng/tests/headless/TmfTraceTest.java @@ -50,7 +50,8 @@ public class TmfTraceTest extends TmfEventRequest { try { // OUr experiment will contains ONE trace - ITmfTrace[] traces = new ITmfTrace[1]; + @SuppressWarnings("unchecked") + ITmfTrace[] traces = new ITmfTrace[1]; traces[0] = new LTTngTrace(TRACE_PATH); // Create our new experiment fExperiment = new TmfExperiment(LttngEvent.class, "Headless", traces); diff --git a/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF index 0a3ba12b4e..0926f39afe 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF @@ -10,6 +10,7 @@ Require-Bundle: org.junit;bundle-version="3.8.2", org.eclipse.linuxtools.lttng.ui;bundle-version="0.3.2", org.eclipse.linuxtools.tmf.core;bundle-version="0.3.2", org.eclipse.ui;bundle-version="3.7.0", + org.eclipse.core.resources;bundle-version="3.7.0", org.eclipse.core.runtime;bundle-version="3.7.0" Bundle-Localization: plugin Bundle-Activator: org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java index b061836fb3..26e072e929 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java @@ -27,7 +27,7 @@ import org.eclipse.linuxtools.tmf.trace.TmfContext; public class LTTngEventParserStub implements ITmfEventParser { @Override - public TmfEvent parseNextEvent(ITmfTrace stream, TmfContext context) + public TmfEvent parseNextEvent(ITmfTrace stream, TmfContext context) throws IOException { // TODO Auto-generated method stub return null; diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java index 7a3f84e1a3..50019de3e1 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java @@ -70,8 +70,8 @@ public class LTTngTraceStub extends TmfTrace { } @Override - public ITmfTrace createTraceCopy() { - ITmfTrace returnedValue = null; + public ITmfTrace copy() { + ITmfTrace returnedValue = null; try { returnedValue = new LTTngTraceStub(this.getName()); } diff --git a/org.eclipse.linuxtools.lttng.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng.ui/META-INF/MANIFEST.MF index 61e912aa33..b90284081e 100644 --- a/org.eclipse.linuxtools.lttng.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng.ui/META-INF/MANIFEST.MF @@ -17,8 +17,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.7.0", org.eclipse.rse.services;bundle-version="3.2.100", org.eclipse.rse.subsystems.files.core;bundle-version="3.2.100", org.eclipse.rse.ui;bundle-version="3.2.0", - org.eclipse.tm.tcf.core;bundle-version="0.4.0", - org.eclipse.tm.tcf.rse;bundle-version="0.4.0" + org.eclipse.tm.tcf.core;bundle-version="0.4.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/org.eclipse.linuxtools.lttng.ui/build.properties b/org.eclipse.linuxtools.lttng.ui/build.properties index 71f5835411..864e9f8762 100644 --- a/org.eclipse.linuxtools.lttng.ui/build.properties +++ b/org.eclipse.linuxtools.lttng.ui/build.properties @@ -4,5 +4,5 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ icons/,\ - about.html,\ + about.html,\ plugin.properties diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.properties b/org.eclipse.linuxtools.lttng.ui/plugin.properties index 606745d140..5d6ea9dc3e 100644 --- a/org.eclipse.linuxtools.lttng.ui/plugin.properties +++ b/org.eclipse.linuxtools.lttng.ui/plugin.properties @@ -23,6 +23,9 @@ project.propertyPage.tracelibPath = LTTng Trace Library Path action.set.label = LTTng Action Set action.set.description = LTTng Action Set +tracetype.category.lttng= LTTng +tracetype.type.kernel = Kernel Trace + #Commands and Menus commands.project.category.name = LTTng Project Commands commands.project.category.description = LTTng Project Commands diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.xml b/org.eclipse.linuxtools.lttng.ui/plugin.xml index 5d86ab88bc..a72ff974d5 100644 --- a/org.eclipse.linuxtools.lttng.ui/plugin.xml +++ b/org.eclipse.linuxtools.lttng.ui/plugin.xml @@ -112,11 +112,11 @@ + class="org.eclipse.linuxtools.lttng.LTTngProjectNature"> @@ -733,7 +733,7 @@ id="org.eclipse.linuxtools.lttng.ui.propertyPage.libPath" name="%project.propertyPage.tracelibPath"> + value="org.eclipse.linuxtools.lttng.LTTngProjectNature" /> @@ -741,4 +741,20 @@ + + + + + + + diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/ImportTraceDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/ImportTraceDialog.java index bfc5a716c0..4e7f2677b2 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/ImportTraceDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/ImportTraceDialog.java @@ -17,11 +17,11 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.linuxtools.lttng.LTTngProjectNature; import org.eclipse.linuxtools.lttng.tracecontrol.model.TraceResource; import org.eclipse.linuxtools.lttng.tracecontrol.model.TraceResource.TraceState; import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin; import org.eclipse.linuxtools.lttng.ui.tracecontrol.Messages; -import org.eclipse.linuxtools.lttng.ui.views.project.LTTngProjectNature; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/NewTraceDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/NewTraceDialog.java index aa0d78e9bf..517e9f12e2 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/NewTraceDialog.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/tracecontrol/dialogs/NewTraceDialog.java @@ -18,6 +18,7 @@ import java.io.File; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.linuxtools.lttng.LTTngProjectNature; import org.eclipse.linuxtools.lttng.tracecontrol.model.TargetResource; import org.eclipse.linuxtools.lttng.tracecontrol.model.TraceResource; import org.eclipse.linuxtools.lttng.tracecontrol.model.config.TraceConfig; @@ -25,7 +26,6 @@ import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin; import org.eclipse.linuxtools.lttng.ui.tracecontrol.Messages; import org.eclipse.linuxtools.lttng.ui.tracecontrol.TraceControlConstants; import org.eclipse.linuxtools.lttng.ui.tracecontrol.subsystems.TraceSubSystem; -import org.eclipse.linuxtools.lttng.ui.views.project.LTTngProjectNature; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.swt.SWT; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java index 87338138c6..3bcd6a9e7c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java @@ -12,11 +12,9 @@ package org.eclipse.linuxtools.lttng.ui.views; -import org.eclipse.linuxtools.lttng.ui.views.control.ControlView; import org.eclipse.linuxtools.lttng.ui.views.controlflow.ControlFlowView; import org.eclipse.linuxtools.lttng.ui.views.events.EventsView; import org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramView; -import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView; import org.eclipse.linuxtools.lttng.ui.views.resources.ResourcesView; import org.eclipse.linuxtools.lttng.ui.views.statistics.StatisticsView; import org.eclipse.ui.IFolderLayout; @@ -30,28 +28,27 @@ import org.eclipse.ui.IPerspectiveFactory; */ public class PerspectiveFactory implements IPerspectiveFactory { - // Perspective ID + // Perspective ID public static final String ID = "org.eclipse.linuxtools.lttng.ui.perspective"; //$NON-NLS-1$ - + // LTTng views - private static final String PROJECT_VIEW_ID = ProjectView.ID; - private static final String CONTROL_VIEW_ID = ControlView.ID; - private static final String EVENTS_VIEW_ID = EventsView.ID; -// private static final String TIME_FRAME_VIEW_ID = TimeFrameView.ID; + private static final String EVENTS_VIEW_ID = EventsView.ID; private static final String CONTROL_FLOW_VIEW_ID = ControlFlowView.ID; - private static final String RESOURCES_VIEW_ID = ResourcesView.ID; - private static final String STATISTICS_VIEW_ID = StatisticsView.ID; - private static final String HISTOGRAM_VIEW_ID = HistogramView.ID; + private static final String RESOURCES_VIEW_ID = ResourcesView.ID; + private static final String STATISTICS_VIEW_ID = StatisticsView.ID; + private static final String HISTOGRAM_VIEW_ID = HistogramView.ID; // Standard Eclipse views - private static final String PROPERTIES_VIEW_ID = IPageLayout.ID_PROP_SHEET; - private static final String PROBLEM_VIEW_ID = IPageLayout.ID_PROBLEM_VIEW; + private static final String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER; + private static final String PROPERTIES_VIEW_ID = IPageLayout.ID_PROP_SHEET; - /* (non-Javadoc) - * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout) - */ - @Override - public void createInitialLayout(IPageLayout layout) { + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout) + */ + @Override + public void createInitialLayout(IPageLayout layout) { layout.setEditorAreaVisible(false); @@ -60,31 +57,32 @@ public class PerspectiveFactory implements IPerspectiveFactory { addPerspectiveShortcuts(layout); // Create the top left folder - IFolderLayout topLeftFolder = layout.createFolder("topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ + IFolderLayout topLeftFolder = layout.createFolder( + "topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ topLeftFolder.addView(PROJECT_VIEW_ID); - topLeftFolder.addView(CONTROL_VIEW_ID); - // Create the bottom left folder - IFolderLayout bottomLeftFolder = layout.createFolder("bottomLeftFolder", IPageLayout.BOTTOM, 0.50f, "topLeftFolder"); //$NON-NLS-1$ //$NON-NLS-2$ - bottomLeftFolder.addView(PROPERTIES_VIEW_ID); - +// // Create the bottom left folder +// IFolderLayout bottomLeftFolder = layout.createFolder( +// "bottomLeftFolder", IPageLayout.BOTTOM, 0.50f, "topLeftFolder"); //$NON-NLS-1$ //$NON-NLS-2$ + // Create the middle right folder - IFolderLayout topRightFolder = layout.createFolder("topRightFolder", IPageLayout.TOP, 0.50f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ + IFolderLayout topRightFolder = layout.createFolder( + "topRightFolder", IPageLayout.TOP, 0.30f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ topRightFolder.addView(CONTROL_FLOW_VIEW_ID); topRightFolder.addView(RESOURCES_VIEW_ID); topRightFolder.addView(STATISTICS_VIEW_ID); // Create the middle right folder - IFolderLayout middleRightFolder = layout.createFolder("middleRightFolder", IPageLayout.BOTTOM, 0.50f, "topRightFolder"); //$NON-NLS-1$//$NON-NLS-2$ + IFolderLayout middleRightFolder = layout.createFolder( + "middleRightFolder", IPageLayout.BOTTOM, 0.40f, "topRightFolder"); //$NON-NLS-1$//$NON-NLS-2$ middleRightFolder.addView(EVENTS_VIEW_ID); // Create the bottom right folder - IFolderLayout bottomRightFolder = layout.createFolder("bottomRightFolder", IPageLayout.BOTTOM, 0.50f, "middleRightFolder"); //$NON-NLS-1$ //$NON-NLS-2$ -// bottomRightFolder.addView(TIME_FRAME_VIEW_ID); + IFolderLayout bottomRightFolder = layout.createFolder( + "bottomRightFolder", IPageLayout.BOTTOM, 0.50f, "middleRightFolder"); //$NON-NLS-1$ //$NON-NLS-2$ bottomRightFolder.addView(HISTOGRAM_VIEW_ID); - bottomRightFolder.addView(PROBLEM_VIEW_ID); - - } + bottomRightFolder.addView(PROPERTIES_VIEW_ID); + } /** * Add fast views to the perspective diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java index 516de49517..ced59acdb3 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java @@ -20,33 +20,38 @@ import org.eclipse.ui.part.ViewPart; *

* TODO: Implement me. Please. */ +@Deprecated public class ControlView extends ViewPart { public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.control"; //$NON-NLS-1$ - /** + /** * */ - public ControlView() { - // TODO Auto-generated constructor stub - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createPartControl(Composite parent) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - // TODO Auto-generated method stub - - } + public ControlView() { + // TODO Auto-generated constructor stub + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parent) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + // TODO Auto-generated method stub + + } } 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 381da5a078..aa0ff19561 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 @@ -13,7 +13,7 @@ package org.eclipse.linuxtools.lttng.ui.views.events; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; -import org.eclipse.linuxtools.tmf.ui.views.TmfEventsView; +import org.eclipse.linuxtools.tmf.ui.views.events.TmfEventsView; import org.eclipse.swt.widgets.Composite; /** 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 238a0badc8..82c7294923 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 @@ -36,8 +36,7 @@ import org.eclipse.swt.widgets.Composite; /** * HistogramView *

- * The purpose of this view is to provide graphical time distribution statistics - * about the experiment/trace events. + * The purpose of this view is to provide graphical time distribution statistics about the experiment/trace events. *

* The view is composed of two histograms and two controls: *

    @@ -168,16 +167,16 @@ public class HistogramView extends TmfView { gridData = new GridData(); gridData.horizontalAlignment = SWT.CENTER; gridData.verticalAlignment = SWT.CENTER; - fCurrentEventTimeControl = new HistogramCurrentTimeControl(this, controlsComposite, SWT.BORDER, SWT.BORDER, currentEventLabel, - HistogramUtils.nanosecondsToString(0L)); + fCurrentEventTimeControl = new HistogramCurrentTimeControl(this, controlsComposite, SWT.BORDER, SWT.BORDER, + currentEventLabel, HistogramUtils.nanosecondsToString(0L)); fCurrentEventTimeControl.setLayoutData(gridData); // Window span time control gridData = new GridData(); gridData.horizontalAlignment = SWT.CENTER; gridData.verticalAlignment = SWT.CENTER; - fTimeSpanControl = new HistogramTimeRangeControl(this, controlsComposite, SWT.BORDER, SWT.BORDER, windowSpanLabel, - HistogramUtils.nanosecondsToString(0L)); + fTimeSpanControl = new HistogramTimeRangeControl(this, controlsComposite, SWT.BORDER, SWT.BORDER, + windowSpanLabel, HistogramUtils.nanosecondsToString(0L)); fTimeSpanControl.setLayoutData(gridData); // -------------------------------------------------------------------- @@ -255,7 +254,8 @@ public class HistogramView extends TmfView { // ------------------------------------------------------------------------ public TmfTimeRange getTimeRange() { - return new TmfTimeRange(new TmfTimestamp(fWindowStartTime, TIME_SCALE), new TmfTimestamp(fWindowEndTime, TIME_SCALE)); + return new TmfTimeRange(new TmfTimestamp(fWindowStartTime, TIME_SCALE), new TmfTimestamp(fWindowEndTime, + TIME_SCALE)); } // ------------------------------------------------------------------------ @@ -265,7 +265,8 @@ public class HistogramView extends TmfView { public void updateCurrentEventTime(long newTime) { if (fCurrentExperiment != null) { TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(newTime, TIME_SCALE), TmfTimestamp.BigCrunch); - HistogramRequest request = new HistogramRequest(fTimeRangeHistogram, timeRange, 0, 1, ExecutionType.FOREGROUND) { + HistogramRequest request = new HistogramRequest(fTimeRangeHistogram, timeRange, 0, 1, + ExecutionType.FOREGROUND) { @Override public void handleData(LttngEvent event) { if (event != null) { @@ -281,7 +282,8 @@ public class HistogramView extends TmfView { public void updateTimeRange(long startTime, long endTime) { if (fCurrentExperiment != null) { // Build the new time range; keep the current time - TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(startTime, TIME_SCALE), new TmfTimestamp(endTime, TIME_SCALE)); + TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(startTime, TIME_SCALE), new TmfTimestamp( + endTime, TIME_SCALE)); TmfTimestamp currentTime = new TmfTimestamp(fCurrentTimestamp, TIME_SCALE); fTimeSpanControl.setValue(endTime - startTime); @@ -451,8 +453,8 @@ public class HistogramView extends TmfView { if (fFullTraceRequest != null && !fFullTraceRequest.isCompleted()) { fFullTraceRequest.cancel(); } - fFullTraceRequest = new HistogramRequest(fFullTraceHistogram, fullRange, (int) fFullTraceHistogram.fDataModel.getNbEvents(), - ExecutionType.BACKGROUND); + fFullTraceRequest = new HistogramRequest(fFullTraceHistogram, fullRange, + (int) fFullTraceHistogram.fDataModel.getNbEvents(), ExecutionType.BACKGROUND); fCurrentExperiment.sendRequest(fFullTraceRequest); } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectNature.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectNature.java deleted file mode 100644 index 2e32fccf26..0000000000 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/LTTngProjectNature.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * 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.core.resources.IProject; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.runtime.CoreException; - -/** - * LTTngProjectNature - *

    - * This is really a marker for the LTTng projects. - */ -public class LTTngProjectNature implements IProjectNature { - - public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.project.LTTngProjectNature"; //$NON-NLS-1$ - - private IProject fProject; - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#configure() - */ - @Override - public void configure() throws CoreException { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#deconfigure() - */ - @Override - public void deconfigure() throws CoreException { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#getProject() - */ - @Override - public IProject getProject() { - return fProject; - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) - */ - @Override - public void setProject(IProject project) { - fProject = project; - } - -} 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 6ef78bc87b..98f7834903 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 @@ -28,11 +28,10 @@ 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.TraceHelper; import org.eclipse.linuxtools.lttng.event.LttngEvent; -import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.trace.LTTngExperiment; import org.eclipse.linuxtools.lttng.trace.LTTngTrace; -import org.eclipse.linuxtools.lttng.ui.TraceHelper; import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.Messages; import org.eclipse.linuxtools.lttng.ui.views.project.model.ILTTngProjectTreeNode; import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode; @@ -78,61 +77,61 @@ public class ProjectView extends TmfView { // Perform updates on the UI thread private Runnable fViewRefresher = new Runnable() { - @Override - public void run() { - if ((fViewer != null) && (!fViewer.getTree().isDisposed())) { - Object[] elements = fViewer.getExpandedElements(); - fViewer.refresh(); - fViewer.setExpandedElements(elements); - } - } + @Override + public void run() { + if ((fViewer != null) && (!fViewer.getTree().isDisposed())) { + Object[] elements = fViewer.getExpandedElements(); + fViewer.refresh(); + fViewer.setExpandedElements(elements); + } + } }; public LTTngProjectRoot getRoot() { - return fProjectRoot; + return fProjectRoot; } - + // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ - public ProjectView() { - - super("ProjectView"); //$NON-NLS-1$ + public ProjectView() { + + super("ProjectView"); //$NON-NLS-1$ fProjectRoot = new LTTngProjectRoot(this); - fWorkspace = ResourcesPlugin.getWorkspace(); - fResourceChangeListener = new IResourceChangeListener() { + fWorkspace = ResourcesPlugin.getWorkspace(); + fResourceChangeListener = new IResourceChangeListener() { @Override - public void resourceChanged(IResourceChangeEvent event) { + public void resourceChanged(IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.POST_CHANGE) { - fProjectRoot.refreshChildren(); - refresh(); + fProjectRoot.refreshChildren(); + refresh(); } - } + } }; fWorkspace.addResourceChangeListener(fResourceChangeListener); - } + } - public void refresh() { - Tree tree = fViewer.getTree(); - if (tree != null && !tree.isDisposed()) - tree.getDisplay().asyncExec(fViewRefresher); - } + 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); - } + public void setSelection(ILTTngProjectTreeNode node) { + fViewer.setSelection(new StructuredSelection(node), true); + } @Override - public void dispose() { - fWorkspace.removeResourceChangeListener(fResourceChangeListener); + public void dispose() { + fWorkspace.removeResourceChangeListener(fResourceChangeListener); } - @Override - public void createPartControl(Composite parent) { + @Override + public void createPartControl(Composite parent) { - fViewer = new TreeViewer(parent, SWT.SINGLE); + fViewer = new TreeViewer(parent, SWT.SINGLE); fViewer.setContentProvider(new LTTngProjectContentProvider()); fViewer.setSorter(new ViewerSorter()); fViewer.setLabelProvider(new LTTngProjectLabelProvider()); @@ -142,17 +141,17 @@ public class ProjectView extends TmfView { hookMouse(); createContextMenu(); - } + } // ------------------------------------------------------------------------ // ViewPart // ------------------------------------------------------------------------ - @Override - @SuppressWarnings("nls") - public String toString() { - return "[ProjectView]"; - } + @Override + @SuppressWarnings("nls") + public String toString() { + return "[ProjectView]"; + } // ------------------------------------------------------------------------ // hookMouse @@ -160,13 +159,13 @@ public class ProjectView extends TmfView { private void hookMouse() { fViewer.getTree().addMouseListener(new MouseAdapter() { - @Override - public void mouseDoubleClick(MouseEvent event) { + @Override + public void mouseDoubleClick(MouseEvent event) { TreeSelection selection = (TreeSelection) fViewer.getSelection(); Object element = selection.getFirstElement(); if (element instanceof LTTngExperimentNode) { - LTTngExperimentNode experiment = (LTTngExperimentNode) element; - selectExperiment(experiment); + LTTngExperimentNode experiment = (LTTngExperimentNode) element; + selectExperiment(experiment); } else { if (element instanceof LTTngTraceNode) { LTTngTraceNode trace = (LTTngTraceNode) element; @@ -193,11 +192,11 @@ public class ProjectView extends TmfView { traces[0] = trace; fSelectedExperiment = new LTTngExperiment(LttngEvent.class, traceNode.getName(), traces); TmfExperiment.setCurrentExperiment(fSelectedExperiment); - + // Make sure the lttng-core, experiment selection context is ready // for an event request from any view - StateManagerFactory.getExperimentManager().experimentSelected_prep( - (TmfExperiment) fSelectedExperiment); +// StateManagerFactory.getExperimentManager().experimentSelected_prep( +// (TmfExperiment) fSelectedExperiment); broadcast(new TmfExperimentSelectedSignal(this, fSelectedExperiment)); } catch (FileNotFoundException e) { @@ -207,37 +206,37 @@ public class ProjectView extends TmfView { } } - private boolean waitForCompletion = true; + private boolean waitForCompletion = true; - /** - * @param experiment - */ - public void selectExperiment(LTTngExperimentNode experiment) { - String expId = experiment.getName(); + /** + * @param experiment + */ + public void selectExperiment(LTTngExperimentNode experiment) { + String expId = experiment.getName(); if (fSelectedExperiment != null) { // System.out.println(fSelectedExperiment.getName() + ": nbEvents=" + fSelectedExperiment.getNbEvents() + // ", nbReads=" + ((LTTngTrace) fSelectedExperiment.getTraces()[0]).nbEventsRead); - fSelectedExperiment.dispose(); + fSelectedExperiment.dispose(); } try { - LTTngTraceNode[] traceEntries = experiment.getTraces(); - int nbTraces = traceEntries.length; - ITmfTrace[] traces = new ITmfTrace[nbTraces]; - for (int i = 0; i < nbTraces; i++) { - IResource res = traceEntries[i].getFolder(); - String location = res.getLocation().toOSString(); - IProject project = res.getProject().getProject(); + LTTngTraceNode[] traceEntries = experiment.getTraces(); + int nbTraces = traceEntries.length; + ITmfTrace[] traces = new ITmfTrace[nbTraces]; + for (int i = 0; i < nbTraces; i++) { + IResource res = traceEntries[i].getFolder(); + String location = res.getLocation().toOSString(); + IProject project = res.getProject().getProject(); String traceLibPath = TraceHelper.getTraceLibDirFromProject(project); - ITmfTrace trace = new LTTngTrace(location, traceLibPath, waitForCompletion, false); + ITmfTrace trace = new LTTngTrace(location, traceLibPath, waitForCompletion, false); traces[i] = trace; - } + } fSelectedExperiment = new LTTngExperiment(LttngEvent.class, expId, traces); TmfExperiment.setCurrentExperiment(fSelectedExperiment); - - // Make sure the lttng-core, experiment selection context is ready - // for an event request from any view - StateManagerFactory.getExperimentManager().experimentSelected_prep( - (TmfExperiment) fSelectedExperiment); + + // Make sure the lttng-core, experiment selection context is ready + // for an event request from any view +// StateManagerFactory.getExperimentManager().experimentSelected_prep( +// (TmfExperiment) fSelectedExperiment); // System.out.println(System.currentTimeMillis() + ": Experiment selected"); broadcast(new TmfExperimentSelectedSignal(this, fSelectedExperiment)); @@ -252,7 +251,7 @@ public class ProjectView extends TmfView { // createContextMenu // ------------------------------------------------------------------------ - // Populated from the plug-in + // Populated from the plug-in private void createContextMenu() { MenuManager menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuManager.setRemoveAllWhenShown(true); @@ -260,5 +259,5 @@ public class ProjectView extends TmfView { fViewer.getControl().setMenu(menu); getSite().registerContextMenu(menuManager, fViewer); } - -} \ No newline at end of file + +} 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 56b4f9064d..c179455c0e 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 @@ -31,6 +31,7 @@ import org.eclipse.ui.IWorkbench; *

    * TODO: Implement me. Please. */ +@Deprecated public class AddTraceWizard extends Wizard implements IImportWizard { private LTTngProjectNode fProject; 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 6032b17e3c..f3c5fffe9b 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 @@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.TableColumn; *

    * TODO: Implement me. Please. */ +@Deprecated public class AddTraceWizardPage extends WizardPage { private LTTngProjectNode fProject; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceContentProvider.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceContentProvider.java index 3eea43f497..cfa252c09f 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceContentProvider.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceContentProvider.java @@ -21,6 +21,7 @@ import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceFolderNode; *

    * TODO: Implement me. Please. */ +@Deprecated public class DialogTraceContentProvider implements IStructuredContentProvider { /* (non-Javadoc) diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceLabelProvider.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceLabelProvider.java index c2f4c37c2e..b016b9b3b0 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceLabelProvider.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/DialogTraceLabelProvider.java @@ -22,6 +22,7 @@ import org.eclipse.swt.graphics.Image; *

    * TODO: Implement me. Please. */ +@Deprecated public class DialogTraceLabelProvider extends LabelProvider implements ITableLabelProvider { /* (non-Javadoc) 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 2ea9f1fb7a..ae48bca21d 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 @@ -30,6 +30,7 @@ import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; * * TODO: Implement me. Please. */ +@Deprecated @SuppressWarnings("restriction") public class ImportTraceWizard extends Wizard implements IImportWizard { 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 0e604cb122..2132ed37c3 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 @@ -17,9 +17,9 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.linuxtools.lttng.TraceHelper; import org.eclipse.linuxtools.lttng.exceptions.LttngException; import org.eclipse.linuxtools.lttng.trace.LTTngTraceVersion; -import org.eclipse.linuxtools.lttng.ui.TraceHelper; import org.eclipse.linuxtools.lttng.ui.views.project.handlers.TraceErrorHandler; import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode; import org.eclipse.ui.IWorkbench; @@ -30,6 +30,7 @@ import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImpo *

    * TODO: Implement me. Please. */ +@Deprecated @SuppressWarnings("restriction") public class ImportTraceWizardPage extends WizardFileSystemResourceImportPage1 { 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 1ed3a95d73..b1d8f7cdfe 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 @@ -55,6 +55,7 @@ import org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup; * * This is stripped down version of NewFolderDialog. */ +@Deprecated @SuppressWarnings("restriction") public class NewExperimentDialog extends SelectionStatusDialog { 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 13102c05bc..7f0ce58e33 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 @@ -25,9 +25,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.linuxtools.lttng.LTTngProjectNature; +import org.eclipse.linuxtools.lttng.TraceHelper; import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin; -import org.eclipse.linuxtools.lttng.ui.TraceHelper; -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; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/TraceLibraryPathPropertyPage.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/TraceLibraryPathPropertyPage.java index 713606ff60..21c015f01c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/TraceLibraryPathPropertyPage.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/TraceLibraryPathPropertyPage.java @@ -16,7 +16,7 @@ import java.io.File; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.linuxtools.lttng.ui.TraceHelper; +import org.eclipse.linuxtools.lttng.TraceHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProjectNode.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProjectNode.java index 2ab9baa962..8898a10a9d 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProjectNode.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/model/LTTngProjectNode.java @@ -22,7 +22,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; -import org.eclipse.linuxtools.lttng.ui.views.project.LTTngProjectNature; +import org.eclipse.linuxtools.lttng.LTTngProjectNature; /** * LTTngProjectNode 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 c21a8740b9..ab59b1e08b 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 @@ -33,9 +33,8 @@ import org.eclipse.swt.widgets.Slider; /** * TimeFrameView *

    - * The TimeFrameView provides a set of spinners to monitor and set the start - * time, end time, the current time interval and current time of the trace set - * at the nanosecond level. + * The TimeFrameView provides a set of spinners to monitor and set the start time, end time, the current time interval + * and current time of the trace set at the nanosecond level. *

    * It ensures that the following relations are always true: *

    @@ -44,15 +43,15 @@ import org.eclipse.swt.widgets.Slider; *

  • [ startTime <= currentTime <= endTime ] *
  • [ interval == (endTime - startTime) ]
  • *

    - * It provides a slider to rapidly set the current time within the time range - * (i.e. between startTime and endTime). + * It provides a slider to rapidly set the current time within the time range (i.e. between startTime and endTime). *

    - * Finally, it allows modification of the time range and the current time. This - * triggers notifications to the other LTTng views. + * Finally, it allows modification of the time range and the current time. This triggers notifications to the other + * LTTng views. *

    - * FIXME: The slider is very jumpy due to the large number of async updates - * FIXME: Revisit the control flow between View, Spinners and Slider + * FIXME: The slider is very jumpy due to the large number of async updates FIXME: Revisit the control flow between + * View, Spinners and Slider */ +@Deprecated public class TimeFrameView extends TmfView { public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.timeframe"; //$NON-NLS-1$ @@ -72,9 +71,9 @@ public class TimeFrameView extends TmfView { private byte fScale = 0; // Labels - private static final String START_TIME_LABEL = Messages.TimeFrameView_WindowStartTime; - private static final String END_TIME_LABEL = Messages.TimeFrameView_WindowEndTime; - private static final String TIME_RANGE_LABEL = Messages.TimeFrameView_WindowRange; + private static final String START_TIME_LABEL = Messages.TimeFrameView_WindowStartTime; + private static final String END_TIME_LABEL = Messages.TimeFrameView_WindowEndTime; + private static final String TIME_RANGE_LABEL = Messages.TimeFrameView_WindowRange; private static final String CURRENT_TIME_LABEL = Messages.TimeFrameView_CurrentTime; private static final int SLIDER_RANGE = 10000; @@ -96,35 +95,33 @@ public class TimeFrameView extends TmfView { // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ - + /** * Constructor */ public TimeFrameView() { - super("TimeFrameView"); //$NON-NLS-1$ + super("TimeFrameView"); //$NON-NLS-1$ } /* * (non-Javadoc) * - * @see - * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets - * .Composite) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets .Composite) */ @Override public void createPartControl(Composite parent) { - // Set the view layout - GridLayout layout = new GridLayout(4, true); - parent.setLayout(layout); + // Set the view layout + GridLayout layout = new GridLayout(4, true); + parent.setLayout(layout); - fStartGroup = new SpinnerGroup(this, parent, START_TIME_LABEL, fTraceTimeRange, fTraceStartTime); - fEndGroup = new SpinnerGroup(this, parent, END_TIME_LABEL, fTraceTimeRange, fTraceEndTime); - fRangeGroup = new SpinnerGroup(this, parent, TIME_RANGE_LABEL, fTraceTimeRange, fTraceEndTime); - fCurrentGroup = new SpinnerGroup(this, parent, CURRENT_TIME_LABEL, fTraceTimeRange, fTraceStartTime); + fStartGroup = new SpinnerGroup(this, parent, START_TIME_LABEL, fTraceTimeRange, fTraceStartTime); + fEndGroup = new SpinnerGroup(this, parent, END_TIME_LABEL, fTraceTimeRange, fTraceEndTime); + fRangeGroup = new SpinnerGroup(this, parent, TIME_RANGE_LABEL, fTraceTimeRange, fTraceEndTime); + fCurrentGroup = new SpinnerGroup(this, parent, CURRENT_TIME_LABEL, fTraceTimeRange, fTraceStartTime); - // Create the slider - createSlider(parent); + // Create the slider + createSlider(parent); } /* @@ -134,7 +131,7 @@ public class TimeFrameView extends TmfView { */ @Override public void setFocus() { - // TODO Auto-generated method stub + // TODO Auto-generated method stub } // ------------------------------------------------------------------------ @@ -145,67 +142,67 @@ 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(); - TmfTimestamp endTime = fEndGroup.getCurrentTime(); - TmfTimestamp timeRange = fRangeGroup.getCurrentTime(); - TmfTimestamp currentTime = fCurrentGroup.getCurrentTime(); - - // If startTime was set beyond endTime, adjust endTime and interval - if (trigger == fStartGroup) { - if (startTime.compareTo(endTime, false) > 0) { - endTime = startTime; - trangeUpdated = true; - } - } - - // If endTime was set beyond startTime, adjust startTime and interval - if (trigger == fEndGroup) { - if (endTime.compareTo(startTime, false) < 0) { - startTime = endTime; - trangeUpdated = true; - } - } - - // If timeRange was set, adjust endTime - if (trigger == fRangeGroup) { - long start = startTime.getValue(); - long span = timeRange.getValue(); - TmfTimestamp ts = new TmfTimestamp(start + span, startTime.getScale(), 0); - if (ts.compareTo(fTraceEndTime, false) > 0) { - 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); - - // Update the spinner groups - fStartGroup.setContent(fTraceTimeRange, startTime); - fEndGroup.setContent(fTraceTimeRange, endTime); - fRangeGroup.setContent(fTraceSpan, interval); - 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)); - } - } + boolean trangeUpdated = false; + + // Collect the data + TmfTimestamp startTime = fStartGroup.getCurrentTime(); + TmfTimestamp endTime = fEndGroup.getCurrentTime(); + TmfTimestamp timeRange = fRangeGroup.getCurrentTime(); + TmfTimestamp currentTime = fCurrentGroup.getCurrentTime(); + + // If startTime was set beyond endTime, adjust endTime and interval + if (trigger == fStartGroup) { + if (startTime.compareTo(endTime, false) > 0) { + endTime = startTime; + trangeUpdated = true; + } + } + + // If endTime was set beyond startTime, adjust startTime and interval + if (trigger == fEndGroup) { + if (endTime.compareTo(startTime, false) < 0) { + startTime = endTime; + trangeUpdated = true; + } + } + + // If timeRange was set, adjust endTime + if (trigger == fRangeGroup) { + long start = startTime.getValue(); + long span = timeRange.getValue(); + TmfTimestamp ts = new TmfTimestamp(start + span, startTime.getScale(), 0); + if (ts.compareTo(fTraceEndTime, false) > 0) { + 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); + + // Update the spinner groups + fStartGroup.setContent(fTraceTimeRange, startTime); + fEndGroup.setContent(fTraceTimeRange, endTime); + fRangeGroup.setContent(fTraceSpan, interval); + 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)); + } + } } // ------------------------------------------------------------------------ @@ -216,29 +213,29 @@ public class TimeFrameView extends TmfView { * @param parent */ private void createSlider(Composite parent) { - fSlider = new Slider(parent, SWT.SMOOTH | SWT.FILL); - fSlider.setMinimum(0); - fSlider.setMaximum(SLIDER_RANGE + fSlider.getThumb()); - fSlider.setIncrement(SLIDER_RANGE / 100); - fSlider.setPageIncrement(SLIDER_RANGE / 10); - fSlider.setSelection(0); - - GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); - gridData.horizontalAlignment = SWT.FILL; - gridData.horizontalSpan = 4; - fSlider.setLayoutData(gridData); - - fSlider.addListener(SWT.Selection, new Listener() { - @Override - public void handleEvent(Event event) { - int ratio = fSlider.getSelection(); - TmfTimestamp span = fCurrentGroup.getSpan(); - long value = span.getValue() * ratio / SLIDER_RANGE; - TmfTimestamp start = fCurrentGroup.getStartTime(); - TmfTimestamp current = new TmfTimestamp(start.getValue() + value, start.getScale(), 0); - fCurrentGroup.setValue(current); - } - }); + fSlider = new Slider(parent, SWT.SMOOTH | SWT.FILL); + fSlider.setMinimum(0); + fSlider.setMaximum(SLIDER_RANGE + fSlider.getThumb()); + fSlider.setIncrement(SLIDER_RANGE / 100); + fSlider.setPageIncrement(SLIDER_RANGE / 10); + fSlider.setSelection(0); + + GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); + gridData.horizontalAlignment = SWT.FILL; + gridData.horizontalSpan = 4; + fSlider.setLayoutData(gridData); + + fSlider.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event event) { + int ratio = fSlider.getSelection(); + TmfTimestamp span = fCurrentGroup.getSpan(); + long value = span.getValue() * ratio / SLIDER_RANGE; + TmfTimestamp start = fCurrentGroup.getStartTime(); + TmfTimestamp current = new TmfTimestamp(start.getValue() + value, start.getScale(), 0); + fCurrentGroup.setValue(current); + } + }); } @@ -248,28 +245,28 @@ public class TimeFrameView extends TmfView { */ private void updateSlider(TmfTimeRange range, TmfTimestamp timestamp) { - // Ignore update if disposed - if (fSlider.isDisposed()) - return; - - // 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); - - // Set the slider value - final long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0; - - // Update the slider on the UI thread - long current = fSlider.getSelection(); - if (position != current) { - fSlider.getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - fSlider.setSelection((int) position); - } - }); - } + // Ignore update if disposed + if (fSlider.isDisposed()) + return; + + // 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); + + // Set the slider value + final long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0; + + // Update the slider on the UI thread + long current = fSlider.getSelection(); + if (position != current) { + fSlider.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + fSlider.setSelection((int) position); + } + }); + } } /* @@ -280,7 +277,7 @@ public class TimeFrameView extends TmfView { @Override @SuppressWarnings("nls") public String toString() { - return "[TimeFrameView]"; + return "[TimeFrameView]"; } // ------------------------------------------------------------------------ @@ -294,27 +291,27 @@ public class TimeFrameView extends TmfView { @TmfSignalHandler public void experimentSelected(TmfExperimentSelectedSignal signal) { - // Update the trace reference - fExperiment = (TmfExperiment) signal.getExperiment(); + // Update the trace reference + fExperiment = (TmfExperiment) signal.getExperiment(); - // Update the time frame - fTraceTimeRange = fExperiment.getTimeRange(); - fTraceStartTime = fTraceTimeRange.getStartTime(); - fTraceEndTime = fTraceTimeRange.getEndTime(); - fScale = fTraceStartTime.getScale(); + // Update the time frame + fTraceTimeRange = fExperiment.getTimeRange(); + fTraceStartTime = fTraceTimeRange.getStartTime(); + fTraceEndTime = fTraceTimeRange.getEndTime(); + fScale = fTraceStartTime.getScale(); - // Update the widgets - fStartGroup.setContent(fTraceTimeRange, fTraceStartTime); - fEndGroup.setContent(fTraceTimeRange, fTraceEndTime); - fCurrentGroup.setContent(fTraceTimeRange, fTraceStartTime); + // Update the widgets + fStartGroup.setContent(fTraceTimeRange, fTraceStartTime); + fEndGroup.setContent(fTraceTimeRange, fTraceEndTime); + fCurrentGroup.setContent(fTraceTimeRange, fTraceStartTime); - fCurrentTime = fTraceStartTime; + fCurrentTime = fTraceStartTime; - TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), 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); + TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), 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); } /** @@ -323,21 +320,21 @@ public class TimeFrameView extends TmfView { @TmfSignalHandler public void experimentUpdated(TmfExperimentUpdatedSignal signal) { - // Update the time frame - // fTraceTimeRange = signal.getTrace().getTimeRange(); - fTraceTimeRange = signal.getExperiment().getTimeRange(); - fTraceStartTime = fTraceTimeRange.getStartTime(); - fTraceEndTime = fTraceTimeRange.getEndTime(); - fScale = fTraceStartTime.getScale(); - - // Update the widgets - fStartGroup.setContent(fTraceTimeRange, fStartGroup.getCurrentTime()); - fEndGroup.setContent(fTraceTimeRange, fTraceEndTime); - fCurrentGroup.setContent(fTraceTimeRange, fCurrentGroup.getCurrentTime()); - - TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0); - fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta); - fRangeGroup.setContent(fTraceSpan, delta); + // Update the time frame + // fTraceTimeRange = signal.getTrace().getTimeRange(); + fTraceTimeRange = signal.getExperiment().getTimeRange(); + fTraceStartTime = fTraceTimeRange.getStartTime(); + fTraceEndTime = fTraceTimeRange.getEndTime(); + fScale = fTraceStartTime.getScale(); + + // Update the widgets + fStartGroup.setContent(fTraceTimeRange, fStartGroup.getCurrentTime()); + fEndGroup.setContent(fTraceTimeRange, fTraceEndTime); + fCurrentGroup.setContent(fTraceTimeRange, fCurrentGroup.getCurrentTime()); + + TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0); + fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta); + fRangeGroup.setContent(fTraceSpan, delta); } /** @@ -345,28 +342,28 @@ public class TimeFrameView extends TmfView { */ @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); + 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); + 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); + TmfTimestamp delta = new TmfTimestamp(selStart.getAdjustment(selEnd, fScale), fScale, 0); - fRangeGroup.setContent(fTraceSpan, delta); - } + fRangeGroup.setContent(fTraceSpan, delta); + } - // restore the external notification flag - fupdateExternalListeners = true; + // restore the external notification flag + fupdateExternalListeners = true; - } + } } /** @@ -374,22 +371,22 @@ public class TimeFrameView extends TmfView { */ @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); - } - if (fEndGroup.getCurrentTime().compareTo(fCurrentTime, false) < 0) { - fEndGroup.setContent(new TmfTimeRange(fStartGroup.getCurrentTime(), fCurrentTime), fCurrentTime); - } - fCurrentGroup.setContent(null, fCurrentTime); - updateSlider(fCurrentGroup.getTimeRange(), fCurrentTime); - - // Enable external notifications - fupdateExternalListeners = true; - } + 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); + } + if (fEndGroup.getCurrentTime().compareTo(fCurrentTime, false) < 0) { + fEndGroup.setContent(new TmfTimeRange(fStartGroup.getCurrentTime(), fCurrentTime), fCurrentTime); + } + fCurrentGroup.setContent(null, fCurrentTime); + updateSlider(fCurrentGroup.getTimeRange(), fCurrentTime); + + // Enable external notifications + fupdateExternalListeners = true; + } } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF index f0ddc93a0d..a87dfaf083 100644 --- a/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name -Bundle-SymbolicName: org.eclipse.linuxtools.lttng.core +Bundle-SymbolicName: org.eclipse.linuxtools.lttng.core;singleton:=true Bundle-Version: 0.3.2.qualifier Bundle-Activator: org.eclipse.linuxtools.lttng.LTTngCorePlugin Bundle-Vendor: %Bundle-Vendor diff --git a/org.eclipse.linuxtools.lttng/build.properties b/org.eclipse.linuxtools.lttng/build.properties index 5fde8c31a4..d944674ba0 100644 --- a/org.eclipse.linuxtools.lttng/build.properties +++ b/org.eclipse.linuxtools.lttng/build.properties @@ -2,5 +2,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - about.html,\ + about.html,\ plugin.properties diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/LTTngProjectNature.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/LTTngProjectNature.java new file mode 100644 index 0000000000..db70b8885d --- /dev/null +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/LTTngProjectNature.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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; + +import org.eclipse.linuxtools.tmf.TmfProjectNature; + +/** + * LTTngProjectNature + *

    + * This is really a marker for the LTTng projects. + */ +public class LTTngProjectNature extends TmfProjectNature { + + public static final String ID = "org.eclipse.linuxtools.lttng.LTTngProjectNature"; //$NON-NLS-1$ + +} diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/TraceHelper.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/TraceHelper.java similarity index 78% rename from org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/TraceHelper.java rename to org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/TraceHelper.java index 7caac58205..ac353a2a32 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/TraceHelper.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/TraceHelper.java @@ -9,13 +9,26 @@ * Contributors: * Yufen Kuo (ykuo@mvista.com) - Initial API and implementation *******************************************************************************/ -package org.eclipse.linuxtools.lttng.ui; + +package org.eclipse.linuxtools.lttng; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; public class TraceHelper { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + private static String TRACE_LIB_PATH = "traceLibraryPath"; //$NON-NLS-1$ + private static String QUALIFIER = "org.eclipse.linuxtools.lttng.jni"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Methods + // ------------------------------------------------------------------------ + /** * Get Trace Library Directory from Project Preference. * @@ -25,11 +38,11 @@ public class TraceHelper { */ public static String getTraceLibDirFromProject(IProject project) { if (project != null && project.exists()) { - return getProjectPreference(project, "traceLibraryPath"); + return getProjectPreference(project, TRACE_LIB_PATH); } return null; } - + /** * Get the project preference with the specified name * @@ -39,17 +52,15 @@ public class TraceHelper { * name of the preference. * @return The project preference value. */ - public static String getProjectPreference(IProject project, - String preferenceName) { + public static String getProjectPreference(IProject project, String preferenceName) { if (project.exists()) { - IEclipsePreferences prefs = new ProjectScope(project) - .getNode("org.eclipse.linuxtools.lttng.jni"); + IEclipsePreferences prefs = new ProjectScope(project).getNode(QUALIFIER); return prefs.get(preferenceName, null); } return null; } - + /** * Set the project preference with the specified value * @@ -61,11 +72,9 @@ public class TraceHelper { * value of the preference. * @return true if preference is successfully set, false otherwise. */ - public static boolean setProjectPreference(IProject project, - String preferenceName, String preferenceValue) { + public static boolean setProjectPreference(IProject project, String preferenceName, String preferenceValue) { if (project.exists()) { - IEclipsePreferences prefs = new ProjectScope(project) - .getNode("org.eclipse.linuxtools.lttng.jni"); + IEclipsePreferences prefs = new ProjectScope(project).getNode(QUALIFIER); prefs.put(preferenceName, preferenceValue); try { @@ -78,6 +87,7 @@ public class TraceHelper { } return false; } + /** * Remove the project preference with the specified name * @@ -87,11 +97,9 @@ public class TraceHelper { * name of the preference. * @return true if preference name is successfully remove, false otherwise. */ - public static boolean removeProjectPreference(IProject project, - String preferenceName) { + public static boolean removeProjectPreference(IProject project, String preferenceName) { if (project.exists()) { - IEclipsePreferences prefs = new ProjectScope(project) - .getNode("org.eclipse.linuxtools.lttng.jni"); + IEclipsePreferences prefs = new ProjectScope(project).getNode(QUALIFIER); prefs.remove(preferenceName); try { diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java index c07809a2ee..0e92a16d30 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java @@ -6,30 +6,35 @@ import org.eclipse.linuxtools.tmf.event.TmfEventSource; import org.eclipse.linuxtools.tmf.trace.TmfTrace; /** - * LttngEvent

    - * - * Lttng specific TmfEvent implementation.

    - * - * The main difference from the basic Tmf implementation is that we keep an internal reference to the JniEvent
    + * LttngEvent + *

    + * Lttng specific TmfEvent implementation. + *

    + * The main difference from the basic Tmf implementation is that we keep an + * internal reference to the JniEvent + *

    * The conversion from this LttngEvent to the JniEvent is then possible. */ public class LttngEvent extends TmfEvent { - + // Reference to the JNI JniEvent. Should only be used INTERNALLY private JniEvent jniEventReference = null; -// // Reference to the parent trace that own this event -// private TmfTrace parentTrace = null; - + // Parameter-less constructor + public LttngEvent() { + super(); + } + /** - * Constructor with parameters.

    + * Constructor with parameters. + *

    * - * @param timestamp The timestamp of this event - * @param source The source of this event - * @param type The type of this event - * @param content The content of this event - * @param reference The reference of this event - * @param lttEvent A reference to a valid JniEvent object + * @param timestamp The timestamp of this event + * @param source The source of this event + * @param type The type of this event + * @param content The content of this event + * @param reference The reference of this event + * @param lttEvent A reference to a valid JniEvent object * * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp * @see org.eclipse.linuxtools.tmf.event.TmfEventSource @@ -38,18 +43,20 @@ public class LttngEvent extends TmfEvent { * @see org.eclipse.linuxtools.lttng.event.LttngEventReference * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent */ - public LttngEvent(TmfTrace parent, LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) { + public LttngEvent(TmfTrace parent, LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, + LttngEventReference reference, JniEvent lttEvent) { super(timestamp, source, type, reference); - + fContent = content; jniEventReference = lttEvent; setParentTrace(parent); } - + /** - * Copy constructor.

    + * Copy constructor. + *

    * - * @param oldEvent Event we want to copy from. + * @param oldEvent Event we want to copy from. */ @SuppressWarnings("unchecked") public LttngEvent(LttngEvent oldEvent) { @@ -63,11 +70,10 @@ public class LttngEvent extends TmfEvent { oldEvent.jniEventReference ); } - /** * Set a new parent trace for this event * - * @param parentTrace The new parent + * @param parentTrace The new parent */ public void setParentTrace(TmfTrace parentTrace) { fParentTrace = parentTrace; @@ -80,72 +86,79 @@ public class LttngEvent extends TmfEvent { * @return Channel (tracefile) for this event */ public String getChannelName() { - return ( (LttngEventType)this.getType() ).getTracefileName(); + return this.getType().getTracefileName(); } - + /** - * Cpu id number of this event.

    + * Cpu id number of this event. + *

    * * @return CpuId */ public long getCpuId() { - return ( (LttngEventType)this.getType() ).getCpuId(); + return this.getType().getCpuId(); } - + /** - * Marker name of this event.

    + * Marker name of this event. + *

    * * @return Marker name */ public String getMarkerName() { - return ( (LttngEventType)this.getType() ).getMarkerName(); + return this.getType().getMarkerName(); } - + /** - * Marker id of this event.

    + * Marker id of this event. + *

    * * @return Marker id */ public int getMarkerId() { - return ( (LttngEventType)this.getType() ).getMarkerId(); + return this.getType().getMarkerId(); } - + @Override public LttngEventContent getContent() { - return (LttngEventContent)fContent; + return (LttngEventContent) fContent; } - + public void setContent(LttngEventContent newContent) { fContent = newContent; } - + @Override public LttngEventType getType() { - return (LttngEventType)fType; + return (LttngEventType) fType; } - + public void setType(LttngEventType newType) { fType = newType; } - + /** - * Set a new JniReference for this event.

    + * Set a new JniReference for this event. + *

    * - * Note : Reference is used to get back to the Jni during event parsing and need to be consistent. + * Note : Reference is used to get back to the Jni during event parsing and + * need to be consistent. * - * @param newJniEventReference New reference + * @param newJniEventReference New reference * * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent */ public synchronized void updateJniEventReference(JniEvent newJniEventReference) { this.jniEventReference = newJniEventReference; } - + /** - * Convert this event into a Jni JniEvent.

    + * Convert this event into a Jni JniEvent. + *

    * - * Note : Some verifications are done to make sure the event is still valid on - * the Jni side before conversion.
    If it is not the case, null will be returned. + * Note : Some verifications are done to make sure the event is still valid + * on the Jni side before conversion.
    + * If it is not the case, null will be returned. * * @return The converted JniEvent * @@ -153,34 +166,36 @@ public class LttngEvent extends TmfEvent { */ public synchronized JniEvent convertEventTmfToJni() { JniEvent tmpEvent = null; - + // ***TODO*** // Should we remove the check to save some time?? - - // We don't want to send away events that are outdated as their informations could be invalid - // If the timestamp between the event and the trace are not coherent we will not perform the conversion - if ( jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue() ) { + + // We don't want to send away events that are outdated as their + // informations could be invalid + // If the timestamp between the event and the trace are not coherent we + // will not perform the conversion + if (jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue()) { tmpEvent = jniEventReference; - } - else { - System.out.println("convertEventTmfToJni() failed: Unsynced Timestamp > TMF:" + getTimestamp().getValue() + " <--> JNI:" + jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime()); //$NON-NLS-1$//$NON-NLS-2$ + } else { + System.out + .println("convertEventTmfToJni() failed: Unsynced Timestamp > TMF:" + getTimestamp().getValue() + " <--> JNI:" + jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime()); //$NON-NLS-1$//$NON-NLS-2$ } return tmpEvent; } - + @Override @SuppressWarnings("nls") - public String toString() { - StringBuffer result= new StringBuffer("[LttngEvent("); - result.append("Timestamp:" + getTimestamp().getValue()); - result.append(",Channel:" + getChannelName()); - result.append(",CPU:" + getCpuId()); - result.append(",Marker:" + getMarkerName()); - result.append(",Content:" + getContent() + ")]"); - - return result.toString(); + public String toString() { + StringBuffer result = new StringBuffer("[LttngEvent("); + result.append("Timestamp:" + getTimestamp().getValue()); + result.append(",Channel:" + getChannelName()); + result.append(",CPU:" + getCpuId()); + result.append(",Marker:" + getMarkerName()); + result.append(",Content:" + getContent() + ")]"); + + return result.toString(); } - + @Override public LttngEvent clone() { LttngEvent clone = (LttngEvent) super.clone(); diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java index 60f942f2d4..38325e2ffb 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java @@ -32,30 +32,32 @@ import org.eclipse.linuxtools.tmf.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.request.ITmfEventRequest; import org.eclipse.linuxtools.tmf.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.signal.TmfExperimentRangeUpdatedSignal; +import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; +import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; +import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; /** * @author alvaro * */ -public class StateExperimentManager extends LTTngTreeNode implements - ILttExperimentSelectedListener, IStateExperimentManager { - - // ======================================================================== - // Data - // ======================================================================= - private LTTngTreeNode fSelectedExperiment = null; // one selected experiment - // supported - private final StateExperimentListener fexperimentListener; - private boolean fwaitForCompletion = false; - /** - * Used to route incoming events to proper trace manager, during check point - * building - */ - private final Map ftraceToManagerMap = new HashMap(); - - private LttngSyntheticEvent syntheticEvent = null; - private ITmfDataRequest fStateCheckPointRequest = null; +public class StateExperimentManager extends LTTngTreeNode implements ILttExperimentSelectedListener, + IStateExperimentManager { + + // ======================================================================== + // Data + // ======================================================================= + private LTTngTreeNode fSelectedExperiment = null; // one selected experiment + // supported + private final StateExperimentListener fexperimentListener; + private boolean fwaitForCompletion = false; + /** + * Used to route incoming events to proper trace manager, during check point building + */ + private final Map ftraceToManagerMap = new HashMap(); + + private LttngSyntheticEvent syntheticEvent = null; + private ITmfDataRequest fStateCheckPointRequest = null; private boolean fCheckPointUpdateBusy = false; private boolean fCheckPointUpdatePending = false; private int fCheckPointUpdateIndex = 0; @@ -63,19 +65,24 @@ public class StateExperimentManager extends LTTngTreeNode implements private long fCheckPointNbEventsHandled = 0; private final Object fCheckPointUpdateSyncObj = new Object(); + // ======================================================================== + // Constructors + // ======================================================================= + public StateExperimentManager(Long id, String name) { + super(id, null, name, null); + fexperimentListener = new StateExperimentListener("Experiment Manager", this); //$NON-NLS-1$ + TmfSignalManager.register(this); + } - // ======================================================================== - // Constructors - // ======================================================================= - public StateExperimentManager(Long id, String name) { - super(id, null, name, null); - fexperimentListener = new StateExperimentListener("Experiment Manager", this); //$NON-NLS-1$ - } - + @TmfSignalHandler + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void experimentSelected(TmfExperimentSelectedSignal signal) { + experimentSelected_prep(signal.getExperiment()); + } - // ======================================================================== - // Methods - // ======================================================================= + // ======================================================================== + // Methods + // ======================================================================= // /* (non-Javadoc) // * @see org.eclipse.linuxtools.lttng.state.experiment.IStateExperimentManager#readExperimentTimeWindow(org.eclipse.linuxtools.tmf.event.TmfTimeRange, java.lang.String, org.eclipse.linuxtools.lttng.state.IStateDataRequestListener) @@ -126,76 +133,68 @@ public class StateExperimentManager extends LTTngTreeNode implements // TraceDebug.debug("No selected experiment available"); // } // } - - - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.lttng.state.experiment.IStateExperimentManager - * #experimentSelected_prep - * (org.eclipse.linuxtools.tmf.experiment.TmfExperiment) - */ - @Override - public void experimentSelected_prep(TmfExperiment experiment) { - - if (fSelectedExperiment != null) { - clearExperimentNode(fSelectedExperiment); - fSelectedExperiment = null; - } - - LTTngTreeNode experimentNode = null; - if (experiment != null) { - experimentNode = getChildByName(experiment.getName()); - // keep experiment if already loaded with the same value - if (experimentNode != null - && experimentNode.getValue() != experiment) { - clearExperimentNode(experimentNode); - experimentNode = null; - } - - // Make sure all traces involved have a corresponding state manager - // and - // state system to request its initial data - if (experimentNode == null) { - // Create the new experiment tree node - experimentNode = new LTTngTreeNode(getNextUniqueId(), this, - experiment.getName(), experiment); - // add the new experiment to this children list - addChild(experimentNode); - } - - // Make sure the traces exists in the tree - ITmfTrace[] rtraces = experiment.getTraces(); - String traceName; - LTTngTreeNode traceStateManagerNode; - // StateStacksHandler - for (ITmfTrace rtrace : rtraces) { - traceName = rtrace.getName(); - traceStateManagerNode = experimentNode.getChildByName(traceName); - // Node does not exist for this experiment, so needs to be - // created - if (traceStateManagerNode == null) { - traceStateManagerNode = StateManagerFactory.getManager( - rtrace, experimentNode); - experimentNode.addChild(traceStateManagerNode); - } - } - - // Reset event provider to handle requests for the new experiment - LttngCoreProviderFactory.reset(experimentNode); - - // preserve the selected experiment - fSelectedExperiment = experimentNode; - } - } + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.lttng.state.experiment.IStateExperimentManager #experimentSelected_prep + * (org.eclipse.linuxtools.tmf.experiment.TmfExperiment) + */ + @Override + public void experimentSelected_prep(TmfExperiment experiment) { + + if (fSelectedExperiment != null) { + clearExperimentNode(fSelectedExperiment); + fSelectedExperiment = null; + } + + LTTngTreeNode experimentNode = null; + if (experiment != null) { + experimentNode = getChildByName(experiment.getName()); + // keep experiment if already loaded with the same value + if (experimentNode != null && experimentNode.getValue() != experiment) { + clearExperimentNode(experimentNode); + experimentNode = null; + } + + // Make sure all traces involved have a corresponding state manager + // and + // state system to request its initial data + if (experimentNode == null) { + // Create the new experiment tree node + experimentNode = new LTTngTreeNode(getNextUniqueId(), this, experiment.getName(), experiment); + // add the new experiment to this children list + addChild(experimentNode); + } + + // Make sure the traces exists in the tree + ITmfTrace[] rtraces = experiment.getTraces(); + String traceName; + LTTngTreeNode traceStateManagerNode; + // StateStacksHandler + for (ITmfTrace rtrace : rtraces) { + traceName = rtrace.getName(); + traceStateManagerNode = experimentNode.getChildByName(traceName); + // Node does not exist for this experiment, so needs to be + // created + if (traceStateManagerNode == null) { + traceStateManagerNode = StateManagerFactory.getManager(rtrace, experimentNode); + experimentNode.addChild(traceStateManagerNode); + } + } + + // Reset event provider to handle requests for the new experiment + LttngCoreProviderFactory.reset(experimentNode); + + // preserve the selected experiment + fSelectedExperiment = experimentNode; + } + } private void clearExperimentNode(LTTngTreeNode experimentNode) { // Remove checkpoints LTTngTreeNode[] traceNodes = experimentNode.getChildren(); - + for (LTTngTreeNode traceStateManagerNode : traceNodes) { IStateTraceManager traceManager = null; try { @@ -205,7 +204,7 @@ public class StateExperimentManager extends LTTngTreeNode implements traceManager.clearCheckPoints(); experimentNode.removeChild(traceStateManagerNode); } catch (ClassCastException e) { - // Nothing to do + // Nothing to do } // rebuild the experiment nodes from scratch @@ -213,353 +212,346 @@ public class StateExperimentManager extends LTTngTreeNode implements } } - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.lttng.signal.ILttExperimentSelectedListener# - * experimentSelected(java.lang.Object, - * org.eclipse.linuxtools.tmf.experiment.TmfExperiment) - */ - @Override - public void experimentSelected(Object source, - TmfExperiment experiment) { - // validate - if (experiment == null) { - TraceDebug.debug("Received experiment is null"); //$NON-NLS-1$ - return; - } - - // If previous request is ongoing, cancel it before requesting a new - // one. - if (fStateCheckPointRequest != null && !fStateCheckPointRequest.isCompleted()) { - fStateCheckPointRequest.cancel(); - } - - synchronized (fCheckPointUpdateSyncObj) { - fCheckPointUpdateBusy = true; - fCheckPointUpdatePending = false; - fCheckPointUpdateIndex = 0; - } - - // trigger data request to build the state system check points - fStateCheckPointRequest = buildCheckPoints(experiment, experiment.getTimeRange(), true); - - if (fStateCheckPointRequest == null) { - synchronized (fCheckPointUpdateSyncObj) { - fCheckPointUpdateBusy = false; - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.lttng.signal.ILttExperimentSelectedListener# - * experimentUpdated - * (org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal, boolean) - */ - @SuppressWarnings("unchecked") - @Override - public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal) { - TmfExperiment experiment = (TmfExperiment) signal.getExperiment(); - // validate - if (experiment != fSelectedExperiment.getValue()) { - return; - } - - synchronized (fCheckPointUpdateSyncObj) { - if (fCheckPointUpdateBusy) { - fCheckPointUpdatePending = true; - fCheckPointUpdateRange = signal.getRange(); - return; - } else { - fCheckPointUpdateBusy = true; - } - } - - // If previous request is ongoing, cancel it before requesting a new - // one. - if (fStateCheckPointRequest != null && !fStateCheckPointRequest.isCompleted()) { - fStateCheckPointRequest.cancel(); - } - - // trigger data request to build the state system check points - fStateCheckPointRequest = buildCheckPoints(experiment, signal.getRange(), false); - - if (fStateCheckPointRequest == null) { - synchronized (fCheckPointUpdateSyncObj) { - fCheckPointUpdateBusy = false; - } - } - } - - - /** - * @return the SelectedExperiment tree node - */ - @Override - public LTTngTreeNode getSelectedExperiment() { - return fSelectedExperiment; - } - - /* (non-Javadoc) - * @see org.eclipse.linuxtools.lttng.state.experiment.IStateExperimentManager#getExperimentTimeRange() - */ - @Override - @SuppressWarnings("unchecked") - public TmfTimeRange getExperimentTimeRange() { - TmfTimeRange timeRangeResult = null; - if (fSelectedExperiment != null) { - timeRangeResult = ((TmfExperiment) fSelectedExperiment - .getValue()).getTimeRange(); - } - return timeRangeResult; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - @Override - protected void finalize() { - fexperimentListener.dispose(); - } - - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.lttng.state.experiment.IStateExperimentManager - * #waitForComplete(boolean) - */ - @Override - public void waitForCompletion(boolean wait) { - fwaitForCompletion = wait; - } - - private ITmfDataRequest buildCheckPoints(final TmfExperiment experiment, final TmfTimeRange range, boolean initial) { - // validate - if (experiment == null) { - TraceDebug.debug("Received experiment is null"); //$NON-NLS-1$ - return null; - } - - LTTngTreeNode experimentNode = getChildByName(experiment.getName()); - if (experimentNode == null) { - TraceDebug.debug("Experiment Node " + experiment.getName() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$ - return null; - } - - final boolean waitForCompletion = fwaitForCompletion; - - // get the trace manager nodes associated to the experiment - LTTngTreeNode[] traceNodes = experimentNode.getChildren(); - - if (initial) { - synchronized (this) { - ftraceToManagerMap.clear(); - } - - ITmfTrace trace; - for (LTTngTreeNode traceStateManagerNode : traceNodes) { - IStateTraceManager traceManager; - try { - traceManager = (IStateTraceManager) traceStateManagerNode; - } catch (ClassCastException e) { - System.out.println(e.getStackTrace().toString()); - return null; - } - - // Clear all previously created check points as preparation to - // re-build - traceManager.clearCheckPoints(); - - // build the trace to manager mapping for event dispatching - trace = traceManager.getTrace(); - synchronized (this) { - ftraceToManagerMap.put(trace, new StateTraceHelper(traceManager)); - } - } - } - - // if no trace mapping - if (ftraceToManagerMap.size() < 1) { - TraceDebug.debug("No traces associated to experiment " + experiment.getName()); //$NON-NLS-1$ - return null; - } - - fCheckPointNbEventsHandled = 0; - - // Prepare event data request to build state model - ITmfEventRequest request = new TmfEventRequest( - LttngEvent.class, range, fCheckPointUpdateIndex, - TmfEventRequest.ALL_DATA, LttngConstants.DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleData() - */ - @Override - public void handleData(LttngEvent event) { - super.handleData(event); - if (event != null) { + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.lttng.signal.ILttExperimentSelectedListener# experimentSelected(java.lang.Object, + * org.eclipse.linuxtools.tmf.experiment.TmfExperiment) + */ + @Override + public void experimentSelected(Object source, TmfExperiment experiment) { + // validate + if (experiment == null) { + TraceDebug.debug("Received experiment is null"); //$NON-NLS-1$ + return; + } + + // If previous request is ongoing, cancel it before requesting a new + // one. + if (fStateCheckPointRequest != null && !fStateCheckPointRequest.isCompleted()) { + fStateCheckPointRequest.cancel(); + } + + synchronized (fCheckPointUpdateSyncObj) { + fCheckPointUpdateBusy = true; + fCheckPointUpdatePending = false; + fCheckPointUpdateIndex = 0; + } + + // trigger data request to build the state system check points + fStateCheckPointRequest = buildCheckPoints(experiment, experiment.getTimeRange(), true); + + if (fStateCheckPointRequest == null) { + synchronized (fCheckPointUpdateSyncObj) { + fCheckPointUpdateBusy = false; + } + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.lttng.signal.ILttExperimentSelectedListener# experimentUpdated + * (org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal, boolean) + */ + @SuppressWarnings("unchecked") + @Override + public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal) { + TmfExperiment experiment = (TmfExperiment) signal.getExperiment(); + // validate + if (experiment != fSelectedExperiment.getValue()) { + return; + } + + synchronized (fCheckPointUpdateSyncObj) { + if (fCheckPointUpdateBusy) { + fCheckPointUpdatePending = true; + fCheckPointUpdateRange = signal.getRange(); + return; + } else { + fCheckPointUpdateBusy = true; + } + } + + // If previous request is ongoing, cancel it before requesting a new + // one. + if (fStateCheckPointRequest != null && !fStateCheckPointRequest.isCompleted()) { + fStateCheckPointRequest.cancel(); + } + + // trigger data request to build the state system check points + fStateCheckPointRequest = buildCheckPoints(experiment, signal.getRange(), false); + + if (fStateCheckPointRequest == null) { + synchronized (fCheckPointUpdateSyncObj) { + fCheckPointUpdateBusy = false; + } + } + } + + /** + * @return the SelectedExperiment tree node + */ + @Override + public LTTngTreeNode getSelectedExperiment() { + return fSelectedExperiment; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.lttng.state.experiment.IStateExperimentManager#getExperimentTimeRange() + */ + @Override + @SuppressWarnings("unchecked") + public TmfTimeRange getExperimentTimeRange() { + TmfTimeRange timeRangeResult = null; + if (fSelectedExperiment != null) { + timeRangeResult = ((TmfExperiment) fSelectedExperiment.getValue()).getTimeRange(); + } + return timeRangeResult; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + @Override + protected void finalize() { + fexperimentListener.dispose(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.lttng.state.experiment.IStateExperimentManager #waitForComplete(boolean) + */ + @Override + public void waitForCompletion(boolean wait) { + fwaitForCompletion = wait; + } + + private ITmfDataRequest buildCheckPoints(final TmfExperiment experiment, + final TmfTimeRange range, boolean initial) { + // validate + if (experiment == null) { + TraceDebug.debug("Received experiment is null"); //$NON-NLS-1$ + return null; + } + + LTTngTreeNode experimentNode = getChildByName(experiment.getName()); + if (experimentNode == null) { + TraceDebug.debug("Experiment Node " + experiment.getName() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } + + final boolean waitForCompletion = fwaitForCompletion; + + // get the trace manager nodes associated to the experiment + LTTngTreeNode[] traceNodes = experimentNode.getChildren(); + + if (initial) { + synchronized (this) { + ftraceToManagerMap.clear(); + } + + ITmfTrace trace; + for (LTTngTreeNode traceStateManagerNode : traceNodes) { + IStateTraceManager traceManager; + try { + traceManager = (IStateTraceManager) traceStateManagerNode; + } catch (ClassCastException e) { + System.out.println(e.getStackTrace().toString()); + return null; + } + + // Clear all previously created check points as preparation to + // re-build + traceManager.clearCheckPoints(); + + // build the trace to manager mapping for event dispatching + trace = traceManager.getTrace(); + synchronized (this) { + ftraceToManagerMap.put(trace, new StateTraceHelper(traceManager)); + } + } + } + + // if no trace mapping + if (ftraceToManagerMap.size() < 1) { + TraceDebug.debug("No traces associated to experiment " + experiment.getName()); //$NON-NLS-1$ + return null; + } + + fCheckPointNbEventsHandled = 0; + + // Prepare event data request to build state model + ITmfEventRequest request = new TmfEventRequest(LttngEvent.class, range, + fCheckPointUpdateIndex, TmfEventRequest.ALL_DATA, LttngConstants.DEFAULT_BLOCK_SIZE, + ITmfDataRequest.ExecutionType.BACKGROUND) { + + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleData() + */ + @Override + public void handleData(LttngEvent event) { + super.handleData(event); + if (event != null) { // Tracer.trace("Chk: " + event.getTimestamp()); - fCheckPointNbEventsHandled++; - ITmfTrace trace = event.getParentTrace(); - - StateTraceHelper helper = ftraceToManagerMap.get(trace); - - if (helper != null) { - helper.incrementNumberRead(); - - // obtain synthetic event - LttngSyntheticEvent synEvent = updateSynEvent(event, helper.getTraceModel()); - - // update state system, and save check points as needed - helper.getStateManager().handleEvent(synEvent, helper.getNumberRead()); - } else { - TraceDebug.debug("StateTraceManager not found for trace" //$NON-NLS-1$ - + trace.getName()); - } - } - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted() - */ - @Override - public void handleCompleted() { - super.handleCompleted(); - printCompletedMessage(); - - if (!waitForCompletion) { - synchronized (fCheckPointUpdateSyncObj) { - fCheckPointUpdateBusy = false; - fCheckPointUpdateIndex += fCheckPointNbEventsHandled; - if (fCheckPointUpdatePending) { - fCheckPointUpdatePending = false; - fCheckPointUpdateBusy = true; - buildCheckPoints(experiment, fCheckPointUpdateRange, false); - } - } - } - } - - /* - /** - * @param header - */ - private void printCompletedMessage() { - if (TraceDebug.isDEBUG()) { - TraceDebug.debug("Trace check point building completed, number of events handled: " + fCheckPointNbEventsHandled + "\n\t\t"); //$NON-NLS-1$ //$NON-NLS-2$ - for (StateTraceHelper helper : ftraceToManagerMap.values()) { - TraceDebug.debug(helper.getStateManager().toString() + "\n\t\t"); //$NON-NLS-1$ - } - } - } - }; - - // Execute event data request - experiment.sendRequest(request); - - if (waitForCompletion) { - try { - request.waitForCompletion(); - synchronized (fCheckPointUpdateSyncObj) { - fCheckPointUpdateBusy = false; - fCheckPointUpdateIndex += fCheckPointNbEventsHandled; - if (fCheckPointUpdatePending) { - fCheckPointUpdatePending = false; - fCheckPointUpdateBusy = true; - buildCheckPoints(experiment, fCheckPointUpdateRange, false); - } - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - return request; - } - - private LttngSyntheticEvent updateSynEvent(LttngEvent e, LttngTraceState stateModel) { - if (syntheticEvent == null || syntheticEvent.getBaseEvent() != e) { - syntheticEvent = new LttngSyntheticEvent(e); - } - - // Trace model needed by application handlers - syntheticEvent.setTraceModel(stateModel); - syntheticEvent.setSequenceInd(SequenceInd.UPDATE); - - return syntheticEvent; - } - - /** - * Helper class that wraps the StateTraceManager, the current - * LTTngTraceState and the number of read events - * - * @author bHufmann - * - */ - private class StateTraceHelper { - - IStateTraceManager stateTraceManager = null; - long numberEventsRead = 0; - LttngTraceState stateTraceModel = null; - - /** - * Constructor - * - * @param stateManager - * The StateTraceManager the helper is for - */ - public StateTraceHelper(IStateTraceManager stateManager) { - this.stateTraceManager = stateManager; - // Get the TraceState at the beginning of the trace - this.stateTraceManager.restoreCheckPointByTimestamp(stateManager - .getTrace().getStartTime()); - this.stateTraceModel = this.stateTraceManager.getStateModel(); - } - - /** - * Returns the StateTraceManager - * - * @return IStateTraceManager - */ - public IStateTraceManager getStateManager() { - return stateTraceManager; - } - - /** - * Returns the number of read events - * - * @return long - */ - public long getNumberRead() { - return numberEventsRead; - } - - /** - * Increments the number of read events - */ - public void incrementNumberRead() { - ++numberEventsRead; - } - - /** - * Returns the current LTTngTraceState - * - * @return LttngTraceState - */ - public LttngTraceState getTraceModel() { - return stateTraceModel; - } - } + fCheckPointNbEventsHandled++; + ITmfTrace trace = event.getParentTrace(); + + StateTraceHelper helper = ftraceToManagerMap.get(trace); + + if (helper != null) { + helper.incrementNumberRead(); + + // obtain synthetic event + LttngSyntheticEvent synEvent = updateSynEvent(event, helper.getTraceModel()); + + // update state system, and save check points as needed + helper.getStateManager().handleEvent(synEvent, helper.getNumberRead()); + } else { + TraceDebug.debug("StateTraceManager not found for trace" //$NON-NLS-1$ + + trace.getName()); + } + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted() + */ + @Override + public void handleCompleted() { + super.handleCompleted(); + printCompletedMessage(); + + if (!waitForCompletion) { + synchronized (fCheckPointUpdateSyncObj) { + fCheckPointUpdateBusy = false; + fCheckPointUpdateIndex += fCheckPointNbEventsHandled; + if (fCheckPointUpdatePending) { + fCheckPointUpdatePending = false; + fCheckPointUpdateBusy = true; + buildCheckPoints(experiment, fCheckPointUpdateRange, false); + } + } + } + } + + /* + * /** + * + * @param header + */ + private void printCompletedMessage() { + if (TraceDebug.isDEBUG()) { + TraceDebug + .debug("Trace check point building completed, number of events handled: " + fCheckPointNbEventsHandled + "\n\t\t"); //$NON-NLS-1$ //$NON-NLS-2$ + for (StateTraceHelper helper : ftraceToManagerMap.values()) { + TraceDebug.debug(helper.getStateManager().toString() + "\n\t\t"); //$NON-NLS-1$ + } + } + } + }; + + // Execute event data request + experiment.sendRequest(request); + + if (waitForCompletion) { + try { + request.waitForCompletion(); + synchronized (fCheckPointUpdateSyncObj) { + fCheckPointUpdateBusy = false; + fCheckPointUpdateIndex += fCheckPointNbEventsHandled; + if (fCheckPointUpdatePending) { + fCheckPointUpdatePending = false; + fCheckPointUpdateBusy = true; + buildCheckPoints(experiment, fCheckPointUpdateRange, false); + } + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + return request; + } + + private LttngSyntheticEvent updateSynEvent(LttngEvent e, LttngTraceState stateModel) { + if (syntheticEvent == null || syntheticEvent.getBaseEvent() != e) { + syntheticEvent = new LttngSyntheticEvent(e); + } + + // Trace model needed by application handlers + syntheticEvent.setTraceModel(stateModel); + syntheticEvent.setSequenceInd(SequenceInd.UPDATE); + + return syntheticEvent; + } + + /** + * Helper class that wraps the StateTraceManager, the current LTTngTraceState and the number of read events + * + * @author bHufmann + * + */ + private class StateTraceHelper { + + IStateTraceManager stateTraceManager = null; + long numberEventsRead = 0; + LttngTraceState stateTraceModel = null; + + /** + * Constructor + * + * @param stateManager + * The StateTraceManager the helper is for + */ + public StateTraceHelper(IStateTraceManager stateManager) { + this.stateTraceManager = stateManager; + // Get the TraceState at the beginning of the trace + this.stateTraceManager.restoreCheckPointByTimestamp(stateManager.getTrace().getStartTime()); + this.stateTraceModel = this.stateTraceManager.getStateModel(); + } + + /** + * Returns the StateTraceManager + * + * @return IStateTraceManager + */ + public IStateTraceManager getStateManager() { + return stateTraceManager; + } + + /** + * Returns the number of read events + * + * @return long + */ + public long getNumberRead() { + return numberEventsRead; + } + + /** + * Increments the number of read events + */ + public void incrementNumberRead() { + ++numberEventsRead; + } + + /** + * Returns the current LTTngTraceState + * + * @return LttngTraceState + */ + public LttngTraceState getTraceModel() { + return stateTraceModel; + } + } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateManagerFactory.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateManagerFactory.java index 6393f2ee9e..22411b92a0 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateManagerFactory.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateManagerFactory.java @@ -25,131 +25,128 @@ import org.eclipse.linuxtools.tmf.trace.ITmfTrace; * */ public class StateManagerFactory { - // ======================================================================== - // Data - // ======================================================================= - - private static IStateExperimentManager experimentManager = null; - /** - * Allows to modify the check point interval for every new instance of trace manager - */ - private static Long ftraceCheckPointInterval = null; - - static { - initCheck(); - } - // ======================================================================== - // Methods - // ======================================================================= - - /** - * @param traceUniqueId - * @param experiment - * @return - */ - public static LTTngTreeNode getManager(ITmfTrace rtrace, - LTTngTreeNode experiment) { - - // Validate - if (rtrace == null) { - return null; - } - - String traceUniqueId = rtrace.getName(); - if (traceUniqueId == null) { - return null; - } - - - LTTngTreeNode managerNode = null; - managerNode = experiment.getChildByName(traceUniqueId); - - if (managerNode != null && managerNode instanceof IStateTraceManager) { - return managerNode; - } + // ======================================================================== + // Data + // ======================================================================= + + private static IStateExperimentManager experimentManager = null; + /** + * Allows to modify the check point interval for every new instance of trace manager + */ + private static Long ftraceCheckPointInterval = null; + + static { + initCheck(); + } + + // ======================================================================== + // Methods + // ======================================================================= + + /** + * @param traceUniqueId + * @param experiment + * @return + */ + public static LTTngTreeNode getManager(ITmfTrace rtrace, LTTngTreeNode experiment) { + + // Validate + if (rtrace == null) { + return null; + } + + String traceUniqueId = rtrace.getName(); + if (traceUniqueId == null) { + return null; + } + + LTTngTreeNode managerNode = null; + managerNode = experiment.getChildByName(traceUniqueId); + + if (managerNode != null && managerNode instanceof IStateTraceManager) { + return managerNode; + } // LttngTraceState traceModel = // StateModelFactory.getStateEntryInstance(); - StateTraceManager manager = null; - - // catch potential construction problems - try { - manager = new StateTraceManager(experiment.getNextUniqueId(), experiment, traceUniqueId, rtrace); - - // Allow the possibility to configure the trace state check point - // interval at creation time - if (ftraceCheckPointInterval != null) { - manager.setCheckPointInterval(ftraceCheckPointInterval); - } - - } catch (LttngStateException e) { - e.printStackTrace(); - } - - experiment.addChild(manager); - return manager; - } - - /** - * Provide the State trace set manager - * - * @return - */ - public static IStateExperimentManager getExperimentManager() { - return experimentManager; - } - - /** - * Remove previously registered managers - * - * @param traceUniqueId - */ - public static void removeManager(ITmfTrace rtrace, LTTngTreeNode rexperiment) { - if (rtrace != null && rexperiment != null - && rexperiment.getValue() instanceof TmfExperiment) { - LTTngTreeNode childToremove = rexperiment.getChildByName(rtrace - .getName()); - if (childToremove != null) { - rexperiment.removeChild(childToremove); - } - } else { - TraceDebug.debug("Invalid arguments to remove manager for trace: " //$NON-NLS-1$ - + rtrace.getName()); - } - } - - /** - * initialization of factory - */ - private static void initCheck() { - if (experimentManager == null) { - Long id = 0L; // unique id - String name = "StateExperimentManager"; // name //$NON-NLS-1$ - experimentManager = new StateExperimentManager(id, name); - } - } - - /** - * Clea up resources - */ - public static void dispose() { - if (experimentManager != null) { - experimentManager = null; - } - } - - /** - * @return the traceCheckPointInterval - */ - public static Long getTraceCheckPointInterval() { - return ftraceCheckPointInterval; - } - - /** - * @param traceCheckPointInterval - * the traceCheckPointInterval to set - */ - public static void setTraceCheckPointInterval(Long traceCheckPointInterval) { - StateManagerFactory.ftraceCheckPointInterval = traceCheckPointInterval; - } + StateTraceManager manager = null; + + // catch potential construction problems + try { + manager = new StateTraceManager(experiment.getNextUniqueId(), experiment, traceUniqueId, rtrace); + + // Allow the possibility to configure the trace state check point + // interval at creation time + if (ftraceCheckPointInterval != null) { + manager.setCheckPointInterval(ftraceCheckPointInterval); + } + + } catch (LttngStateException e) { + e.printStackTrace(); + } + + experiment.addChild(manager); + return manager; + } + + /** + * Provide the State trace set manager + * + * @return + */ + public static IStateExperimentManager getExperimentManager() { + return experimentManager; + } + + /** + * Remove previously registered managers + * + * @param traceUniqueId + */ + public static void removeManager(ITmfTrace rtrace, LTTngTreeNode rexperiment) { + if (rtrace != null && rexperiment != null && rexperiment.getValue() instanceof TmfExperiment) { + LTTngTreeNode childToremove = rexperiment.getChildByName(rtrace.getName()); + if (childToremove != null) { + rexperiment.removeChild(childToremove); + } + } else { + TraceDebug.debug("Invalid arguments to remove manager for trace: " //$NON-NLS-1$ + + rtrace.getName()); + } + } + + /** + * initialization of factory + */ + private static void initCheck() { + if (experimentManager == null) { + Long id = 0L; // unique id + String name = "StateExperimentManager"; // name //$NON-NLS-1$ + experimentManager = new StateExperimentManager(id, name); + } + } + + /** + * Clea up resources + */ + public static void dispose() { + if (experimentManager != null) { + experimentManager = null; + } + } + + /** + * @return the traceCheckPointInterval + */ + public static Long getTraceCheckPointInterval() { + return ftraceCheckPointInterval; + } + + /** + * @param traceCheckPointInterval + * the traceCheckPointInterval to set + */ + public static void setTraceCheckPointInterval(Long traceCheckPointInterval) { + StateManagerFactory.ftraceCheckPointInterval = traceCheckPointInterval; + } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/resource/ILttngStateContext.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/resource/ILttngStateContext.java index 2152f540f7..8e5a70e381 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/resource/ILttngStateContext.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/resource/ILttngStateContext.java @@ -66,7 +66,7 @@ public interface ILttngStateContext { * * @return */ - public ITmfTrace getTraceIdRef(); + public ITmfTrace getTraceIdRef(); /** * Returns Trace Identifier diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java index 65a7186dc2..fb7d22daa0 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java @@ -30,7 +30,7 @@ public interface IStateTraceManager { * * @return */ - public abstract ITmfTrace getTrace(); + public abstract ITmfTrace getTrace(); /** * Restore to the closest checkpoint from TmfTimestamp diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java index d3be8af1a0..00b81d3d95 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java @@ -36,7 +36,7 @@ import org.eclipse.linuxtools.tmf.trace.TmfContext; * Temporary class to resolve a basic incompatibility between TMF and LTTng. *

    */ -public class LTTngExperiment extends TmfExperiment implements ITmfTrace { +public class LTTngExperiment extends TmfExperiment { private static final int DEFAULT_INDEX_PAGE_SIZE = 50000; @@ -51,11 +51,11 @@ public class LTTngExperiment extends TmfExperiment implem * @param epoch * @param indexPageSize */ - public LTTngExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize) { + public LTTngExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize) { this(type, id, traces, TmfTimestamp.Zero, indexPageSize, false); } - public LTTngExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize, boolean preIndexExperiment) { + public LTTngExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize, boolean preIndexExperiment) { super(type, id, traces, epoch, indexPageSize, preIndexExperiment); } @@ -64,7 +64,7 @@ public class LTTngExperiment extends TmfExperiment implem * @param id * @param traces */ - public LTTngExperiment(Class type, String id, ITmfTrace[] traces) { + public LTTngExperiment(Class type, String id, ITmfTrace[] traces) { this(type, id, traces, TmfTimestamp.Zero, DEFAULT_INDEX_PAGE_SIZE); } @@ -74,10 +74,11 @@ public class LTTngExperiment extends TmfExperiment implem * @param traces * @param indexPageSize */ - public LTTngExperiment(Class type, String id, ITmfTrace[] traces, int indexPageSize) { + public LTTngExperiment(Class type, String id, ITmfTrace[] traces, int indexPageSize) { this(type, id, traces, TmfTimestamp.Zero, indexPageSize); } + @SuppressWarnings("unchecked") public LTTngExperiment(LTTngExperiment other) { super(other.getName() + "(clone)", other.fType); //$NON-NLS-1$ @@ -86,7 +87,7 @@ public class LTTngExperiment extends TmfExperiment implem fTraces = new ITmfTrace[other.fTraces.length]; for (int trace = 0; trace < other.fTraces.length; trace++) { - fTraces[trace] = other.fTraces[trace].createTraceCopy(); + fTraces[trace] = other.fTraces[trace].copy(); } fNbEvents = other.fNbEvents; @@ -94,7 +95,7 @@ public class LTTngExperiment extends TmfExperiment implem } @Override - public LTTngExperiment createTraceCopy() { + public LTTngExperiment copy() { LTTngExperiment experiment = new LTTngExperiment(this); TmfSignalManager.deregister(experiment); return experiment; diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java index a7510c65ac..19a48f0b68 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java @@ -28,13 +28,12 @@ import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.tmf.event.TmfNoSuchFieldException; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.trace.ITmfLocation; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.trace.TmfCheckpoint; import org.eclipse.linuxtools.tmf.trace.TmfContext; import org.eclipse.linuxtools.tmf.trace.TmfLocation; import org.eclipse.linuxtools.tmf.trace.TmfTrace; -public class LTTngTextTrace extends TmfTrace implements ITmfTrace { +public class LTTngTextTrace extends TmfTrace { private LttngTimestamp eventTimestamp = null; private LttngEventSource eventSource = null; private LttngEventType eventType = null; @@ -110,7 +109,7 @@ public class LTTngTextTrace extends TmfTrace implements ITmfTrace { } @Override - public LTTngTextTrace createTraceCopy() { + public LTTngTextTrace copy() { LTTngTextTrace returnedTrace = null; @@ -530,4 +529,4 @@ class TextLttngEventContent extends LttngEventContent { return returnedField; } -} \ No newline at end of file +} diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java index 7fe2216b59..52fe78cc0e 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java @@ -13,10 +13,13 @@ package org.eclipse.linuxtools.lttng.trace; +import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Iterator; import java.util.Vector; +import org.eclipse.core.resources.IProject; +import org.eclipse.linuxtools.lttng.TraceHelper; import org.eclipse.linuxtools.lttng.event.LttngEvent; import org.eclipse.linuxtools.lttng.event.LttngEventContent; import org.eclipse.linuxtools.lttng.event.LttngEventReference; @@ -41,1175 +44,1187 @@ import org.eclipse.linuxtools.tmf.trace.TmfContext; import org.eclipse.linuxtools.tmf.trace.TmfTrace; class LTTngTraceException extends LttngException { - static final long serialVersionUID = -1636648737081868146L; + static final long serialVersionUID = -1636648737081868146L; - public LTTngTraceException(String errMsg) { - super(errMsg); - } + public LTTngTraceException(String errMsg) { + super(errMsg); + } } /** * LTTngTrace *

    * - * LTTng trace implementation. It accesses the C trace handling library - * (seeking, reading and parsing) through the JNI component. + * LTTng trace implementation. It accesses the C trace handling library (seeking, reading and parsing) through the JNI + * component. */ public class LTTngTrace extends TmfTrace { - public static boolean PrintDebug = false; - public static boolean UniqueEvent = true; - - private final static boolean SHOW_LTT_DEBUG_DEFAULT = false; - private final static boolean IS_PARSING_NEEDED_DEFAULT = !UniqueEvent; - private final static int CHECKPOINT_PAGE_SIZE = 50000; - - // Reference to our JNI trace - private JniTrace currentJniTrace = null; - - // *** - // UNHACKED : We can no longer do that because TCF need to maintain several - // events at once. - // This is very slow to do so in LTTng, this has to be temporary. - // *** HACK *** - // To save time, we will declare all component of the LttngEvent during the - // construction of the trace - // Then, while reading the trace, we will just SET the values instead of - // declaring new object - // *** - LttngTimestamp eventTimestamp = null; - LttngEventSource eventSource = null; - LttngEventContent eventContent = null; - LttngEventReference eventReference = null; - - // The actual event - LttngEvent currentLttngEvent = null; - - // The current location - LttngLocation previousLocation = null; - - LttngEventType eventType = null; - // Hashmap of the possible types of events (Tracefile/CPU/Marker in the JNI) - HashMap traceTypes = null; - // This vector will be used to quickly find a marker name from a position - Vector traceTypeNames = null; - private String traceLibPath; - /** - * Default Constructor. - *

    - * - * @param path - * Path to a directory that contain an LTTng trace. - * - * @exception Exception - * (most likely LTTngTraceException or FileNotFoundException) - */ - public LTTngTrace(String path) throws Exception { - // Call with "wait for completion" true and "skip indexing" false - this(path, null, true, false); - } - - /** - * Constructor, with control over the indexing. - *

    - * - * @param path - * Path to a directory that contain an LTTng trace. - * @param waitForCompletion - * Should we wait for indexign to complete before moving on. - * - * @exception Exception - * (most likely LTTngTraceException or FileNotFoundException) - */ - public LTTngTrace(String path, boolean waitForCompletion) throws Exception { - // Call with "skip indexing" false - this(path, null, waitForCompletion, false); - } - - /** - * Default constructor, with control over the indexing and possibility to - * bypass indexation - *

    - * - * @param path - * Path to a directory that contain an LTTng trace. - * @param traceLibPath + public static boolean PrintDebug = false; + public static boolean UniqueEvent = true; + + private final static boolean SHOW_LTT_DEBUG_DEFAULT = false; + private final static boolean IS_PARSING_NEEDED_DEFAULT = !UniqueEvent; + private final static int CHECKPOINT_PAGE_SIZE = 50000; + + // Reference to our JNI trace + private JniTrace currentJniTrace = null; + + // *** + // UNHACKED : We can no longer do that because TCF need to maintain several + // events at once. + // This is very slow to do so in LTTng, this has to be temporary. + // *** HACK *** + // To save time, we will declare all component of the LttngEvent during the + // construction of the trace + // Then, while reading the trace, we will just SET the values instead of + // declaring new object + // *** + LttngTimestamp eventTimestamp = null; + LttngEventSource eventSource = null; + LttngEventContent eventContent = null; + LttngEventReference eventReference = null; + + // The actual event + LttngEvent currentLttngEvent = null; + + // The current location + LttngLocation previousLocation = null; + + LttngEventType eventType = null; + // Hashmap of the possible types of events (Tracefile/CPU/Marker in the JNI) + HashMap traceTypes = null; + // This vector will be used to quickly find a marker name from a position + Vector traceTypeNames = null; + private String traceLibPath = null; + + public LTTngTrace() { + } + + public boolean validate(IProject project, String path) { + if (super.validate(project, path)) { + String traceLibPath = TraceHelper.getTraceLibDirFromProject(project); + try { + LTTngTraceVersion version = new LTTngTraceVersion(path, traceLibPath); + return version.isValidLttngTrace(); + } catch (LttngException e) { + } + } + return false; + } + + @Override + public void initTrace(String path, Class eventType, boolean indexTrace) throws FileNotFoundException { + super.initTrace(path, eventType, indexTrace); + try { + currentJniTrace = JniTraceFactory.getJniTrace(path, traceLibPath, SHOW_LTT_DEBUG_DEFAULT); + } catch (Exception e) { + throw new FileNotFoundException(e.getMessage()); + } + + // Export all the event types from the JNI side + traceTypes = new HashMap(); + traceTypeNames = new Vector(); + initialiseEventTypes(currentJniTrace); + + // *** VERIFY *** + // Verify that all those "default constructor" are safe to use + eventTimestamp = new LttngTimestamp(); + eventSource = new LttngEventSource(); + this.eventType = new LttngEventType(); + eventContent = new LttngEventContent(currentLttngEvent); + eventReference = new LttngEventReference(this.getName()); + + // Create the skeleton event + currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, this.eventType, eventContent, + eventReference, null); + + // Create a new current location + previousLocation = new LttngLocation(); + + // Set the currentEvent to the eventContent + eventContent.setEvent(currentLttngEvent); + + // // Bypass indexing if asked + // if ( bypassIndexing == false ) { + // indexTrace(true); + // } + // else { + // Even if we don't have any index, set ONE checkpoint + // fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L) , new + // LttngLocation() ) ); + + // Set the time range of the trace + TmfContext context = seekLocation(null); + LttngEvent event = getNextEvent(context); + LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp()); + LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime()); + + setTimeRange(new TmfTimeRange(startTime, endTime)); + } + + /** + * Default Constructor. + *

    + * + * @param path + * Path to a directory that contain an LTTng trace. + * + * @exception Exception + * (most likely LTTngTraceException or FileNotFoundException) + */ + public LTTngTrace(String path) throws Exception { + // Call with "wait for completion" true and "skip indexing" false + this(path, null, true, false); + } + + /** + * Constructor, with control over the indexing. + *

    + * + * @param path + * Path to a directory that contain an LTTng trace. + * @param waitForCompletion + * Should we wait for indexign to complete before moving on. + * + * @exception Exception + * (most likely LTTngTraceException or FileNotFoundException) + */ + public LTTngTrace(String path, boolean waitForCompletion) throws Exception { + // Call with "skip indexing" false + this(path, null, waitForCompletion, false); + } + + /** + * Default constructor, with control over the indexing and possibility to bypass indexation + *

    + * + * @param path + * Path to a directory that contain an LTTng trace. + * @param traceLibPath * Path to a directory that contains LTTng trace libraries. - * @param waitForCompletion - * Should we wait for indexign to complete before moving on. - * @param bypassIndexing - * Should we bypass indexing completly? This is should only be - * useful for unit testing. - * - * @exception Exception - * (most likely LTTngTraceException or FileNotFoundException) - * - */ - public LTTngTrace(String path, String traceLibPath, boolean waitForCompletion, - boolean bypassIndexing) throws Exception { - super(path, LttngEvent.class, path, CHECKPOINT_PAGE_SIZE, false); - try { - currentJniTrace = JniTraceFactory.getJniTrace(path, traceLibPath, - SHOW_LTT_DEBUG_DEFAULT); - } catch (Exception e) { - throw new LTTngTraceException(e.getMessage()); - } - - this.traceLibPath = traceLibPath; - // Export all the event types from the JNI side - traceTypes = new HashMap(); - traceTypeNames = new Vector(); - initialiseEventTypes(currentJniTrace); - - // *** VERIFY *** - // Verify that all those "default constructor" are safe to use - eventTimestamp = new LttngTimestamp(); - eventSource = new LttngEventSource(); - eventType = new LttngEventType(); - eventContent = new LttngEventContent(currentLttngEvent); - eventReference = new LttngEventReference(this.getName()); - - // Create the skeleton event - currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, - eventType, eventContent, eventReference, null); - - // Create a new current location - previousLocation = new LttngLocation(); - - // Set the currentEvent to the eventContent - eventContent.setEvent(currentLttngEvent); - - // // Bypass indexing if asked - // if ( bypassIndexing == false ) { - // indexTrace(true); - // } - // else { - // Even if we don't have any index, set ONE checkpoint - // fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L) , new - // LttngLocation() ) ); - - // Set the time range of the trace - TmfContext context = seekLocation(null); - LttngEvent event = getNextEvent(context); - LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp()); - LttngTimestamp endTime = new LttngTimestamp(currentJniTrace - .getEndTime().getTime()); - - setTimeRange(new TmfTimeRange(startTime, endTime)); - - } - - /* - * Copy constructor is forbidden for LttngEvenmStream - */ - public LTTngTrace(LTTngTrace oldTrace) throws Exception { - this(oldTrace.getPath(),oldTrace.getTraceLibPath(), false, true); - - // *** VERIFY *** - // Is this safe? - this.fCheckpoints = oldTrace.fCheckpoints; - - /* - * // This would only work if the index is already done - * this.fCheckpoints = new Vector( - * oldTrace.fCheckpoints.size() ); for (int x = 0; - * x(); + traceTypeNames = new Vector(); + initialiseEventTypes(currentJniTrace); + + // *** VERIFY *** + // Verify that all those "default constructor" are safe to use + eventTimestamp = new LttngTimestamp(); + eventSource = new LttngEventSource(); + eventType = new LttngEventType(); + eventContent = new LttngEventContent(currentLttngEvent); + eventReference = new LttngEventReference(this.getName()); + + // Create the skeleton event + currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, eventType, eventContent, eventReference, + null); + + // Create a new current location + previousLocation = new LttngLocation(); + + // Set the currentEvent to the eventContent + eventContent.setEvent(currentLttngEvent); + + // // Bypass indexing if asked + // if ( bypassIndexing == false ) { + // indexTrace(true); + // } + // else { + // Even if we don't have any index, set ONE checkpoint + // fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L) , new + // LttngLocation() ) ); + + // Set the time range of the trace + TmfContext context = seekLocation(null); + LttngEvent event = getNextEvent(context); + LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp()); + LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime()); + + setTimeRange(new TmfTimeRange(startTime, endTime)); + } + + /* + * Copy constructor is forbidden for LttngEvenmStream + */ + public LTTngTrace(LTTngTrace oldTrace) throws Exception { + this(oldTrace.getPath(), oldTrace.getTraceLibPath(), false, true); + + // *** VERIFY *** + // Is this safe? + this.fCheckpoints = oldTrace.fCheckpoints; + + /* + * // This would only work if the index is already done this.fCheckpoints = new Vector( + * oldTrace.fCheckpoints.size() ); for (int x = 0; x(); - clone.traceTypeNames = new Vector(); - clone.initialiseEventTypes(clone.currentJniTrace); - - // Verify that all those "default constructor" are safe to use - clone.eventTimestamp = new LttngTimestamp(); - clone.eventSource = new LttngEventSource(); - clone.eventType = new LttngEventType(); - clone.eventContent = new LttngEventContent(clone.currentLttngEvent); - clone.eventReference = new LttngEventReference(this.getName()); - - // Create the skeleton event - clone.currentLttngEvent = new LttngEvent(this, - clone.eventTimestamp, clone.eventSource, clone.eventType, - clone.eventContent, clone.eventReference, null); - - // Create a new current location - clone.previousLocation = new LttngLocation(); - - // Set the currentEvent to the eventContent - clone.eventContent.setEvent(clone.currentLttngEvent); - - // Set the start time of the trace - setTimeRange(new TmfTimeRange(new LttngTimestamp( - clone.currentJniTrace.getStartTime().getTime()), - new LttngTimestamp(clone.currentJniTrace.getEndTime() - .getTime()))); - } catch (CloneNotSupportedException e) { - } - - return clone; - } - - public String getTraceLibPath() { - return traceLibPath; - } - - /* - * Fill out the HashMap with "Type" (Tracefile/Marker) - * - * This should be called at construction once the trace is open - */ - private void initialiseEventTypes(JniTrace trace) { - // Work variables - LttngEventType tmpType = null; - String[] markerFieldsLabels = null; - - String newTracefileKey = null; - Integer newMarkerKey = null; - - JniTracefile newTracefile = null; - JniMarker newMarker = null; - - // First, obtain an iterator on TRACEFILES of owned by the TRACE - Iterator tracefileItr = trace.getTracefilesMap().keySet() - .iterator(); - - while (tracefileItr.hasNext()) { - newTracefileKey = tracefileItr.next(); - newTracefile = trace.getTracefilesMap().get(newTracefileKey); - - // From the TRACEFILE read, obtain its MARKER - Iterator markerItr = newTracefile.getTracefileMarkersMap() - .keySet().iterator(); - while (markerItr.hasNext()) { - newMarkerKey = markerItr.next(); - newMarker = newTracefile.getTracefileMarkersMap().get( - newMarkerKey); - - // From the MARKER we can obtain the MARKERFIELDS keys (i.e. - // labels) - markerFieldsLabels = newMarker - .getMarkerFieldsHashMap() - .keySet() - .toArray( - new String[newMarker.getMarkerFieldsHashMap() - .size()]); - - tmpType = new LttngEventType(newTracefile.getTracefileName(), - newTracefile.getCpuNumber(), newMarker.getName(), - newMarkerKey.intValue(), markerFieldsLabels); - - // Add the type to the map/vector - addEventTypeToMap(tmpType); - } - } - } - - /* - * Add a new type to the HashMap - * - * As the hashmap use a key format that is a bit dangerous to use, we should - * always add using this function. - */ - private void addEventTypeToMap(LttngEventType newEventType) { - int newTypeKey = EventTypeKey.getEventTypeHash(newEventType); - - this.traceTypes.put(newTypeKey, newEventType); - this.traceTypeNames.add(newTypeKey); - } - - // /** - // * Index the current trace. - // * - // * @param useless This boolean is only to comply to the interface and will - // be ignored. - // */ - // @Override - // public synchronized void indexTrace(boolean useless) { - // - // long nbEvents=0L; - // - // // Start time need to be null to detect none have been set - // // LastTime need to exist so we can ajust it as we go - // LttngTimestamp startTime = null; - // LttngTimestamp lastTime = new LttngTimestamp(); - // - // // Position the trace at the beginning - // TmfContext context = seekEvent( new LttngTimestamp(0L) ); - // - // // Read the first event and extract the location - // LttngEvent tmpEvent = (LttngEvent)getNextEvent(context); - // - // // If we read the first event, define the start time. - // if ( tmpEvent != null ) { - // startTime = new LttngTimestamp( tmpEvent.getTimestamp() ); - // lastTime.setValue(tmpEvent.getTimestamp().getValue()); - // } - // - // // Now, we read each event until we hit the end of the trace - // // We will create a new checkpoint every "getCacheSize()" event - // while ( tmpEvent != null) { - // // Update the last time each time we read a new event - // lastTime.setValue(tmpEvent.getTimestamp().getValue()); - // - // // Save a check point if needed - // if ((nbEvents++ % getCacheSize()) == 0) { - // // *** IMPORTANT - // // We need to NEW each stuff we put in checkpoint - // // Otherwise everything will be the same! - // LttngTimestamp tmpTimestamp = new LttngTimestamp( - // (LttngTimestamp)tmpEvent.getTimestamp() ); - // LttngLocation newLocation = new LttngLocation( - // (LttngTimestamp)tmpEvent.getTimestamp() ); - // - // fCheckpoints.add(new TmfCheckpoint(tmpTimestamp, newLocation ) ); - // } - // // Read the next event - // tmpEvent = (LttngEvent)getNextEvent(context); - // } - // - // // If we have a start time, we should have an end time as well - // // Issue the new range - // if (startTime != null) { - // setTimeRange( new TmfTimeRange(startTime, lastTime) ); - // notifyListeners(getTimeRange() ); - // } - // - // // Ajust the total number of event in the trace - // fNbEvents = nbEvents; - // //printCheckpointsVector(); - // //printDebug = true; - // } - - /** - * Return the latest saved location. Note : Modifying the returned location - * may result in buggy positionning! - * - * @return The LttngLocation as it was after the last operation. - * - * @see org.eclipse.linuxtools.lttng.event.LttngLocation - */ - @Override - public synchronized ITmfLocation getCurrentLocation() { - return previousLocation; - } - - /** - * Position the trace to the event at the given location. - *

    - * NOTE : Seeking by location is very fast compare to seeking by position - * but is still slower than "ReadNext", avoid using it for small interval. - * - * @param location - * Location of the event in the trace. If no event available at - * this exact location, we will position ourself to the next one. - * - * @return The TmfContext that point to this event - * - * @see org.eclipse.linuxtools.lttng.event.LttngLocation - * @see org.eclipse.linuxtools.tmf.trace.TmfContext - */ - @Override - public synchronized TmfContext seekLocation(ITmfLocation location) { - - // // [lmcfrch] - // lastTime = 0; - - if (PrintDebug) { - System.out - .println("seekLocation(location) location -> " + location); //$NON-NLS-1$ - } - - // If the location in context is null, create a new one - LttngLocation curLocation = null; - if (location == null) { - curLocation = new LttngLocation(); - TmfContext context = seekEvent(curLocation.getOperationTime()); - context.setRank(ITmfContext.INITIAL_RANK); - return context; - } else { - curLocation = (LttngLocation) location; - } - - // *** NOTE : - // Update to location should (and will) be done in SeekEvent. - - // The only seek valid in LTTng is with the time, we call - // seekEvent(timestamp) - TmfContext context = seekEvent(curLocation.getOperationTime()); - - // // Adjust the previousLocation flags - // if (location instanceof LttngLocation) { - // LttngLocation lttngLocation = (LttngLocation) location; - // if (lttngLocation.isLastOperationReadNext()) { - // previousLocation.setLastOperationReadNext(); - // } else if (lttngLocation.isLastOperationParse()) { - // previousLocation.setLastOperationParse(); - // } else if (lttngLocation.isLastOperationSeek()) { - // previousLocation.setLastOperationSeek(); - // } - // } - - return context; - } - - /** - * Position the trace to the event at the given time. - *

    - * NOTE : Seeking by time is very fast compare to seeking by position but is - * still slower than "ReadNext", avoid using it for small interval. - * - * @param timestamp - * Time of the event in the trace. If no event available at this - * exact time, we will position ourself to the next one. - * - * @return The TmfContext that point to this event - * - * @see org.eclipse.linuxtools.lttng.event.LttngLocation - * @see org.eclipse.linuxtools.tmf.trace.TmfContext - */ - @Override - public synchronized TmfContext seekEvent(TmfTimestamp timestamp) { - - // // [lmcfrch] - // lastTime = 0; - - if (PrintDebug) { - System.out - .println("seekEvent(timestamp) timestamp -> " + timestamp); //$NON-NLS-1$ - } - - // Call JNI to seek - currentJniTrace.seekToTime(new JniTime(timestamp.getValue())); - - // Save the time at which we seeked - previousLocation.setOperationTime(timestamp.getValue()); - // Set the operation marker as seek, to be able to detect we did "seek" - // this event - previousLocation.setLastOperationSeek(); - - // *** VERIFY *** - // Is that too paranoid? - // - // We don't trust what upper level could do with our internal location - // so we create a new one to return instead - LttngLocation curLocation = new LttngLocation(previousLocation); - - return new TmfContext(curLocation); - } - - /** - * Position the trace to the event at the given position (rank). - *

    - * NOTE : Seeking by position is very slow in LTTng, consider seeking by - * timestamp. - * - * @param position - * Position (or rank) of the event in the trace, starting at 0. - * - * @return The TmfContext that point to this event - * - * @see org.eclipse.linuxtools.lttng.event.LttngLocation - * @see org.eclipse.linuxtools.tmf.trace.TmfContext - */ - @Override - public synchronized TmfContext seekEvent(long position) { - - if (PrintDebug) { - System.out.println("seekEvent(position) position -> " + position); //$NON-NLS-1$ - } - - TmfTimestamp timestamp = null; - long index = position / getCacheSize(); - - // Get the timestamp of the closest check point to the given position - if (fCheckpoints.size() > 0) { - if (index >= fCheckpoints.size()) { - index = fCheckpoints.size() - 1; - } - timestamp = fCheckpoints.elementAt((int) index) - .getTimestamp(); - } - // If none, take the start time of the trace - else { - timestamp = getStartTime(); - } - - // Seek to the found time - TmfContext tmpContext = seekEvent(timestamp); - tmpContext.setRank((index + 1) * fIndexPageSize); - previousLocation = (LttngLocation) tmpContext.getLocation(); - - // Ajust the index of the event we found at this check point position - Long currentPosition = index * getCacheSize(); - - Long lastTimeValueRead = 0L; - - // Get the event at current position. This won't move to the next one - JniEvent tmpJniEvent = currentJniTrace.findNextEvent(); - // Now that we are positionned at the checkpoint, - // we need to "readNext" (Position - CheckpointPosition) times or until - // trace "run out" - while ((tmpJniEvent != null) && (currentPosition < position)) { - tmpJniEvent = currentJniTrace.readNextEvent(); - currentPosition++; - } - - // If we found our event, save its timestamp - if (tmpJniEvent != null) { - lastTimeValueRead = tmpJniEvent.getEventTime().getTime(); - } - - // Set the operation marker as seek, to be able to detect we did "seek" - // this event - previousLocation.setLastOperationSeek(); - // Save read event time - previousLocation.setOperationTime(lastTimeValueRead); - - // *** VERIFY *** - // Is that too paranoid? - // - // We don't trust what upper level could do with our internal location - // so we create a new one to return instead - LttngLocation curLocation = new LttngLocation(previousLocation); - - return new TmfContext(curLocation); - } - - @Override - public TmfContext seekLocation(double ratio) { - // TODO Auto-generated method stub - return null; - } - - @Override - public double getLocationRatio(ITmfLocation location) { - // TODO Auto-generated method stub - return 0; - } - - /** - * Return the event in the trace according to the given context. Read it if - * necessary. - *

    - * Similar (same?) as ParseEvent except that calling GetNext twice read the - * next one the second time. - * - * @param context - * Current TmfContext where to get the event - * - * @return The LttngEvent we read of null if no event are available - * - * @see org.eclipse.linuxtools.lttng.event.LttngLocation - * @see org.eclipse.linuxtools.tmf.trace.TmfContext - */ - - public int nbEventsRead = 0; - - @Override - public synchronized LttngEvent getNextEvent(TmfContext context) { - - if (PrintDebug) { - System.out - .println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$ - + context.getLocation()); - } - - LttngEvent returnedEvent = null; - LttngLocation curLocation = null; - - curLocation = (LttngLocation)context.getLocation(); - // If the location in context is null, create a new one - if ( curLocation == null ) { - curLocation = getCurrentLocation(context); - } - - // // [lmcfrch] - // TmfContext savedContext = context.clone(); - // // [/lmcfrch] - - // *** HACK *** - // TMF assumes it is possible to read (GetNextEvent) to the next Event - // once ParseEvent() is called - // In LTTNG, there is not difference between "Parsing" and "Reading" an - // event. - // Since parsing/reading invalidate the previous event, - // we need to make sure the sequence ParseEvent() -> GetNextEvent() will - // not actually move to the next event. - // To do so, we avoid moving for call to "GetNextEvent()" that follow - // call to a call to "ParseEvent()". - // However, calling ParseEvent() -> GetNextEvent() -> GetNextEvent() - // will only move next by one. - - // *** Positioning trick : - // GetNextEvent only read the trace if : - // 1- The last operation was NOT a ParseEvent --> A read is required - // OR - // 2- The time of the previous location is different from the current - // one --> A seek + a read is required - if ((!(curLocation.isLastOperationParse())) - || (previousLocation.getOperationTimeValue() != curLocation - .getOperationTimeValue())) { - if (previousLocation.getOperationTimeValue() != curLocation - .getOperationTimeValue()) { - if (PrintDebug) { - System.out - .println("\t\tSeeking in getNextEvent. [ LastTime : " //$NON-NLS-1$ - + previousLocation.getOperationTimeValue() - + " CurrentTime" //$NON-NLS-1$ - + curLocation.getOperationTimeValue() - + " ]"); //$NON-NLS-1$ - } - seekEvent(curLocation.getOperationTime()); - } - // Read the next event from the trace. The last one will NO LONGER - // BE VALID. - returnedEvent = readNextEvent(curLocation); - - } else { - // No event was read, just return the one currently loaded (the last - // one we read) - returnedEvent = currentLttngEvent; - - // *** IMPORTANT! - // Reset (erase) the operation marker to both location, to be able - // to detect we did NOT "read" this event - previousLocation.resetLocationState(); - curLocation.resetLocationState(); - } - - // If we read an event, set it's time to the locations (both previous - // and current) - if (returnedEvent != null) { - setPreviousAndCurrentTimes(context, returnedEvent, curLocation); - - // // [lmcfrch] - // LttngLocation prevLocation = (LttngLocation) - // savedContext.getLocation(); - // LttngLocation currLocation = (LttngLocation) - // context.getLocation(); - // if (prevLocation.equals(currLocation)) { - // System.out.println("Aie"); - // } - // Tracer.trace("Trc: " + context.getRank() + ": " + - // returnedEvent.getTimestamp().toString() + " (" + - // (prevLocation.isLastOperationParse() ? "T" : "F") + "," + - // (prevLocation.isLastOperationReadNext() ? "T" : "F") + "," + - // (prevLocation.isLastOperationSeek() ? "T" : "F") + "), (" + - // (currLocation.isLastOperationParse() ? "T" : "F") + "," + - // (currLocation.isLastOperationReadNext() ? "T" : "F") + "," + - // (currLocation.isLastOperationSeek() ? "T" : "F") + ")" - // ); - // // [/lmcfrch] - - - } - - return returnedEvent; - } - - // this method was extracted for profiling purposes - private void setPreviousAndCurrentTimes(TmfContext context, LttngEvent returnedEvent, - LttngLocation curLocation) { - - TmfTimestamp eventTimestamp = returnedEvent.getTimestamp(); - //long eventTime = eventTimestamp.getValue(); - previousLocation.setOperationTime(eventTimestamp.getValue()); - curLocation.setOperationTime(eventTimestamp.getValue()); - updateIndex(context, context.getRank(), eventTimestamp); - context.updateRank(1); - } - - protected void updateIndex(TmfContext context, long rank, TmfTimestamp timestamp) { - - if (getStartTime().compareTo(timestamp, false) > 0) setStartTime( timestamp ); - if (getEndTime().compareTo(timestamp, false) < 0) setEndTime(timestamp ); - if (rank != ITmfContext.UNKNOWN_RANK) { - if (fNbEvents <= rank) - fNbEvents = rank + 1; - // Build the index as we go along - if ((rank % fIndexPageSize) == 0) { - // Determine the table position - long position = rank / fIndexPageSize; - // Add new entry at proper location (if empty) - if (fCheckpoints.size() == position) { - addCheckPoint(context, timestamp); - } - } - } - } - - private void addCheckPoint(TmfContext context, TmfTimestamp timestamp) { - ITmfLocation location = context.getLocation().clone(); - fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location)); - } - - // this method was extracted for profiling purposes - private LttngEvent readNextEvent(LttngLocation curLocation) { - LttngEvent returnedEvent; - // Read the next event from the trace. The last one will NO LONGER BE VALID. - returnedEvent = readEvent(curLocation); - nbEventsRead++; - - // Set the operation marker as read to both location, to be able to detect we did "read" this event - previousLocation.setLastOperationReadNext(); - curLocation.setLastOperationReadNext(); - return returnedEvent; - } - - // this method was extracted for profiling purposes - private LttngLocation getCurrentLocation(TmfContext context) { - LttngLocation curLocation; - curLocation = new LttngLocation(); - context.setLocation(curLocation); - return curLocation; - } - /** - * Return the event in the trace according to the given context. Read it if - * necessary. - *

    - * Similar (same?) as GetNextEvent except that calling ParseEvent twice will - * return the same event - * - * @param context - * Current TmfContext where to get the event - * - * @return The LttngEvent we read of null if no event are available - * - * @see org.eclipse.linuxtools.lttng.event.LttngLocation - * @see org.eclipse.linuxtools.tmf.trace.TmfContext - */ - @Override - public synchronized LttngEvent parseEvent(TmfContext context) { - - if (PrintDebug) { - System.out.println("parseEvent(context) context.getLocation() -> " //$NON-NLS-1$ - + context.getLocation()); - } - - LttngEvent returnedEvent = null; - LttngLocation curLocation = null; - - // If the location in context is null, create a new one - if (context.getLocation() == null) { - curLocation = new LttngLocation(); - context.setLocation(curLocation); - } - // Otherwise, we use the one in context; it should be a valid - // LttngLocation - else { - curLocation = (LttngLocation) context.getLocation(); - } - - // *** HACK *** - // TMF assumes it is possible to read (GetNextEvent) to the next Event - // once ParseEvent() is called - // In LTTNG, there is not difference between "Parsing" and "Reading" an - // event. - // So, before "Parsing" an event, we have to make sure we didn't "Read" - // it alreafy. - // Also, "Reading" invalidate the previous Event in LTTNG and seek back - // is very costly, - // so calling twice "Parse" will return the same event, giving a way to - // get the "Currently loaded" event - - // *** Positionning trick : - // ParseEvent only read the trace if : - // 1- The last operation was NOT a ParseEvent or a GetNextEvent --> A - // read is required - // OR - // 2- The time of the previous location is different from the current - // one --> A seek + a read is required - if (((!(curLocation.isLastOperationParse())) && ((!(curLocation - .isLastOperationReadNext())))) - || (previousLocation.getOperationTimeValue() != curLocation - .getOperationTimeValue())) { - // Previous time != Current time : We need to reposition to the - // current time - if (previousLocation.getOperationTimeValue() != curLocation - .getOperationTimeValue()) { - if (PrintDebug) { - System.out - .println("\t\tSeeking in getNextEvent. [ LastTime : " //$NON-NLS-1$ - + previousLocation.getOperationTimeValue() - + " CurrentTime" //$NON-NLS-1$ - + curLocation.getOperationTimeValue() - + " ]"); //$NON-NLS-1$ - } - seekEvent(curLocation.getOperationTime()); - } - - // Read the next event from the trace. The last one will NO LONGER - // BE VALID. - returnedEvent = readEvent(curLocation); - } else { - // No event was read, just return the one currently loaded (the last - // one we read) - returnedEvent = currentLttngEvent; - } - - // If we read an event, set it's time to the locations (both previous - // and current) - if (returnedEvent != null) { - previousLocation.setOperationTime((LttngTimestamp) returnedEvent - .getTimestamp()); - curLocation.setOperationTime((LttngTimestamp) returnedEvent - .getTimestamp()); - } - - // Set the operation marker as parse to both location, to be able to - // detect we already "read" this event - previousLocation.setLastOperationParse(); - curLocation.setLastOperationParse(); - - return returnedEvent; - } - - /* - * Read the next event from the JNI and convert it as Lttng Event

    - * - * @param location Current LttngLocation that to be updated with the event - * timestamp - * - * @return The LttngEvent we read of null if no event are available - * - * @see org.eclipse.linuxtools.lttng.event.LttngLocation - * - * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace - */ - private synchronized LttngEvent readEvent(LttngLocation location) { - LttngEvent returnedEvent = null; - JniEvent tmpEvent = null; - - // Read the next event from JNI. THIS WILL INVALIDATE THE CURRENT LTTNG - // EVENT. - tmpEvent = currentJniTrace.readNextEvent(); - - if (tmpEvent != null) { - // *** NOTE - // Convert will update the currentLttngEvent - returnedEvent = convertJniEventToTmf(tmpEvent); - - location.setOperationTime((LttngTimestamp) returnedEvent - .getTimestamp()); - } - // *** NOTE - // If the read failed (likely the last event in the trace), set the - // LastReadTime to the JNI time - // That way, even if we try to read again, we will step over the bogus - // seek and read - else { - location.setOperationTime(getEndTime().getValue() + 1); - } - - return returnedEvent; - } - - /** - * Method to convert a JniEvent into a LttngEvent. - *

    - * - * Note : This method will call LttngEvent convertEventJniToTmf(JniEvent, - * boolean) with a default value for isParsingNeeded - * - * @param newEvent - * The JniEvent to convert into LttngEvent - * - * @return The converted LttngEvent - * - * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent - * @see org.eclipse.linuxtools.lttng.event.LttngEvent - */ - public synchronized LttngEvent convertJniEventToTmf(JniEvent newEvent) { - currentLttngEvent = convertJniEventToTmf(newEvent, - IS_PARSING_NEEDED_DEFAULT); - - return currentLttngEvent; - } - - /** - * Method to convert a JniEvent into a LttngEvent - * - * @param jniEvent - * The JniEvent to convert into LttngEvent - * @param isParsingNeeded - * A boolean value telling if the event should be parsed or not. - * - * @return The converted LttngEvent - * - * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent - * @see org.eclipse.linuxtools.lttng.event.LttngEvent - */ - public synchronized LttngEvent convertJniEventToTmf(JniEvent jniEvent, - boolean isParsingNeeded) { - - if (UniqueEvent) { - - // *** - // UNHACKED : We can no longer do that because TCF need to maintain - // several events at once. - // This is very slow to do so in LTTng, this has to be temporary. - // *** HACK *** - // To save time here, we only set value instead of allocating new - // object - // This give an HUGE performance improvement - // all allocation done in the LttngTrace constructor - // *** - eventTimestamp.setValue(jniEvent.getEventTime().getTime()); - eventSource.setSourceId(jniEvent.requestEventSource()); - - eventType = traceTypes.get(EventTypeKey.getEventTypeHash(jniEvent)); - - eventReference.setValue(jniEvent.getParentTracefile() - .getTracefilePath()); - eventReference.setTracepath(this.getName()); - - eventContent.emptyContent(); - - currentLttngEvent.setType(eventType); - // Save the jni reference - currentLttngEvent.updateJniEventReference(jniEvent); - - // Parse now if was asked - // Warning : THIS IS SLOW - if (isParsingNeeded) { - eventContent.getFields(); - } - - return currentLttngEvent; - } else { - return convertJniEventToTmfMultipleEventEvilFix(jniEvent, - isParsingNeeded); - } - - } - - /** - * This method is a temporary fix to support multiple events at once in TMF - * This is expected to be slow and should be fixed in another way. See - * comment in convertJniEventToTmf(); - * - * @param jniEvent - * The current JNI Event - * @return Current Lttng Event fully parsed - */ - private synchronized LttngEvent convertJniEventToTmfMultipleEventEvilFix( - JniEvent jniEvent, boolean isParsingNeeded) { - // *** HACK *** - // Below : the "fix" with all the new and the full-parse - // Allocating new memory is slow. - // Parsing every events is very slow. - eventTimestamp = new LttngTimestamp(jniEvent.getEventTime().getTime()); - eventSource = new LttngEventSource(jniEvent.requestEventSource()); - eventReference = new LttngEventReference(jniEvent.getParentTracefile() - .getTracefilePath(), this.getName()); - eventType = new LttngEventType(traceTypes.get(EventTypeKey - .getEventTypeHash(jniEvent))); - eventContent = new LttngEventContent(currentLttngEvent); - currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, - eventType, eventContent, eventReference, null); - - // The jni reference is no longer reliable but we will keep it anyhow - currentLttngEvent.updateJniEventReference(jniEvent); - // Ensure that the content is correctly set - eventContent.setEvent(currentLttngEvent); - - // Parse the event if it was needed - // *** WARNING *** - // ONLY for testing, NOT parsing events with non-unique events WILL - // result in segfault in the JVM - if (isParsingNeeded) { - eventContent.getFields(); - } - - return currentLttngEvent; - } - - /** - * Reference to the current LttngTrace we are reading from. - *

    - * - * Note : This bypass the framework and should not be use, except for - * testing! - * - * @return Reference to the current LttngTrace - * - * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace - */ - public JniTrace getCurrentJniTrace() { - return currentJniTrace; - } - - /** - * Return a reference to the current LttngEvent we have in memory. - * - * @return The current (last read) LttngEvent - * - * @see org.eclipse.linuxtools.lttng.event.LttngEvent - */ - public synchronized LttngEvent getCurrentEvent() { - return currentLttngEvent; - } - - /** - * Get the major version number for the current trace - * - * @return Version major or -1 if unknown - * - * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace - * - */ - public short getVersionMajor() { - if (currentJniTrace != null) { - return currentJniTrace.getLttMajorVersion(); - } else { - return -1; - } - } - - /** - * Get the minor version number for the current trace - * - * @return Version minor or -1 if unknown - * - * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace - * - */ - public short getVersionMinor() { - if (currentJniTrace != null) { - return currentJniTrace.getLttMinorVersion(); - } else { - return -1; - } - } - - /** - * Get the number of CPU for this trace - * - * @return Number of CPU or -1 if unknown - * - * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace - * - */ - public int getCpuNumber() { - if (currentJniTrace != null) { - return currentJniTrace.getCpuNumber(); - } else { - return -1; - } - } - - /** - * Print the content of the checkpoint vector. - *

    - * - * This is intended for debug purpose only. - */ - public void printCheckpointsVector() { - System.out.println("StartTime : " //$NON-NLS-1$ - + getTimeRange().getStartTime().getValue()); - System.out.println("EndTime : " //$NON-NLS-1$ - + getTimeRange().getEndTime().getValue()); - - for (int pos = 0; pos < fCheckpoints.size(); pos++) { - System.out.print(pos + ": " + "\t"); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.print(fCheckpoints.get(pos).getTimestamp() + "\t"); //$NON-NLS-1$ - System.out.println(fCheckpoints.get(pos).getLocation()); - } - } - - @Override - public synchronized void dispose() { - currentJniTrace.closeTrace(); - super.dispose(); - } - - /** - * Return a String identifying this trace. - * - * @return String that identify this trace - */ - @Override + LTTngTrace clone = null; + try { + clone = (LTTngTrace) super.clone(); + try { + clone.currentJniTrace = JniTraceFactory.getJniTrace(getPath(), getTraceLibPath(), + SHOW_LTT_DEBUG_DEFAULT); + } catch (JniException e) { + // e.printStackTrace(); + } + + // Export all the event types from the JNI side + clone.traceTypes = new HashMap(); + clone.traceTypeNames = new Vector(); + clone.initialiseEventTypes(clone.currentJniTrace); + + // Verify that all those "default constructor" are safe to use + clone.eventTimestamp = new LttngTimestamp(); + clone.eventSource = new LttngEventSource(); + clone.eventType = new LttngEventType(); + clone.eventContent = new LttngEventContent(clone.currentLttngEvent); + clone.eventReference = new LttngEventReference(this.getName()); + + // Create the skeleton event + clone.currentLttngEvent = new LttngEvent(this, clone.eventTimestamp, clone.eventSource, clone.eventType, + clone.eventContent, clone.eventReference, null); + + // Create a new current location + clone.previousLocation = new LttngLocation(); + + // Set the currentEvent to the eventContent + clone.eventContent.setEvent(clone.currentLttngEvent); + + // Set the start time of the trace + setTimeRange(new TmfTimeRange(new LttngTimestamp(clone.currentJniTrace.getStartTime().getTime()), + new LttngTimestamp(clone.currentJniTrace.getEndTime().getTime()))); + } catch (CloneNotSupportedException e) { + } + + return clone; + } + + public String getTraceLibPath() { + return traceLibPath; + } + + /* + * Fill out the HashMap with "Type" (Tracefile/Marker) + * + * This should be called at construction once the trace is open + */ + private void initialiseEventTypes(JniTrace trace) { + // Work variables + LttngEventType tmpType = null; + String[] markerFieldsLabels = null; + + String newTracefileKey = null; + Integer newMarkerKey = null; + + JniTracefile newTracefile = null; + JniMarker newMarker = null; + + // First, obtain an iterator on TRACEFILES of owned by the TRACE + Iterator tracefileItr = trace.getTracefilesMap().keySet().iterator(); + + while (tracefileItr.hasNext()) { + newTracefileKey = tracefileItr.next(); + newTracefile = trace.getTracefilesMap().get(newTracefileKey); + + // From the TRACEFILE read, obtain its MARKER + Iterator markerItr = newTracefile.getTracefileMarkersMap().keySet().iterator(); + while (markerItr.hasNext()) { + newMarkerKey = markerItr.next(); + newMarker = newTracefile.getTracefileMarkersMap().get(newMarkerKey); + + // From the MARKER we can obtain the MARKERFIELDS keys (i.e. + // labels) + markerFieldsLabels = newMarker.getMarkerFieldsHashMap().keySet() + .toArray(new String[newMarker.getMarkerFieldsHashMap().size()]); + + tmpType = new LttngEventType(newTracefile.getTracefileName(), newTracefile.getCpuNumber(), + newMarker.getName(), newMarkerKey.intValue(), markerFieldsLabels); + + // Add the type to the map/vector + addEventTypeToMap(tmpType); + } + } + } + + /* + * Add a new type to the HashMap + * + * As the hashmap use a key format that is a bit dangerous to use, we should always add using this function. + */ + private void addEventTypeToMap(LttngEventType newEventType) { + int newTypeKey = EventTypeKey.getEventTypeHash(newEventType); + + this.traceTypes.put(newTypeKey, newEventType); + this.traceTypeNames.add(newTypeKey); + } + + // /** + // * Index the current trace. + // * + // * @param useless This boolean is only to comply to the interface and will + // be ignored. + // */ + // @Override + // public synchronized void indexTrace(boolean useless) { + // + // long nbEvents=0L; + // + // // Start time need to be null to detect none have been set + // // LastTime need to exist so we can ajust it as we go + // LttngTimestamp startTime = null; + // LttngTimestamp lastTime = new LttngTimestamp(); + // + // // Position the trace at the beginning + // TmfContext context = seekEvent( new LttngTimestamp(0L) ); + // + // // Read the first event and extract the location + // LttngEvent tmpEvent = (LttngEvent)getNextEvent(context); + // + // // If we read the first event, define the start time. + // if ( tmpEvent != null ) { + // startTime = new LttngTimestamp( tmpEvent.getTimestamp() ); + // lastTime.setValue(tmpEvent.getTimestamp().getValue()); + // } + // + // // Now, we read each event until we hit the end of the trace + // // We will create a new checkpoint every "getCacheSize()" event + // while ( tmpEvent != null) { + // // Update the last time each time we read a new event + // lastTime.setValue(tmpEvent.getTimestamp().getValue()); + // + // // Save a check point if needed + // if ((nbEvents++ % getCacheSize()) == 0) { + // // *** IMPORTANT + // // We need to NEW each stuff we put in checkpoint + // // Otherwise everything will be the same! + // LttngTimestamp tmpTimestamp = new LttngTimestamp( + // (LttngTimestamp)tmpEvent.getTimestamp() ); + // LttngLocation newLocation = new LttngLocation( + // (LttngTimestamp)tmpEvent.getTimestamp() ); + // + // fCheckpoints.add(new TmfCheckpoint(tmpTimestamp, newLocation ) ); + // } + // // Read the next event + // tmpEvent = (LttngEvent)getNextEvent(context); + // } + // + // // If we have a start time, we should have an end time as well + // // Issue the new range + // if (startTime != null) { + // setTimeRange( new TmfTimeRange(startTime, lastTime) ); + // notifyListeners(getTimeRange() ); + // } + // + // // Ajust the total number of event in the trace + // fNbEvents = nbEvents; + // //printCheckpointsVector(); + // //printDebug = true; + // } + + /** + * Return the latest saved location. Note : Modifying the returned location may result in buggy positionning! + * + * @return The LttngLocation as it was after the last operation. + * + * @see org.eclipse.linuxtools.lttng.event.LttngLocation + */ + @Override + public synchronized ITmfLocation getCurrentLocation() { + return previousLocation; + } + + /** + * Position the trace to the event at the given location. + *

    + * NOTE : Seeking by location is very fast compare to seeking by position but is still slower than "ReadNext", avoid + * using it for small interval. + * + * @param location + * Location of the event in the trace. If no event available at this exact location, we will position + * ourself to the next one. + * + * @return The TmfContext that point to this event + * + * @see org.eclipse.linuxtools.lttng.event.LttngLocation + * @see org.eclipse.linuxtools.tmf.trace.TmfContext + */ + @Override + public synchronized TmfContext seekLocation(ITmfLocation location) { + + // // [lmcfrch] + // lastTime = 0; + + if (PrintDebug) { + System.out.println("seekLocation(location) location -> " + location); //$NON-NLS-1$ + } + + // If the location in context is null, create a new one + LttngLocation curLocation = null; + if (location == null) { + curLocation = new LttngLocation(); + TmfContext context = seekEvent(curLocation.getOperationTime()); + context.setRank(ITmfContext.INITIAL_RANK); + return context; + } else { + curLocation = (LttngLocation) location; + } + + // *** NOTE : + // Update to location should (and will) be done in SeekEvent. + + // The only seek valid in LTTng is with the time, we call + // seekEvent(timestamp) + TmfContext context = seekEvent(curLocation.getOperationTime()); + + // // Adjust the previousLocation flags + // if (location instanceof LttngLocation) { + // LttngLocation lttngLocation = (LttngLocation) location; + // if (lttngLocation.isLastOperationReadNext()) { + // previousLocation.setLastOperationReadNext(); + // } else if (lttngLocation.isLastOperationParse()) { + // previousLocation.setLastOperationParse(); + // } else if (lttngLocation.isLastOperationSeek()) { + // previousLocation.setLastOperationSeek(); + // } + // } + + return context; + } + + /** + * Position the trace to the event at the given time. + *

    + * NOTE : Seeking by time is very fast compare to seeking by position but is still slower than "ReadNext", avoid + * using it for small interval. + * + * @param timestamp + * Time of the event in the trace. If no event available at this exact time, we will position ourself to + * the next one. + * + * @return The TmfContext that point to this event + * + * @see org.eclipse.linuxtools.lttng.event.LttngLocation + * @see org.eclipse.linuxtools.tmf.trace.TmfContext + */ + @Override + public synchronized TmfContext seekEvent(TmfTimestamp timestamp) { + + // // [lmcfrch] + // lastTime = 0; + + if (PrintDebug) { + System.out.println("seekEvent(timestamp) timestamp -> " + timestamp); //$NON-NLS-1$ + } + + // Call JNI to seek + currentJniTrace.seekToTime(new JniTime(timestamp.getValue())); + + // Save the time at which we seeked + previousLocation.setOperationTime(timestamp.getValue()); + // Set the operation marker as seek, to be able to detect we did "seek" + // this event + previousLocation.setLastOperationSeek(); + + // *** VERIFY *** + // Is that too paranoid? + // + // We don't trust what upper level could do with our internal location + // so we create a new one to return instead + LttngLocation curLocation = new LttngLocation(previousLocation); + + return new TmfContext(curLocation); + } + + /** + * Position the trace to the event at the given position (rank). + *

    + * NOTE : Seeking by position is very slow in LTTng, consider seeking by timestamp. + * + * @param position + * Position (or rank) of the event in the trace, starting at 0. + * + * @return The TmfContext that point to this event + * + * @see org.eclipse.linuxtools.lttng.event.LttngLocation + * @see org.eclipse.linuxtools.tmf.trace.TmfContext + */ + @Override + public synchronized TmfContext seekEvent(long position) { + + if (PrintDebug) { + System.out.println("seekEvent(position) position -> " + position); //$NON-NLS-1$ + } + + TmfTimestamp timestamp = null; + long index = position / getCacheSize(); + + // Get the timestamp of the closest check point to the given position + if (fCheckpoints.size() > 0) { + if (index >= fCheckpoints.size()) { + index = fCheckpoints.size() - 1; + } + timestamp = fCheckpoints.elementAt((int) index).getTimestamp(); + } + // If none, take the start time of the trace + else { + timestamp = getStartTime(); + } + + // Seek to the found time + TmfContext tmpContext = seekEvent(timestamp); + tmpContext.setRank((index + 1) * fIndexPageSize); + previousLocation = (LttngLocation) tmpContext.getLocation(); + + // Ajust the index of the event we found at this check point position + Long currentPosition = index * getCacheSize(); + + Long lastTimeValueRead = 0L; + + // Get the event at current position. This won't move to the next one + JniEvent tmpJniEvent = currentJniTrace.findNextEvent(); + // Now that we are positionned at the checkpoint, + // we need to "readNext" (Position - CheckpointPosition) times or until + // trace "run out" + while ((tmpJniEvent != null) && (currentPosition < position)) { + tmpJniEvent = currentJniTrace.readNextEvent(); + currentPosition++; + } + + // If we found our event, save its timestamp + if (tmpJniEvent != null) { + lastTimeValueRead = tmpJniEvent.getEventTime().getTime(); + } + + // Set the operation marker as seek, to be able to detect we did "seek" + // this event + previousLocation.setLastOperationSeek(); + // Save read event time + previousLocation.setOperationTime(lastTimeValueRead); + + // *** VERIFY *** + // Is that too paranoid? + // + // We don't trust what upper level could do with our internal location + // so we create a new one to return instead + LttngLocation curLocation = new LttngLocation(previousLocation); + + return new TmfContext(curLocation); + } + + @Override + public TmfContext seekLocation(double ratio) { + // TODO Auto-generated method stub + return null; + } + + @Override + public double getLocationRatio(ITmfLocation location) { + // TODO Auto-generated method stub + return 0; + } + + /** + * Return the event in the trace according to the given context. Read it if necessary. + *

    + * Similar (same?) as ParseEvent except that calling GetNext twice read the next one the second time. + * + * @param context + * Current TmfContext where to get the event + * + * @return The LttngEvent we read of null if no event are available + * + * @see org.eclipse.linuxtools.lttng.event.LttngLocation + * @see org.eclipse.linuxtools.tmf.trace.TmfContext + */ + + public int nbEventsRead = 0; + + @Override + public synchronized LttngEvent getNextEvent(TmfContext context) { + + if (PrintDebug) { + System.out.println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$ + + context.getLocation()); + } + + LttngEvent returnedEvent = null; + LttngLocation curLocation = null; + + curLocation = (LttngLocation) context.getLocation(); + // If the location in context is null, create a new one + if (curLocation == null) { + curLocation = getCurrentLocation(context); + } + + // // [lmcfrch] + // TmfContext savedContext = context.clone(); + // // [/lmcfrch] + + // *** HACK *** + // TMF assumes it is possible to read (GetNextEvent) to the next Event + // once ParseEvent() is called + // In LTTNG, there is not difference between "Parsing" and "Reading" an + // event. + // Since parsing/reading invalidate the previous event, + // we need to make sure the sequence ParseEvent() -> GetNextEvent() will + // not actually move to the next event. + // To do so, we avoid moving for call to "GetNextEvent()" that follow + // call to a call to "ParseEvent()". + // However, calling ParseEvent() -> GetNextEvent() -> GetNextEvent() + // will only move next by one. + + // *** Positioning trick : + // GetNextEvent only read the trace if : + // 1- The last operation was NOT a ParseEvent --> A read is required + // OR + // 2- The time of the previous location is different from the current + // one --> A seek + a read is required + if ((!(curLocation.isLastOperationParse())) + || (previousLocation.getOperationTimeValue() != curLocation.getOperationTimeValue())) { + if (previousLocation.getOperationTimeValue() != curLocation.getOperationTimeValue()) { + if (PrintDebug) { + System.out.println("\t\tSeeking in getNextEvent. [ LastTime : " //$NON-NLS-1$ + + previousLocation.getOperationTimeValue() + " CurrentTime" //$NON-NLS-1$ + + curLocation.getOperationTimeValue() + " ]"); //$NON-NLS-1$ + } + seekEvent(curLocation.getOperationTime()); + } + // Read the next event from the trace. The last one will NO LONGER + // BE VALID. + returnedEvent = readNextEvent(curLocation); + + } else { + // No event was read, just return the one currently loaded (the last + // one we read) + returnedEvent = currentLttngEvent; + + // *** IMPORTANT! + // Reset (erase) the operation marker to both location, to be able + // to detect we did NOT "read" this event + previousLocation.resetLocationState(); + curLocation.resetLocationState(); + } + + // If we read an event, set it's time to the locations (both previous + // and current) + if (returnedEvent != null) { + setPreviousAndCurrentTimes(context, returnedEvent, curLocation); + + // // [lmcfrch] + // LttngLocation prevLocation = (LttngLocation) + // savedContext.getLocation(); + // LttngLocation currLocation = (LttngLocation) + // context.getLocation(); + // if (prevLocation.equals(currLocation)) { + // System.out.println("Aie"); + // } + // Tracer.trace("Trc: " + context.getRank() + ": " + + // returnedEvent.getTimestamp().toString() + " (" + + // (prevLocation.isLastOperationParse() ? "T" : "F") + "," + + // (prevLocation.isLastOperationReadNext() ? "T" : "F") + "," + + // (prevLocation.isLastOperationSeek() ? "T" : "F") + "), (" + + // (currLocation.isLastOperationParse() ? "T" : "F") + "," + + // (currLocation.isLastOperationReadNext() ? "T" : "F") + "," + + // (currLocation.isLastOperationSeek() ? "T" : "F") + ")" + // ); + // // [/lmcfrch] + + } + + return returnedEvent; + } + + // this method was extracted for profiling purposes + private void setPreviousAndCurrentTimes(TmfContext context, LttngEvent returnedEvent, LttngLocation curLocation) { + + TmfTimestamp eventTimestamp = returnedEvent.getTimestamp(); + // long eventTime = eventTimestamp.getValue(); + previousLocation.setOperationTime(eventTimestamp.getValue()); + curLocation.setOperationTime(eventTimestamp.getValue()); + updateIndex(context, context.getRank(), eventTimestamp); + context.updateRank(1); + } + + protected void updateIndex(TmfContext context, long rank, TmfTimestamp timestamp) { + + if (getStartTime().compareTo(timestamp, false) > 0) + setStartTime(timestamp); + if (getEndTime().compareTo(timestamp, false) < 0) + setEndTime(timestamp); + if (rank != ITmfContext.UNKNOWN_RANK) { + if (fNbEvents <= rank) + fNbEvents = rank + 1; + // Build the index as we go along + if ((rank % fIndexPageSize) == 0) { + // Determine the table position + long position = rank / fIndexPageSize; + // Add new entry at proper location (if empty) + if (fCheckpoints.size() == position) { + addCheckPoint(context, timestamp); + } + } + } + } + + private void addCheckPoint(TmfContext context, TmfTimestamp timestamp) { + ITmfLocation location = context.getLocation().clone(); + fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location)); + } + + // this method was extracted for profiling purposes + private LttngEvent readNextEvent(LttngLocation curLocation) { + LttngEvent returnedEvent; + // Read the next event from the trace. The last one will NO LONGER BE + // VALID. + returnedEvent = readEvent(curLocation); + nbEventsRead++; + + // Set the operation marker as read to both location, to be able to + // detect we did "read" this event + previousLocation.setLastOperationReadNext(); + curLocation.setLastOperationReadNext(); + return returnedEvent; + } + + // this method was extracted for profiling purposes + private LttngLocation getCurrentLocation(TmfContext context) { + LttngLocation curLocation; + curLocation = new LttngLocation(); + context.setLocation(curLocation); + return curLocation; + } + + /** + * Return the event in the trace according to the given context. Read it if necessary. + *

    + * Similar (same?) as GetNextEvent except that calling ParseEvent twice will return the same event + * + * @param context + * Current TmfContext where to get the event + * + * @return The LttngEvent we read of null if no event are available + * + * @see org.eclipse.linuxtools.lttng.event.LttngLocation + * @see org.eclipse.linuxtools.tmf.trace.TmfContext + */ + @Override + public synchronized LttngEvent parseEvent(TmfContext context) { + + if (PrintDebug) { + System.out.println("parseEvent(context) context.getLocation() -> " //$NON-NLS-1$ + + context.getLocation()); + } + + LttngEvent returnedEvent = null; + LttngLocation curLocation = null; + + // If the location in context is null, create a new one + if (context.getLocation() == null) { + curLocation = new LttngLocation(); + context.setLocation(curLocation); + } + // Otherwise, we use the one in context; it should be a valid + // LttngLocation + else { + curLocation = (LttngLocation) context.getLocation(); + } + + // *** HACK *** + // TMF assumes it is possible to read (GetNextEvent) to the next Event + // once ParseEvent() is called + // In LTTNG, there is not difference between "Parsing" and "Reading" an + // event. + // So, before "Parsing" an event, we have to make sure we didn't "Read" + // it alreafy. + // Also, "Reading" invalidate the previous Event in LTTNG and seek back + // is very costly, + // so calling twice "Parse" will return the same event, giving a way to + // get the "Currently loaded" event + + // *** Positionning trick : + // ParseEvent only read the trace if : + // 1- The last operation was NOT a ParseEvent or a GetNextEvent --> A + // read is required + // OR + // 2- The time of the previous location is different from the current + // one --> A seek + a read is required + if (((!(curLocation.isLastOperationParse())) && ((!(curLocation.isLastOperationReadNext())))) + || (previousLocation.getOperationTimeValue() != curLocation.getOperationTimeValue())) { + // Previous time != Current time : We need to reposition to the + // current time + if (previousLocation.getOperationTimeValue() != curLocation.getOperationTimeValue()) { + if (PrintDebug) { + System.out.println("\t\tSeeking in getNextEvent. [ LastTime : " //$NON-NLS-1$ + + previousLocation.getOperationTimeValue() + " CurrentTime" //$NON-NLS-1$ + + curLocation.getOperationTimeValue() + " ]"); //$NON-NLS-1$ + } + seekEvent(curLocation.getOperationTime()); + } + + // Read the next event from the trace. The last one will NO LONGER + // BE VALID. + returnedEvent = readEvent(curLocation); + } else { + // No event was read, just return the one currently loaded (the last + // one we read) + returnedEvent = currentLttngEvent; + } + + // If we read an event, set it's time to the locations (both previous + // and current) + if (returnedEvent != null) { + previousLocation.setOperationTime((LttngTimestamp) returnedEvent.getTimestamp()); + curLocation.setOperationTime((LttngTimestamp) returnedEvent.getTimestamp()); + } + + // Set the operation marker as parse to both location, to be able to + // detect we already "read" this event + previousLocation.setLastOperationParse(); + curLocation.setLastOperationParse(); + + return returnedEvent; + } + + /* + * Read the next event from the JNI and convert it as Lttng Event

    + * + * @param location Current LttngLocation that to be updated with the event timestamp + * + * @return The LttngEvent we read of null if no event are available + * + * @see org.eclipse.linuxtools.lttng.event.LttngLocation + * + * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace + */ + private synchronized LttngEvent readEvent(LttngLocation location) { + LttngEvent returnedEvent = null; + JniEvent tmpEvent = null; + + // Read the next event from JNI. THIS WILL INVALIDATE THE CURRENT LTTNG + // EVENT. + tmpEvent = currentJniTrace.readNextEvent(); + + if (tmpEvent != null) { + // *** NOTE + // Convert will update the currentLttngEvent + returnedEvent = convertJniEventToTmf(tmpEvent); + + location.setOperationTime((LttngTimestamp) returnedEvent.getTimestamp()); + } + // *** NOTE + // If the read failed (likely the last event in the trace), set the + // LastReadTime to the JNI time + // That way, even if we try to read again, we will step over the bogus + // seek and read + else { + location.setOperationTime(getEndTime().getValue() + 1); + } + + return returnedEvent; + } + + /** + * Method to convert a JniEvent into a LttngEvent. + *

    + * + * Note : This method will call LttngEvent convertEventJniToTmf(JniEvent, boolean) with a default value for + * isParsingNeeded + * + * @param newEvent + * The JniEvent to convert into LttngEvent + * + * @return The converted LttngEvent + * + * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.event.LttngEvent + */ + public synchronized LttngEvent convertJniEventToTmf(JniEvent newEvent) { + currentLttngEvent = convertJniEventToTmf(newEvent, IS_PARSING_NEEDED_DEFAULT); + + return currentLttngEvent; + } + + /** + * Method to convert a JniEvent into a LttngEvent + * + * @param jniEvent + * The JniEvent to convert into LttngEvent + * @param isParsingNeeded + * A boolean value telling if the event should be parsed or not. + * + * @return The converted LttngEvent + * + * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.event.LttngEvent + */ + public synchronized LttngEvent convertJniEventToTmf(JniEvent jniEvent, boolean isParsingNeeded) { + + if (UniqueEvent) { + + // *** + // UNHACKED : We can no longer do that because TCF need to maintain + // several events at once. + // This is very slow to do so in LTTng, this has to be temporary. + // *** HACK *** + // To save time here, we only set value instead of allocating new + // object + // This give an HUGE performance improvement + // all allocation done in the LttngTrace constructor + // *** + eventTimestamp.setValue(jniEvent.getEventTime().getTime()); + eventSource.setSourceId(jniEvent.requestEventSource()); + + eventType = traceTypes.get(EventTypeKey.getEventTypeHash(jniEvent)); + + eventReference.setValue(jniEvent.getParentTracefile().getTracefilePath()); + eventReference.setTracepath(this.getName()); + + eventContent.emptyContent(); + + currentLttngEvent.setType(eventType); + // Save the jni reference + currentLttngEvent.updateJniEventReference(jniEvent); + + // Parse now if was asked + // Warning : THIS IS SLOW + if (isParsingNeeded) { + eventContent.getFields(); + } + + return currentLttngEvent; + } else { + return convertJniEventToTmfMultipleEventEvilFix(jniEvent, isParsingNeeded); + } + + } + + /** + * This method is a temporary fix to support multiple events at once in TMF This is expected to be slow and should + * be fixed in another way. See comment in convertJniEventToTmf(); + * + * @param jniEvent + * The current JNI Event + * @return Current Lttng Event fully parsed + */ + private synchronized LttngEvent convertJniEventToTmfMultipleEventEvilFix(JniEvent jniEvent, boolean isParsingNeeded) { + // *** HACK *** + // Below : the "fix" with all the new and the full-parse + // Allocating new memory is slow. + // Parsing every events is very slow. + eventTimestamp = new LttngTimestamp(jniEvent.getEventTime().getTime()); + eventSource = new LttngEventSource(jniEvent.requestEventSource()); + eventReference = new LttngEventReference(jniEvent.getParentTracefile().getTracefilePath(), this.getName()); + eventType = new LttngEventType(traceTypes.get(EventTypeKey.getEventTypeHash(jniEvent))); + eventContent = new LttngEventContent(currentLttngEvent); + currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, eventType, eventContent, eventReference, + null); + + // The jni reference is no longer reliable but we will keep it anyhow + currentLttngEvent.updateJniEventReference(jniEvent); + // Ensure that the content is correctly set + eventContent.setEvent(currentLttngEvent); + + // Parse the event if it was needed + // *** WARNING *** + // ONLY for testing, NOT parsing events with non-unique events WILL + // result in segfault in the JVM + if (isParsingNeeded) { + eventContent.getFields(); + } + + return currentLttngEvent; + } + + /** + * Reference to the current LttngTrace we are reading from. + *

    + * + * Note : This bypass the framework and should not be use, except for testing! + * + * @return Reference to the current LttngTrace + * + * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace + */ + public JniTrace getCurrentJniTrace() { + return currentJniTrace; + } + + /** + * Return a reference to the current LttngEvent we have in memory. + * + * @return The current (last read) LttngEvent + * + * @see org.eclipse.linuxtools.lttng.event.LttngEvent + */ + public synchronized LttngEvent getCurrentEvent() { + return currentLttngEvent; + } + + /** + * Get the major version number for the current trace + * + * @return Version major or -1 if unknown + * + * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace + * + */ + public short getVersionMajor() { + if (currentJniTrace != null) { + return currentJniTrace.getLttMajorVersion(); + } else { + return -1; + } + } + + /** + * Get the minor version number for the current trace + * + * @return Version minor or -1 if unknown + * + * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace + * + */ + public short getVersionMinor() { + if (currentJniTrace != null) { + return currentJniTrace.getLttMinorVersion(); + } else { + return -1; + } + } + + /** + * Get the number of CPU for this trace + * + * @return Number of CPU or -1 if unknown + * + * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace + * + */ + public int getCpuNumber() { + if (currentJniTrace != null) { + return currentJniTrace.getCpuNumber(); + } else { + return -1; + } + } + + /** + * Print the content of the checkpoint vector. + *

    + * + * This is intended for debug purpose only. + */ + public void printCheckpointsVector() { + System.out.println("StartTime : " //$NON-NLS-1$ + + getTimeRange().getStartTime().getValue()); + System.out.println("EndTime : " //$NON-NLS-1$ + + getTimeRange().getEndTime().getValue()); + + for (int pos = 0; pos < fCheckpoints.size(); pos++) { + System.out.print(pos + ": " + "\t"); //$NON-NLS-1$ //$NON-NLS-2$ + System.out.print(fCheckpoints.get(pos).getTimestamp() + "\t"); //$NON-NLS-1$ + System.out.println(fCheckpoints.get(pos).getLocation()); + } + } + + @Override + public synchronized void dispose() { + if (currentJniTrace != null) + currentJniTrace.closeTrace(); + super.dispose(); + } + + /** + * Return a String identifying this trace. + * + * @return String that identify this trace + */ + @Override @SuppressWarnings("nls") - public String toString() { - String returnedData = ""; + public String toString() { + String returnedData = ""; - returnedData += "Path :" + getPath() + " "; - returnedData += "Trace:" + currentJniTrace + " "; - returnedData += "Event:" + currentLttngEvent; + returnedData += "Path :" + getPath() + " "; + returnedData += "Trace:" + currentJniTrace + " "; + returnedData += "Event:" + currentLttngEvent; - return returnedData; - } + return returnedData; + } } /* * EventTypeKey inner class * - * This class is used to make the process of generating the HashMap key more - * transparent and so less error prone to use + * This class is used to make the process of generating the HashMap key more transparent and so less error prone to use */ final class EventTypeKey { - // *** WARNING *** - // These two getEventTypeKey() functions should ALWAYS construct the key the - // same ways! - // Otherwise, every type search will fail! - - // added final to encourage inlining. - - // generating a hash code by hand to avoid a string creation - final static public int getEventTypeHash( LttngEventType newEventType ) - { - return generateHash(newEventType.getTracefileName(), newEventType.getCpuId(), newEventType.getMarkerName() ); - } - - final private static int generateHash(String traceFileName, long cpuNumber , String markerName) { - // 0x1337 is a prime number. The number of CPUs is always under 8192 on the current kernel, so this will work with the current linux kernel. - int cpuHash = (int) (cpuNumber*(0x1337)); - return traceFileName.hashCode() ^(cpuHash) ^ markerName.hashCode(); - } - - // generating a hash code by hand to avoid a string creation - final static public int getEventTypeHash( JniEvent newEvent ) - { - return generateHash( newEvent.getParentTracefile().getTracefileName(), newEvent.getParentTracefile().getCpuNumber(),newEvent.requestEventMarker().getName() ); - } + // *** WARNING *** + // These two getEventTypeKey() functions should ALWAYS construct the key the + // same ways! + // Otherwise, every type search will fail! + // added final to encourage inlining. + + // generating a hash code by hand to avoid a string creation + final static public int getEventTypeHash(LttngEventType newEventType) { + return generateHash(newEventType.getTracefileName(), newEventType.getCpuId(), newEventType.getMarkerName()); + } + + final private static int generateHash(String traceFileName, long cpuNumber, String markerName) { + // 0x1337 is a prime number. The number of CPUs is always under 8192 on + // the current kernel, so this will work with the current linux kernel. + int cpuHash = (int) (cpuNumber * (0x1337)); + return traceFileName.hashCode() ^ (cpuHash) ^ markerName.hashCode(); + } + + // generating a hash code by hand to avoid a string creation + final static public int getEventTypeHash(JniEvent newEvent) { + return generateHash(newEvent.getParentTracefile().getTracefileName(), newEvent.getParentTracefile() + .getCpuNumber(), newEvent.requestEventMarker().getName()); + } } diff --git a/org.eclipse.linuxtools.tmf.tests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.tests/META-INF/MANIFEST.MF index bce4fd0a1b..21333c9c43 100644 --- a/org.eclipse.linuxtools.tmf.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.tests/META-INF/MANIFEST.MF @@ -1,13 +1,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name -Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core.tests +Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core.tests;singleton:=true Bundle-Version: 0.3.2.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.junit;bundle-version="3.8.2", org.eclipse.linuxtools.tmf.core;bundle-version="0.3.2", - org.eclipse.core.runtime;bundle-version="3.7.0" + org.eclipse.core.runtime;bundle-version="3.7.0", + org.eclipse.core.resources;bundle-version="3.7.100" Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.linuxtools.tmf.tests.TmfCoreTestPlugin diff --git a/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java b/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java index 16ef92042e..b3388ff8fe 100644 --- a/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java +++ b/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java @@ -115,7 +115,7 @@ public class TmfTraceStub extends TmfTrace { } @Override - public ITmfTrace createTraceCopy() { + public ITmfTrace copy() { ITmfTrace returnedValue = null; returnedValue = clone(); return returnedValue; @@ -135,7 +135,7 @@ public class TmfTraceStub extends TmfTrace { @Override @SuppressWarnings("unchecked") - public TmfContext seekLocation(ITmfLocation location) { + public TmfContext seekLocation(ITmfLocation location) { fLock.lock(); try { if (fTrace != null) { @@ -183,7 +183,8 @@ public class TmfTraceStub extends TmfTrace { } @Override - public double getLocationRatio(ITmfLocation location) { + @SuppressWarnings("rawtypes") + public double getLocationRatio(ITmfLocation location) { fLock.lock(); try { if (fTrace != null) { diff --git a/org.eclipse.linuxtools.tmf.ui.tests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.ui.tests/META-INF/MANIFEST.MF index 79f0e2f0b0..07b004d6cc 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.ui.tests/META-INF/MANIFEST.MF @@ -5,7 +5,7 @@ Bundle-SymbolicName: org.eclipse.linuxtools.tmf.ui.tests;singleton:=true Bundle-Version: 0.3.2.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.junit, +Require-Bundle: org.junit;bundle-version="3.8.2", org.eclipse.linuxtools.tmf.core;bundle-version="0.3.2", org.eclipse.linuxtools.tmf.ui;bundle-version="0.3.2", org.eclipse.core.runtime;bundle-version="3.7.0", @@ -14,4 +14,3 @@ Require-Bundle: org.junit, Bundle-Localization: plugin Bundle-Activator: org.eclipse.linuxtools.tmf.ui.tests.TmfUITestPlugin Bundle-ActivationPolicy: lazy - diff --git a/org.eclipse.linuxtools.tmf.ui.tests/plugin.properties b/org.eclipse.linuxtools.tmf.ui.tests/plugin.properties index f47b6bf68a..4333a8c656 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/plugin.properties +++ b/org.eclipse.linuxtools.tmf.ui.tests/plugin.properties @@ -1,3 +1,5 @@ #Properties file for org.eclipse.linuxtools.tmf.ui.tests Bundle-Vendor = Eclipse Linux Tools -Bundle-Name = TMF UI Unit Test Suite \ No newline at end of file +Bundle-Name = TMF UI Unit Test Suite +tmf.ui.stubs.category.name = TMF UI Stubs +tmf.analysis/view.name = TMF Time Analysis View diff --git a/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF index dff517021d..0acbe2ceed 100644 --- a/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF @@ -5,16 +5,21 @@ Bundle-SymbolicName: org.eclipse.linuxtools.tmf.ui;singleton:=true Bundle-Version: 0.3.2.qualifier Bundle-Activator: org.eclipse.linuxtools.tmf.ui.TmfUiPlugin Bundle-Vendor: %Bundle-Vendor -Require-Bundle: org.eclipse.ui, +Require-Bundle: org.eclipse.ui;bundle-version="3.7.0", + org.eclipse.ui.ide;bundle-version="3.7.0", + org.eclipse.core.resources;bundle-version="3.7.100", + org.eclipse.core.filesystem;bundle-version="1.3.100", org.eclipse.core.runtime;bundle-version="3.7.0", org.eclipse.linuxtools.tmf.core;bundle-version="0.3.2", - org.eclipse.core.resources;bundle-version="3.7.100", - org.eclipse.ui.ide;bundle-version="3.7.0" + org.eclipse.ui.navigator;bundle-version="3.5.100", + org.eclipse.ui.navigator.resources;bundle-version="3.4.300", + org.eclipse.core.expressions Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.linuxtools.tmf.ui, org.eclipse.linuxtools.tmf.ui.editors, org.eclipse.linuxtools.tmf.ui.parsers, + org.eclipse.linuxtools.tmf.ui.project.model, org.eclipse.linuxtools.tmf.ui.signal, org.eclipse.linuxtools.tmf.ui.viewers, org.eclipse.linuxtools.tmf.ui.viewers.events, @@ -24,8 +29,8 @@ Export-Package: org.eclipse.linuxtools.tmf.ui, org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets, org.eclipse.linuxtools.tmf.ui.views, org.eclipse.linuxtools.tmf.ui.views.colors, + org.eclipse.linuxtools.tmf.ui.views.events, org.eclipse.linuxtools.tmf.ui.views.filter, - org.eclipse.linuxtools.tmf.ui.views.project, org.eclipse.linuxtools.tmf.ui.views.statistics, org.eclipse.linuxtools.tmf.ui.views.statistics.model, org.eclipse.linuxtools.tmf.ui.views.timechart, diff --git a/org.eclipse.linuxtools.tmf.ui/icons/dlcl16/open.gif b/org.eclipse.linuxtools.tmf.ui/icons/dlcl16/open.gif new file mode 100644 index 0000000000000000000000000000000000000000..96d5334b7ebb947d35804c3a55d1b24381dda769 GIT binary patch literal 223 zcmZ?wbhEHb6krfwIKsg2`}dz;zkdJx`RnNMGpEj6`11Ap=P%zreg69K)0Z8)59~X5 z^yrB*-+%o4_Wj4#Z{NRs{dVTW{?o_z-Mn`G(z#=Y4j%mT=g>rx0hWdorQ5819!v6E1XWlLv_9II zW4JCN=c-etip+t7TQ)AW;d!XIeP}_?u5A1Hd|7N7r$l)(o#nIHf_eY!{FS~%*emX$G*(T!r9i(($2=OsGF>%n5m+csG*gnpOnJE!NI`5 z{{H^`{r&v>{Qv*|A^8LW0018VEC2ui01yBW000Ga;3tk`S!!sCnj*k?FdS*DR&|}A zQxHvRj7mk)84MF{Pd|fs7=8C?l#gfKDPvxZS>$O{b{a x;|yDHV82@}P7Mwg0|kbLXd4#}7z757kX0fZ83YHHmYW| zia%Kx85lGfbU-G7{KUYPcVJ3^hYpwji6xgRoGj;`6TTcN$)j~qv+F=tPWG`j|LrWlp_a;k~*@-fIsC@bgqa;fo%2s6s6PE$?t@)A-} gQBv@5b5>W9N?erdAym3(=JFM}@@qCMbY!pw020oQNdN!< literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/dtool16/import.gif b/org.eclipse.linuxtools.tmf.ui/icons/dtool16/import.gif new file mode 100644 index 0000000000000000000000000000000000000000..cd4474182f048ef617d0355fbee88208910cfc3c GIT binary patch literal 143 zcmZ?wbhEHb6krfw*v!Dt(lX`Nod?%$+&Odp%GRCx_Z&EO@ydCMz|Eio5(AmRz+zKy(sT9Ru*5ax-{d_?@2;40*>jbbz!WZrUFiX9 oUMvz>uQWy6^-&5#T2~iiH7Qp`TG0#`TE)3 z;^OA%&ehuE=IF=I)Wgit#m>|B`TFwo_44)h@bvZh`}_F%`u+a?{Qdp={QUa+`}z9% z{Qdm<{QLL!^Y-@g_4V=k`uF+y_W1bq_xJSs`}z9%`1$$w`1tnw`}*|r?(_2P^YZSn zte&i>o2aCh=HuDn-O}LP(c<3I=;hq#<=v#8lc=MYYmVO%hYP>9uNmZv5>e} zEEQ{&)Cmd$0wB;Zyk51Nl|rviEE}85HjnuIcp4}%Abk-DhzS}UCNUp#2nh(2iYX^E zBXb88n+FFPB_25^a~Y#MQrt+fkl+B~)1W=ez2vPP+;O;XF6q-Hl;&2F|{*k-Y?&2m|%`MNIo z)!k-=Q`WEVGg;qfx~bn}>qO)-~asg|JT3&zyJLoLV0FMhJw4NZvcbhPZmZlhI$4a1|R@Mlmq*ohWe)FmewX&BNuNu1_x(nS62@w zC)s*NMkYpP77lG0GcywtGnsl}BV$uJxqf|9Q{zoS(`U|P;o=q4QE^vkRy1Nbe8k#~ zPmj+_v0l>1y1RFZjg6J1rBpqS(T2PC?sB)a?Qd39RZ~^h(9|+iQg&BXZaQf6?Yq6G zsDYS>ZoPbpPN&%f_a#i8lNx?(c66JN;h@CE`Dn3wKX1Lki35xu1^HymQ(}KGH{RYp Wng5@J#e@Z^P0Tvcn^Gh>7_0%hy?-bG literal 607 zcmZ?wbh9u|6krfw_{PBS^ueRBrp+5qzu0^3p-b5+xAN6)6{|ff*Z9`1_pMnM*syWe znfn?^(+a1ozy9!L#^#5)TOZ|bdsMOONy~v}6OO&O@%sCfm!IGN`v2+o|Er(>Kl=9X z@wb1ke*S;=>;K2!{~v$<_vHJ(mp}i%{q_IZkAJU!{eSoS|NGznKmYmv```Z;KmUFD z^Z(o5|G)nI|M~C#&SS^_{e9n5?$}#v*HPurT;|wZ?)dl1`Mw&vj!K8WpU-cdsJwNO z@~-J>vzx7^*4s>Ju=(?R@w`g0WsOqHnxvLCNv-RWU*Bi4zRz@7r}@G*i-m2Lvzx7d z-)){*BD|^JWOcXMgG=lF|NqZ0n1JF>7Dfh!00te9qd;-Oz`my;psBf~wXNN{g@uK+ zhn<6qk=a_mvx%QyfL~BZSVYv)O5e(=sk@hros-+e)YQVl)Fr@Ia@%%ES!ZW^CrAG+ zl01ixC~7-+J81X@xE?xkSVmplM@Ppkz)w<(_prEx#ARJMIllmRNwvE?;&0W|lvGsQ z13V-ZUyDDHk`80(23rZBFVvE4FCk*=4t={ diff --git a/org.eclipse.linuxtools.tmf.ui/icons/elcl16/open.gif b/org.eclipse.linuxtools.tmf.ui/icons/elcl16/open.gif new file mode 100644 index 0000000000000000000000000000000000000000..7e4c5830d9951a0eeb57185daee0dea5c41a2acd GIT binary patch literal 359 zcmV-t0hs(xQU&?;OY71?fUKV z`|$Mph@HWRoxqW$$KUDs;OY3~?fUKV`tGP z?eqKe_xs=K_~q{T>G1jO^ZM-b`uF+!nwpT9n30~Gjh&l~ucv{gp@*WLi=my0o0*Tj zuXwqwd#|Q}rl5$&wQB87!LfC|uXwqvdbFv2tD}VA$dA;rXwaAFU<`N}FGV;Q5g!p4 zm&7cfOD6{#K%2oN3~Dn%v~0~BBfqZB7aEEK-Kza&K^#Kp!XOvyt* F06Qbsz2g7? literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/elcl16/refresh.gif b/org.eclipse.linuxtools.tmf.ui/icons/elcl16/refresh.gif new file mode 100644 index 0000000000000000000000000000000000000000..049cac696c3ff0955901aff15bffc9ed96f6e4eb GIT binary patch literal 368 zcmV-$0gwJiNk%w1VGsZi0M!5h{r&#U)8O>?{qptu_xb($`~CU){PFet-st$`?D_5T z`t|tz+~@b<>iFvL`SSMs`1<|k?)mWb`}6nw_4xbw`~CO%`}_R;{Qdp={QTM5*O-`* zo0^aQ{qLTfjr;Jl<>Jq#p@*WLi@mRSw5oltrh%)Zg~zpV#k6z6vURzvdi&mm`ORO- zw0hvkkJPeg)Us*Xy?nid7S*z8wtN(}eH5*75v_6(t#cBrauTL%5dZ)G0000000000 z00000A^8LW0027xEC2ui01yBW000J!z@2bNEEZ45B+@7Z0Sr(m?8KDGG8l_CHbWI< z9c$}Cp}1nN)R4ydxNEJ#U_KZTbFAELg{w&Z5-LSHIuJT75DJP4BttDb8UzF_1P+## zB|-xP O0UOTG&rH%nK>$0EIl$Eb literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/elcl16/rename.gif b/org.eclipse.linuxtools.tmf.ui/icons/elcl16/rename.gif new file mode 100644 index 0000000000000000000000000000000000000000..aeccbfd8c143b83c3ade695cb69fbf1cf969fc17 GIT binary patch literal 346 zcmZ?wbhEHb6krfwxXQrLF?HRyAAfphtlo9}{=3h=zyA2^owq2ZWoz%u)em3&c=+o3 zi}ybtzW(w43sCCMgV#TvzyJCE%dZEozrXwPd+FhaQ|B)I`t$F%pMO@Je7gD4tFJ%* z?7jWr_|xylpME?4_V?A#|K~5BH-FK*6)R_~STSScx`{hCcW(lcn|k(d>-hiwKLf=; z@h1x-1A``m4#*^spBUK64@@cW(Bb24KX@=9$7r^nhM=oy!1{=+S1t!7%w+q2IIB$$ zQt3IgAVKAx(8~V5rum%9~ij#r> literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/elcl16/set_trace_type.gif b/org.eclipse.linuxtools.tmf.ui/icons/elcl16/set_trace_type.gif new file mode 100644 index 0000000000000000000000000000000000000000..9da8bff09f7fe8933b70ff07d3be8fcc2cda9327 GIT binary patch literal 346 zcmZ?wbhEHb6krfwxXQqA`uxqBj`>>;-QIrqj&I&7pUim?W$RO$wx>01&*|A;(0`z0 z(xKWJ$C~DxxN`qv<@6&{SD!w1aq+#T00-g~>@=1k|qzYhIh!y(zJ0Q|82N*^_rX0;Gx6Cd}7HZi4B(X&oNwnX`vuEfLTt*(6G*z(^OJOm`TCN#K@?~%acJ#UtdpIUdGK?RZmJv ebFquMl%8VUsv>PEl~t~KY8$qhYh*bxSOWn2ADo2% literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/etool16/import.gif b/org.eclipse.linuxtools.tmf.ui/icons/etool16/import.gif new file mode 100644 index 0000000000000000000000000000000000000000..d38085ad9c273000d1c7ef3ea0144de87b776e46 GIT binary patch literal 327 zcmZ?wbhEHb6krfwxXQp_Z$IBYetux?yuh5fA^8gfa_0sYEDX$@8&R?(qGWMI>Eg)J z#W5Aj<7-wY)UHmhUz<|DHmzxW>%y~b3(wBod@a6qb$sorkr;FE?8n*u-Kt|Id9CY|Ns9p&;Tg@WMO1rP-f5pnGNz216#_0i3J`yQvJsm zgg7JQrk+bO_7dTAKGtDoB+_bkXzjJf5992w1-8iStkCP%_Lx#5y6_`@wFT09~= wevLfb(wrPzoISn09c+@45|YAGBqXFHg(kDGv$8VHpTB^88S}Cb7e@wb0E(nwr~m)} literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/etool16/new.gif b/org.eclipse.linuxtools.tmf.ui/icons/etool16/new.gif new file mode 100644 index 0000000000000000000000000000000000000000..7aea894d0b603a02aed2a7f706bcb3170988774d GIT binary patch literal 612 zcmZ{h>q}E%9Dt8G)5LOgQI2^@7e=H}5t7*jq~=si${U5|rU_+M-j`oOU#sb&i!)6! zQj1L2<%^C`(3Frs!zQH!M$LxHZR)0;HP3s_`~J#5py%WBe0&lT<%eQbQbx*H7)D;+ zC9mj8tL`~bsh6u?DXLzlp`Oc4!$r+QwcX=`U*-e?sC#^9(mL|ZR{74{H@%DrT- zV)#}6;rDanLRp{LGx3fOqC^RS3vNq|)X-(A$o!#sus3{C+!5o{Rj7~JHa zq?m$3AWMR=N;c$n#X>#8pgrH*sO=7AfY*vOt}fICx=Rq;>*}tJq5D zJOzs&S}52kF^hQm&roD!pv_wX{I_nC2C7b_o=HnlsqcF+ z>%ILpZc-}G=AK7a*@3|wd!lmkaw^a@Hhgq+cl5#IStlz|F}po7cvo=5fta}bq!M(A z4UvV+$@aw_y%1lD%Gl7ITxjV2!wCgP%26SkA9VL}>?w1J7eN*3kUXk(DEU6m(EdKjHN)jkv7c;{Jb4a3C!1>qfFng9R* literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/ovr16/link_ovr.gif b/org.eclipse.linuxtools.tmf.ui/icons/ovr16/link_ovr.gif new file mode 100644 index 0000000000000000000000000000000000000000..4f1440ebe0e494d674af9abd8de6f16dcc2482b2 GIT binary patch literal 169 zcmZ?wbhEHbWM|-DIKsfNdgm2!qgWl+yh%$APF`}bq;o|`ZhvrYpOSOBSxEVlH(wvW z`TFF|mnUz(zJCAd^@q=|KYaT9<-_OCK=kp~_jmt)zWx2}-G4A(zy=h5vM@3*NHFMt zBtdpEu&O;!?GsO$m$q~jrxWXjR0TmBPgW*Y{|5pctxXp>7z8?<6Bz_r7#OSp^$SR; literal 0 HcmV?d00001 diff --git a/org.eclipse.linuxtools.tmf.ui/icons/ovr16/trace_type_ovr.gif b/org.eclipse.linuxtools.tmf.ui/icons/ovr16/trace_type_ovr.gif new file mode 100644 index 0000000000000000000000000000000000000000..2f8ec19fb0be72b07f9f328701800c5990caddaa GIT binary patch literal 76 zcmZ?wbh9u|WM|-D_{6}Vku=S}ZsqDj*XQrL_#X)<{$ycfU|?s^VE_V002S=1^@s6A3-Z300009a7bBm000XU z000XU0RWnu7ytkYO=&|zP*7-ZbZ>KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{zu>7~aD})?0RX_umCct+(lZpemCzb@^6=o|A>zVpu|i=NDG+7} zl4`aK{0#b-!z=TL9Wt0BGO&T{GJWpjryhdijfaIQ&2!o}p04JRKYg3k&Tf zVxhe-O!X z{f;To;xw^bEES6JSc$k$B2CA6xl)ltA<32E66t?3@gJ7`36pmX0IY^jz)rRYwaaY4 ze(nJRiw;=Qb^t(r^DT@T3y}a2XEZW-_W%Hszxj_qD**t_m!#tW0KDiJT&R>6OvVTR z07RgHDzHHZ48atvzz&?j9lXF70$~P3Knx_nJP<+#`N z#-MZ2bTkiLfR>_b(HgWKJ%F~Nr_oF3b#wrIijHG|(J>BYjM-sajE6;FiC7vY#};Gd zST$CUHDeuEH+B^pz@B062qXfFfD`NpUW5?BY=V%GM_5c)L#QR}BeW8_2v-S%gfYS= zB9o|3v?Y2H`NVi)In3rTB8+ej^> zQ=~r95NVuDChL%G$=>7$vVg20myx%S50Foi`^m%Pw-h?Xh~i8Mq9jtJloCocWk2Nv zrJpiFnV_ms&8eQ$2&#xWpIS+6pmtC%Q-`S&GF4Q#^mhymh7E(qNMa}%YZ-ePrx>>xFPTiH1=E+A$W$=bG8>s^ zm=Bn5Rah$aDtr}@$`X}2l~$F0mFKEdRdZE8)p@E5RI61Ft6o-prbbn>P~)iy)E2AN zsU20jsWz_8Qg>31P|s0cqrPALg8E|(vWA65poU1JRAaZs8I2(p#xiB`SVGovRs-uS zYnV-9TeA7=Om+qP8+I>yOjAR1s%ETak!GFdam@h^# z)@rS0t$wXH+Irf)+G6c;?H29p+V6F6oj{!|o%K3xI`?%6x;DB|x`n#ibhIR?(H}Q3Gzd138Ei2)WAMz7W9Vy`X}HnwgyEn!VS)>mv$8&{hQn>w4zwy3R}t;BYlZQm5)6pty=DfLrs+A-|>>;~;Q z_F?uV_HFjh9n2gO9o9Q^JA86v({H5aB!kjoO6 zc9$1ZZKsN-Zl8L~mE{`ly3)1N^`o1+o7}D0ZPeY&J;i;i`%NyJ8_8Y6J?}yE@b_5a zam?eLr<8@mESk|3$_SkmS{wQ>%qC18))9_|&j{ZT zes8AvOzF(F2#DZEY>2oYX&IRp`F#{ADl)1r>QS^)ba8a|EY_^#S^HO&t^Rgqwv=MZThqqEWH8 zxJo>d=ABlR_Bh=;eM9Tw|Ih34~oTE|= zX_mAr*D$vzw@+p(E0Yc6dFE}(8oqt`+R{gE3x4zjX+Sb3_cYE^= zgB=w+-tUy`ytONMS8KgRef4hA?t0j zufM;t32jm~jUGrkaOInTZ`zyfns>EuS}G30LFK_G-==(f<51|K&cocp&EJ`SxAh3? zNO>#LI=^+SEu(FqJ)ynt=!~PC9bO$rzPJB=?=j6w@a-(u02P7 zaQ)#(uUl{HW%tYNS3ItC^iAtK(eKlL`f9+{bJzISE?u8_z3;~C8@FyI-5j_jy7l;W z_U#vU3hqqYU3!mrul&B+{ptt$59)uk{;_4iZQ%G|z+lhASr6|H35TBkl>gI*;nGLU zN7W-nBaM%pA0HbH8olyl&XeJ%vZoWz%6?Y=dFykl=imL}`%BMQ{Mhgd`HRoLu6e2R za__6DuR6yg#~-}Tc|Gx_{H@O0eebyMy5GmWADJlpK>kqk(fVV@r_fLLKIeS?{4e)} z^ZO;zpECde00d`2O+f$vv5tKEQIh}w03c&XQcVB=dL;k=fP(-4`Tqa_faw4Lbua(` z>RI+y?e7jKeZ#YO-C4;M*9K~#9!>|1S&9o2b$-ZOLOe(dhu4`UXL0fR|HN@ckT z?GMtlB&sSEsX?Nx)JU|YQq@-dlcGrdl?bE$sFYTUP%5>eO+!;EQIVE_C@O`-BmrcI zV;h5wiNEizy02kRT(J?oL^QKF>EGL=0_1WVof zu?6d!&yAH;Q6U)+@Idx~EMDrFj}=(|^ujr#M3H142~PwdQ32TtKvsJGV*}QcFOK&q zSrNdH01`G;1qkFa+t~16ee0$1vJwfC05G9YnLwWa!YgQN!-DnH%jW|URgwi^0umCS z`XH#}Kl|8%_4F$jJSD3nN?l-x2nGNI$z(e30K|d8fSJD24 z0P8<@Uo50-3IL#sIld7LkyoZq8xpK%U%S|&M6W;$yHrR3UqpsTt{SM1G+6)r;|ZgR zL4v_jVl9d34Jjey+Wh8660GmNK2cJlU!)x~bt}0qf*~s8%6;Aj0_*uVCaVN`gj^B^ z0emrQqfsAOu>NPyq)}p!T;BBy;2R@Dx<(q+y_vOWB)0BhlE1rNK)v+VQ~{99f~Bhg zsYZF8Cqod(di7(~%xZ=4AJ&`kztvmuS(2k7^43~*@PFT)DiavEq(}?I6AY|}>8%

    t- z8F~OPITwE6{B&#j(D8GaoUQ-Llixe|1W9kT9eees(*po{Rvc|3Rk=pmd)1mHQgi_D z3%8XH`JVsa)V!^~b?`K(_Mu(>{N}%0ZM(bo&zSG;o4x^9Skhf;^NduCS^2&Xjlhdk z;?M2u-!srx`PG?*zO(Oe4a0-MBac1##<#Dut=A6B7yv^86jtoGLEstmtusDCqM*vM zDl2Q^4MqB*Fa6fdCrYK#{a>J}g5O9Doo9w2LfMULzyM|YE>yPej)B7)73m4On0 z=NTDTQ&8mm{}A8Nd1B>&=nA-WwiO0!n}+lz?jI-1lS?NnaIE63G!z zW!EwLo{PSB3UQ7F>sU}_!6|$tK`u(f^KsldDEU9vm5YsCRXMn0V@McvHyb!)W$&S~Hrf<^bQ z0G3$~upavSjx)dg*)3o6gYtp>?~h=3Ab8~2?@yit3OkdyvY75=03`rL?Ehd6wefHz zK`&mZppy`%C|S#X>o};&UUK>1cHJZRrM54AZpX;){Q8y${h)GS|NA4jIAsT(|Ix)1 zqzo`0fWiI`E}%9(huM&DPM7Ye!1F!nzuezn7|wJc4r7O6*gFCMIC17Q#wRBb`xQ(~*U@UW z(2DG0pgidnSw8S2;Kh!8vE?QuD&YFO*ODXkl_z#TA|l(IDvSWuDx%oJsY0D5N9`O{ z`P4Ii`}?Q5!h>yqcQP}(X6WG`|LYK@XQuJMuicK`o+{?*Eu5*1fC~@&%Lte-m&wO_om=vDWNgO6hy>h?h69A`>yRT-+s&1aZ;Cd0J?-j zSV7?ZWk%|chpHFvcWw)e0IG^=&nRl=1hex?W+1NtIMp={k0s6f017A<1N`OheFp#j z(t7}k=qs0SX2ydR!N^Drvvcz(7JP&`W{E(2PpSkkc7E#KiRrmNzg!kfOijIW`z>3? z*FBLYiGkiC9)93L9lxiU+fo07<;M=NMl2;RnlE`29&(;J3qsQUHAZ-kUJr zh%i3y5ELzDrxd48oq@9sRH7AH?ARXNbKqETDDb5hfR`WXXaD|>5_6C?yCCVgwThQt zKZ1KV`kp&#j8s$!5}xmSZLzkhsn-;UNFq=IoEe)# zvuUqwiN>iSwhn*?rw-OB>diXln}l@=BZ8T^W-_=WmM@K%_WqN@=Wu+qg>$VcLPi)l zc^n7c-j8N|9ye{h89_0CF$S&3qTu_#RPc4LD#Tj$T1C-_cp0JUjTp1@A&f|8H-ZZn z8(7aW&5~e+k;Qx?gfZtZGrtMV(4yc^!83$&{n?}dECufMG zr$%w&@Da>TO#)P?I*gne!SI%w;2RHNXkm=(a1MRev8?QJLS5$9-m`(e)?hhR_+Aao z@H1$|ie_k0Z}!8vNrbV5NtWugwQH%-j4i%e@Z+cVyf==cwK@Fs=tb<^cNi06XW;oh zjPXG#=n{{5=JW^(+wVXaSqRKFr>rdZ+F@kT3}g7lpj`6PffFc~4{Fy9EOm-A7lxoL zz}gm~*g-@vHCx2g+zh;w_L(#22J3@bqk8--esH{2d-LLSbl<`EYk2qFpP}Fs!#5^n zazfIuBVm_1MObg36pXdWCoyp zF2H-oF95bqe@uE_CQ}_X5|=_6Lceq`H*=0*{}b>uI!oPXPX5k^Lm%HDOpiPdwHVo zNzci1-a*v}O1{zk&JREMo8M8@?rJBLyQ8=v8D1}*R+U7+73B>{b3&6FHiY5Sc4ZZlMs5?e(}2?7$ftZCL`)67`4q8W-{fzTHV zKJMJQ2|GTyB{xc3Fw*T4$-QPS`E8rEbZ%wZW9HhBC7#KyiG0PAZBukkp{W@beGK`= z#S8k?K5q{!l@cq_iWT#OG$Uu~lg+~UxyWmDua{c}ENw4yY6AwKrxIX#wwX|$%%bqL zEX(#B9!VIJlujhgBTZ_`**Qd#=hCPBuB};CJKiwx zWzbJaL0QP~)OxK_S_JE=5=YKVPd5FL3ys3X*onLRN~sbA7XX%-W9Cu7g=W~%0JcL7 z@qDe?yiB{yy z*lg&JjMszF`Pej5M}K8yAX}b;tO@FBMf3Xz;s?VXOfb7qV^;K+d1Zf8dc6@ zv+yMgKo^)_3Y>GAhCM*RlT8M!W?csm6KE=BMk%wAGb8obJ3ZM7Y7-5AB399roR7bp zm&vs2?1ecrTOo{?1f;BEigdOoyG~w$$&3t)XVOxRf#;dTlstiF3`79uQbD#!wZPh> z%pzjondCmt2)x|2KoD7nR^-r%EyBnmjFamywhMw%&tT9bi@Gf#O(hzRW;|A@HLZ7I zCM=wqXawU8Yr@M-vo6W3mwtQ%jaJmj?vaaYT%v8+C}(=ZG}1RF**%j2WdM_&C&_xk z1nV+kPWW#m|4af_b|i_&I)rgDH5XZjDAx3tlzHmS)&fULNW)QTv6@qnGbiTa!tse# zFft$d4R?jf=pwN8zVS}+t55GOI3=EXelNPcd46)P`}1{PrFcb~5}~7vIhqrZddC{p zKRy)(CugFIb@wD{UNg9agjB25*@g?wwVXFP7YAo&qrz0=#Oe}# zTh)v-0L;{F3B;gwig#62mNhTRX&os`C$gDc=4N|I!uL$Yh*Xpcmn{X#ua(N4;iZ-l zC7FeG{nkoLj@Erfdahy9`c!)waR^tr$W;LGjg<96WTI=jFhm6XNdB|8DxlKUFXi=I z$bVhIs<&JZAf+@qSrt$Mi04Te8)RDmRx@-SfL?&BW>m&1*&wW1idh3l7GkU#sB{I) zhGEqLuv(ET11Kh@C#(L)!bW3N8>}c+Banf$VAMusRfk!EK?0i~Yx5r%-;<(XW3dVV zjCEQ9aPwLLm1g`EY{1O`xMMB + + + + - - @@ -104,111 +105,633 @@ + + + + + + + class="org.eclipse.linuxtools.tmf.TmfProjectNature"> - - + point="org.eclipse.ui.ide.projectNatureImages"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + description="%commands.trace_folder.category.description" + id="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category" + name="%commands.trace_folder.category.name"> - - - - - - - - + categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category" + description="%commands.trace_folder.import.description" + id="org.eclipse.linuxtools.tmf.ui.command.project.trace.import" + name="%commands.trace_folder.import"> + categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category" + description="%commands.trace_folder.refresh.description" + id="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh" + name="%commands.trace_folder.refresh"> - - + + + + + + + + + description="%commands.trace.select_trace_type.description" + id="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type" + name="%commands.trace.select_trace_type"> + + + + @@ -223,12 +746,6 @@ id="org.eclipse.linuxtools.tmf.ui.commands.experiment.category" name="%commands.experiment.category.name"> - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + class="org.eclipse.linuxtools.tmf.ui.project.handlers.ImportTraceHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.import"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.RefreshHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.OpenTraceHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.open"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.CopyTraceHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.copy"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.RenameTraceHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.rename"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.DeleteTraceHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.SelectTraceTypeHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.NewExperimentHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.new"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.RefreshHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.refresh"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.CopyExperimentHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.copy"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.RenameExperimentHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.rename"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.DeleteExperimentHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.delete"> + class="org.eclipse.linuxtools.tmf.ui.project.handlers.RefreshHandler" + commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.refresh"> + + + + diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java index ab502899a1..711b61e783 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/TmfUiPlugin.java @@ -14,9 +14,8 @@ package org.eclipse.linuxtools.tmf.ui; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.linuxtools.tmf.ui.TmfUiTracer; import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; -import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.LoadersManager; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -24,13 +23,13 @@ import org.osgi.framework.BundleContext; /** * TmfUiPlugin *

    - * The activator class controls the plug-in life cycle + * The activator class controls the plug-in life cycle. */ public class TmfUiPlugin extends AbstractUIPlugin { - // ======================================================================== + // ------------------------------------------------------------------------ // Attributes - // ======================================================================== + // ------------------------------------------------------------------------ // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.ui"; //$NON-NLS-1$ @@ -38,49 +37,34 @@ public class TmfUiPlugin extends AbstractUIPlugin { // The shared instance private static TmfUiPlugin plugin; - // ======================================================================== + // ------------------------------------------------------------------------ // Constructors - // ======================================================================== + // ------------------------------------------------------------------------ - /** - * The constructor - */ public TmfUiPlugin() { } - // ======================================================================== + // ------------------------------------------------------------------------ // Accessors - // ======================================================================== + // ------------------------------------------------------------------------ - /** - * Returns the shared instance - * - * @return the shared instance - */ public static TmfUiPlugin getDefault() { return plugin; } - // ======================================================================== - // Operators - // ======================================================================== + // ------------------------------------------------------------------------ + // AbstractUIPlugin + // ------------------------------------------------------------------------ - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; TmfUiTracer.init(); ParserProviderManager.init(); + TmfTraceElement.init(); } - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ @Override public void stop(BundleContext context) throws Exception { TmfUiTracer.stop(); @@ -88,6 +72,10 @@ public class TmfUiPlugin extends AbstractUIPlugin { super.stop(context); } + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + public Image getImageFromPath(String path){ return getImageDescripterFromPath(path).createImage(); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java index 1ed8ccfba7..59a5db5434 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java @@ -13,18 +13,27 @@ package org.eclipse.linuxtools.tmf.ui.dialogs; import java.io.File; +import java.net.URI; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.TmfUiPreferenceInitializer; import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor; import org.eclipse.linuxtools.tmf.ui.internal.Messages; import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; @@ -33,9 +42,9 @@ import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.wizards.CustomTxtParserWizard; -import org.eclipse.linuxtools.tmf.ui.wizards.CustomXmlParserWizard; +import org.eclipse.linuxtools.tmf.ui.parsers.wizards.CustomTxtParserWizard; +import org.eclipse.linuxtools.tmf.ui.parsers.wizards.CustomXmlParserWizard; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -299,7 +308,7 @@ public class ManageCustomParsersDialog extends Dialog { IPath location = Path.fromOSString(path); IFile file = workspace.getRoot().getFileForLocation(location); if (file == null) { - file = ProjectView.createLink(new File(location.toPortableString()).toURI()); + file = createLink(new File(location.toPortableString()).toURI()); } file.setPersistentProperty(ParserProviderManager.PARSER_PROPERTY, parser); IEditorInput editorInput = new FileEditorInput(file); @@ -327,6 +336,50 @@ public class ManageCustomParsersDialog extends Dialog { return composite; } + // ///////////////////////////////////////////////////////////////////////////// + // FIXME: Duplicated in TmfEventsEditor + // From the legacy ProjectView + // ///////////////////////////////////////////////////////////////////////////// + + // ------------------------------------------------------------------------ + // Static methods + // ------------------------------------------------------------------------ + + static public IFolder getActiveProjectTracesFolder() { + IEclipsePreferences node = new InstanceScope() + .getNode(TmfUiPlugin.PLUGIN_ID); + String activeProjectName = node.get( + TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, + TmfUiPreferenceInitializer.ACTIVE_PROJECT_DEFAULT); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject[] projects = root.getProjects(); + for (IProject project : projects) { + if (project.isAccessible() + && project.getName().equals(activeProjectName)) { + return project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); + } + } + return null; + } + + static public IFile createLink(URI uri) throws CoreException { + IFolder folder = getActiveProjectTracesFolder(); + if (folder == null || !folder.exists()) { + throw new CoreException(new Status(Status.ERROR, + TmfUiPlugin.PLUGIN_ID, "No active project set")); //$NON-NLS-1$ + } + String path = uri.getPath(); + // TODO: support duplicate file names + IFile file = folder.getFile(path.substring(path + .lastIndexOf(Path.SEPARATOR))); + if (!file.exists()) { + file.createLink(uri, IResource.NONE, null); + } + return file; + } + + // ///////////////////////////////////////////////////////////////////////////// + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/ITmfTraceEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/ITmfTraceEditor.java index d1a2911abb..a8d1824334 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/ITmfTraceEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/ITmfTraceEditor.java @@ -17,6 +17,6 @@ import org.eclipse.linuxtools.tmf.trace.ITmfTrace; public interface ITmfTraceEditor { - public ITmfTrace getTrace(); + public ITmfTrace getTrace(); public IResource getResource(); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java index 841170953e..f29ee3bad2 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java @@ -12,24 +12,43 @@ package org.eclipse.linuxtools.tmf.ui.editors; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarkerDelta; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.linuxtools.tmf.TmfCorePlugin; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.signal.TmfTraceSelectedSignal; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.TmfUiPreferenceInitializer; import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal; import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceOpenedSignal; import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceParserUpdatedSignal; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; @@ -41,6 +60,7 @@ import org.eclipse.ui.IReusableEditor; import org.eclipse.ui.PartInitException; import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.ide.IGotoMarker; +import org.osgi.framework.Bundle; /** * TmfEventsEditor @@ -51,7 +71,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus private TmfEventsTable fEventsTable; private IResource fResource; - private ITmfTrace fTrace; + private ITmfTrace fTrace; private Composite fParent; @Override @@ -74,7 +94,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus } else if (input instanceof FileStoreEditorInput) { try { FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) input; - fResource = ProjectView.createLink(fileStoreEditorInput.getURI()); + fResource = createLink(fileStoreEditorInput.getURI()); fTrace = ParserProviderManager.getTrace(fResource); input = new TmfEditorInput(fResource, fTrace); } catch (CoreException e) { @@ -90,6 +110,49 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus super.setInput(input); } + /////////////////////////////////////////////////////////////////////////////// + // FIXME: Duplicated in ManageCustomParsersDialog + // From the legacy ProjectView + /////////////////////////////////////////////////////////////////////////////// + + // ------------------------------------------------------------------------ + // Static methods + // ------------------------------------------------------------------------ + + static public IFolder getActiveProjectTracesFolder() { + @SuppressWarnings("deprecation") + IEclipsePreferences node = new InstanceScope() + .getNode(TmfUiPlugin.PLUGIN_ID); + String activeProjectName = node.get( + TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, + TmfUiPreferenceInitializer.ACTIVE_PROJECT_DEFAULT); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject[] projects = root.getProjects(); + for (IProject project : projects) { + if (project.isAccessible() + && project.getName().equals(activeProjectName)) { + return project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); + } + } + return null; + } + + static public IFile createLink(URI uri) throws CoreException { + IFolder folder = getActiveProjectTracesFolder(); + if (folder == null || !folder.exists()) { + throw new CoreException(new Status(Status.ERROR, TmfUiPlugin.PLUGIN_ID, "No active project set")); //$NON-NLS-1$ + } + String path = uri.getPath(); + // TODO: support duplicate file names + IFile file = folder.getFile(path.substring(path + .lastIndexOf(Path.SEPARATOR))); + if (!file.exists()) { + file.createLink(uri, IResource.NONE, null); + } + return file; + } + /////////////////////////////////////////////////////////////////////////////// + @Override public boolean isDirty() { return false; @@ -155,15 +218,61 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus } protected TmfEventsTable createEventsTable(Composite parent, int cacheSize) { - TmfEventsTable eventsTable = ParserProviderManager.getEventsTable(fTrace, parent, cacheSize); + TmfEventsTable eventsTable = getEventsTable(parent, cacheSize); if (eventsTable == null) { eventsTable = new TmfEventsTable(parent, cacheSize); } return eventsTable; } + private TmfEventsTable getEventsTable(Composite parent, int cacheSize) { + TmfEventsTable eventsTable = null; + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfCorePlugin.TMF_TRACE_TYPE_ID); + try { + String traceType = fResource.getPersistentProperty(TmfTraceElement.TRACETYPE); + for (IConfigurationElement ce : config) { + if (ce.getAttribute(TmfTraceElement.ID).equals(traceType)) { + IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceElement.EVENTS_TABLE_TYPE); + if (eventsTableTypeCE.length != 1) { + break; + } + String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceElement.CLASS); + if (eventsTableType == null || eventsTableType.length() == 0) { + break; + } + Bundle bundle = Platform.getBundle(ce.getContributor().getName()); + Class c = bundle.loadClass(eventsTableType); + Class[] constructorArgs = new Class[] { Composite.class, int.class }; + Constructor constructor = c.getConstructor(constructorArgs); + Object[] args = new Object[] { parent, cacheSize }; + eventsTable = (TmfEventsTable) constructor.newInstance(args); + break; + } + } + } catch (InvalidRegistryObjectException e) { + e.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + return eventsTable; + } + @Override - public ITmfTrace getTrace() { + public ITmfTrace getTrace() { return fTrace; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java index 3fe2d8f3a6..3561aaa111 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/Messages.java @@ -110,13 +110,6 @@ public class Messages extends NLS { public static String ColorsView_TickButtonText; public static String TickColorDialog_TickColorDialogTitle; - public static String AddTraceWizard_WindowTitle; - public static String AddTraceWizardPage_TraceColumnHeader; - public static String AddTraceWizardPage_WindowTitle; - public static String AddTraceWizardPage_Description; - public static String NewProjectWizard_DialogHeader; - public static String NewProjectWizard_DialogMessage; - public static String CustomTxtParserInputWizardPage_addChildLine; public static String CustomTxtParserInputWizardPage_addGroup; public static String CustomTxtParserInputWizardPage_addNextLine; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties index 5a37ed80b3..e6a6ddeb14 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/internal/messages.properties @@ -109,14 +109,6 @@ ColorsView_MoveUpActionToolTipText=Increase priority ColorsView_TickButtonText=Tick TickColorDialog_TickColorDialogTitle=Choose tick color -# org.eclipse.linuxtools.tmf.ui.views.project.dialogs -AddTraceWizard_WindowTitle=Add traces to experiment -AddTraceWizardPage_TraceColumnHeader=Trace -AddTraceWizardPage_WindowTitle=Select Traces -AddTraceWizardPage_Description=Select the traces to add to the experiment -NewProjectWizard_DialogHeader=TMF Project -NewProjectWizard_DialogMessage=Create a TMF Project - # org.eclipse.linuxtools.tmf.ui.wizards CustomTxtParserInputWizardPage_addChildLine=Add child line CustomTxtParserInputWizardPage_addGroup=Add group diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/IParserProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/IParserProvider.java index c47964c0bf..f8678e4133 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/IParserProvider.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/IParserProvider.java @@ -35,7 +35,7 @@ public interface IParserProvider { * @param resource the resource * @return a trace instance or null if the parser id is not handled by this parser provider */ - public ITmfTrace getTraceForParser(String parser, IResource resource); + public ITmfTrace getTraceForParser(String parser, IResource resource); /** * Return a trace instance for a resource given a content type id @@ -44,7 +44,7 @@ public interface IParserProvider { * @param resource the resource * @return a trace instance or null if the content type id is not handled by this parser provider */ - public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource); + public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource); /** * Return the parser map for this parser provider @@ -90,6 +90,6 @@ public interface IParserProvider { * @param cacheSize the desired cache size for the table * @return an events table instance or null if the trace is not handled by this parser provider */ - public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize); + public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomParserProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomParserProvider.java index 04761eef7d..e89912b6d3 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomParserProvider.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomParserProvider.java @@ -30,7 +30,7 @@ public class CustomParserProvider implements IParserProvider { } @Override - public ITmfTrace getTraceForParser(String parser, IResource resource) { + public ITmfTrace getTraceForParser(String parser, IResource resource) { try { String name = resource.getName(); String path = resource.getLocation().toOSString(); @@ -51,7 +51,7 @@ public class CustomParserProvider implements IParserProvider { } @Override - public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource) { + public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource) { return null; } @@ -115,7 +115,7 @@ public class CustomParserProvider implements IParserProvider { } @Override - public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize) { + public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize) { if (trace instanceof CustomTxtTrace) { return new CustomEventsTable(((CustomTxtTrace) trace).getDefinition(), parent, cacheSize); } else if (trace instanceof CustomXmlTrace) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java index dfddb9247b..110e359c3e 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -48,7 +48,8 @@ public class CustomTxtTrace extends TmfTrace { } @Override - public ITmfTrace createTraceCopy() { + @SuppressWarnings({ "unchecked", "rawtypes" }) + public ITmfTrace copy() { // TODO Auto-generated method stub return null; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java index 6c60dc4841..1ca18f01b1 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -136,7 +136,8 @@ public class CustomXmlTrace extends TmfTrace { } @Override - public ITmfTrace createTraceCopy() { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public ITmfTrace copy() { // TODO Auto-generated method stub return null; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java similarity index 97% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java index a62b4c9293..9b8941c693 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java @@ -1,4 +1,4 @@ -package org.eclipse.linuxtools.tmf.ui.wizards; +package org.eclipse.linuxtools.tmf.ui.parsers.wizards; import java.io.BufferedReader; import java.io.IOException; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java similarity index 96% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java index 828d21dccf..3b3de65148 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java @@ -1,4 +1,4 @@ -package org.eclipse.linuxtools.tmf.ui.wizards; +package org.eclipse.linuxtools.tmf.ui.parsers.wizards; import java.io.File; import java.io.FileNotFoundException; @@ -204,7 +204,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { writer.write(wizard.inputPage.getInputText()); writer.close(); - ITmfTrace trace = new CustomTxtTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); + ITmfTrace trace = new CustomTxtTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); previewTable.dispose(); previewTable = new CustomEventsTable(definition, tableContainer, MAX_NUM_ENTRIES); previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserWizard.java similarity index 93% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserWizard.java index bafd68fcbe..a7261b2049 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomTxtParserWizard.java @@ -1,4 +1,4 @@ -package org.eclipse.linuxtools.tmf.ui.wizards; +package org.eclipse.linuxtools.tmf.ui.parsers.wizards; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java similarity index 97% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java index f1c83af6e6..bbebbac256 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java @@ -1,4 +1,4 @@ -package org.eclipse.linuxtools.tmf.ui.wizards; +package org.eclipse.linuxtools.tmf.ui.parsers.wizards; import java.io.BufferedReader; import java.io.ByteArrayInputStream; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java similarity index 96% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java index 7ac6e789a1..f29b5f98d8 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java @@ -1,4 +1,4 @@ -package org.eclipse.linuxtools.tmf.ui.wizards; +package org.eclipse.linuxtools.tmf.ui.parsers.wizards; import java.io.File; import java.io.FileNotFoundException; @@ -205,7 +205,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { writer.write(wizard.inputPage.getInputText()); writer.close(); - ITmfTrace trace = new CustomXmlTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); + ITmfTrace trace = new CustomXmlTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); previewTable.dispose(); previewTable = new CustomEventsTable(definition, tableContainer, MAX_NUM_ENTRIES); previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserWizard.java similarity index 93% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserWizard.java index d2642d4331..000bf51cc7 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/wizards/CustomXmlParserWizard.java @@ -1,4 +1,4 @@ -package org.eclipse.linuxtools.tmf.ui.wizards; +package org.eclipse.linuxtools.tmf.ui.parsers.wizards; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyExperimentHandler.java new file mode 100644 index 0000000000..1cc0548bc6 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyExperimentHandler.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.wizards.CopyExperimentDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * CopyExperimentHandler + *

    + * TODO: Implement me. Please. + */ +public class CopyExperimentHandler extends AbstractHandler { + + private TmfExperimentElement fExperiment = null; + + // ------------------------------------------------------------------------ + // isEnabled + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure there is only selection and that it is an experiment + fExperiment = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + // There should be only one item selected as per the plugin.xml + Object element = sel.getFirstElement(); + if (element instanceof TmfExperimentElement) { + fExperiment = (TmfExperimentElement) element; + } + } + + return (fExperiment != null); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Fire the Copy Experiment dialog + Shell shell = window.getShell(); + CopyExperimentDialog dialog = new CopyExperimentDialog(shell, fExperiment); + dialog.open(); + + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyTraceHandler.java new file mode 100644 index 0000000000..850d64dd55 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/CopyTraceHandler.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.linuxtools.tmf.ui.project.wizards.CopyTraceDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * CopyTraceHandler + *

    + */ +public class CopyTraceHandler extends AbstractHandler { + + private TmfTraceElement fTrace = null; + + // ------------------------------------------------------------------------ + // Validation + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure a trace is selected + fTrace = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + // There should be only one item selected as per the plugin.xml + Object element = sel.getFirstElement(); + if (element instanceof TmfTraceElement) { + fTrace = (TmfTraceElement) element; + } + } + + // We only enable opening from the Traces folder for now + return (fTrace != null && fTrace.getParent() instanceof TmfTraceFolder); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Fire the Copy Experiment dialog + Shell shell = window.getShell(); + CopyTraceDialog dialog = new CopyTraceDialog(shell, fTrace); + dialog.open(); + + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteExperimentHandler.java new file mode 100644 index 0000000000..c7a9cbd566 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteExperimentHandler.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import java.util.Iterator; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * DeleteExperimentHandler + *

    + */ +public class DeleteExperimentHandler extends AbstractHandler { + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Confirm the operation + Shell shell = window.getShell(); + MessageBox confirmOperation = new MessageBox(shell, SWT.ICON_QUESTION | SWT.CANCEL | SWT.OK); + confirmOperation.setText(Messages.DeleteDialog_Title); + confirmOperation.setMessage(Messages.DeleteExperimentHandler_Message); + if (confirmOperation.open() != SWT.OK) + return null; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + @SuppressWarnings("unchecked") + Iterator iterator = sel.iterator(); + while (iterator.hasNext()) { + Object element = iterator.next(); + if (element instanceof TmfExperimentElement) { + TmfExperimentElement experiment = (TmfExperimentElement) element; + IResource resource = experiment.getResource(); + try { + resource.delete(true, null); + experiment.getProject().refresh(); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + } + + return null; + } +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteTraceHandler.java new file mode 100644 index 0000000000..b8886fbbd6 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/DeleteTraceHandler.java @@ -0,0 +1,146 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * DeleteTraceHandler + *

    + */ +public class DeleteTraceHandler extends AbstractHandler { + + private TreeSelection fSelection = null; + + // ------------------------------------------------------------------------ + // Validation + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure selection contains only traces + fSelection = null; + if (selection instanceof TreeSelection) { + fSelection = (TreeSelection) selection; + @SuppressWarnings("unchecked") + Iterator iterator = fSelection.iterator(); + while (iterator.hasNext()) { + Object element = iterator.next(); + if (!(element instanceof TmfTraceElement)) { + return false; + } + } + } + + // If we get here, either nothing is selected or everything is a trace + return !selection.isEmpty(); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Confirm the operation + Shell shell = window.getShell(); + MessageBox confirmOperation = new MessageBox(shell, SWT.ICON_QUESTION | SWT.CANCEL | SWT.OK); + confirmOperation.setText(Messages.DeleteDialog_Title); + confirmOperation.setMessage(Messages.DeleteTraceHandler_Message); + if (confirmOperation.open() != SWT.OK) + return null; + + @SuppressWarnings("unchecked") + Iterator iterator = fSelection.iterator(); + while (iterator.hasNext()) { + Object element = iterator.next(); + if (element instanceof TmfTraceElement) { + TmfTraceElement trace = (TmfTraceElement) element; + IResource resource = trace.getResource(); + try { + IPath path = resource.getLocation(); + if (path != null && (trace.getParent() instanceof TmfTraceFolder)) { + String location = path.toFile().getCanonicalPath(); + TmfExperimentFolder experimentFolder = trace.getProject().getExperimentsFolder(); + + // Propagate the removal to traces + for (ITmfProjectModelElement experiment : experimentFolder.getChildren()) { + List toRemove = new LinkedList(); + for (ITmfProjectModelElement child : experiment.getChildren()) { + if (child.getResource().getLocation().toString().equals(location)) { + toRemove.add(child); + } + } + for (ITmfProjectModelElement child : toRemove) { + experiment.removeChild(child); + child.getResource().delete(true, null); + } + } + } + + // Finally, delete the trace + resource.delete(true, new NullProgressMonitor()); + trace.getProject().refresh(); + + } catch (IOException e1) { + e1.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + + return null; + } +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/ImportTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/ImportTraceHandler.java new file mode 100644 index 0000000000..274785dc6b --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/ImportTraceHandler.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.linuxtools.tmf.ui.project.wizards.ImportTraceWizard; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * ImportTraceHandler + *

    + * Starts an ImportTraceWizard that will handle the lowly details. + */ +public class ImportTraceHandler extends AbstractHandler { + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + TmfTraceFolder traceFolder = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + // There should be only one item selected as per the plugin.xml + Object element = sel.getFirstElement(); + if (element instanceof TmfTraceFolder) { + traceFolder = (TmfTraceFolder) element; + } + } + if (traceFolder == null) + return null; + + // Fire the Import Trace Wizard + IWorkbench workbench = PlatformUI.getWorkbench(); + Shell shell = workbench.getActiveWorkbenchWindow().getShell(); + + ImportTraceWizard wizard = new ImportTraceWizard(); + wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(traceFolder)); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.open(); + + traceFolder.refresh(); + + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/Messages.java new file mode 100644 index 0000000000..401bc5528c --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/Messages.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.handlers; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.project.handlers.messages"; //$NON-NLS-1$ + + public static String OpenTraceHandler_Title; + public static String OpenTraceHandler_NoTraceType; + public static String OpenTraceHandler_NoTrace; + + public static String OpenExperimentHandler_Title; + + public static String DeleteDialog_Title; + public static String DeleteTraceHandler_Message; + public static String DeleteExperimentHandler_Message; + + public static String SelectTraceTypeHandler_Title; + public static String SelectTraceTypeHandler_InvalidTraceType; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/NewExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/NewExperimentHandler.java new file mode 100644 index 0000000000..df87fea367 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/NewExperimentHandler.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.wizards.NewExperimentDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * NewExperimentHandler + *

    + */ +public class NewExperimentHandler extends AbstractHandler { + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + TmfExperimentFolder experimentFolder = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + Object element = sel.getFirstElement(); + if (element instanceof TmfExperimentFolder) { + experimentFolder = (TmfExperimentFolder) element; + } + } + if (experimentFolder == null) { + return null; + } + + // Fire the New Experiment dialog + Shell shell = window.getShell(); + NewExperimentDialog dialog = new NewExperimentDialog(shell, experimentFolder); + dialog.open(); + + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenExperimentHandler.java new file mode 100644 index 0000000000..2f630a52d5 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenExperimentHandler.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import java.io.FileNotFoundException; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.event.TmfEvent; +import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; +import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; +import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * OpenExperimentHandler + *

    + * TODO: Implement me. Please. + */ +public class OpenExperimentHandler extends AbstractHandler { + + private TmfExperimentElement fExperiment = null; + + // ------------------------------------------------------------------------ + // Validation + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure there is only one selection and that it is an experiment + fExperiment = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + // There should be only one item selected as per the plugin.xml + Object element = sel.getFirstElement(); + if (element instanceof TmfExperimentElement) { + fExperiment = (TmfExperimentElement) element; + } + } + + // We only enable opening from the Traces folder for now + return (fExperiment != null); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Close the current experiment, if any + TmfExperiment currentExperiment = TmfExperiment.getCurrentExperiment(); + if (currentExperiment != null) { + currentExperiment.dispose(); + } + + // Instantiate the experiment's traces + List traceEntries = fExperiment.getTraces(); + int nbTraces = traceEntries.size(); + ITmfTrace[] traces = new ITmfTrace[nbTraces]; + for (int i = 0; i < nbTraces; i++) { + TmfTraceElement element = traceEntries.get(i); + ITmfTrace trace = element.instantiateTrace(); + TmfEvent traceEvent = element.instantiateEvent(); + try { + trace.initTrace(element.getLocation().getPath(), traceEvent.getClass()); + } catch (FileNotFoundException e) { + displayErrorMsg(""); //$NON-NLS-1$ + } + traces[i] = trace; + } + + // Create the experiment and signal + TmfExperiment experiment = new TmfExperiment(traces[0].getClass(), "Experiment", traces, //$NON-NLS-1$ + traces[0].getCacheSize()); + TmfExperiment.setCurrentExperiment(experiment); + TmfSignalManager.dispatchSignal(new TmfExperimentSelectedSignal(this, experiment)); + + return null; + } + + private void displayErrorMsg(String errorMsg) { + MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); + mb.setText(Messages.OpenTraceHandler_Title); + mb.setMessage(errorMsg); + mb.open(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenTraceHandler.java new file mode 100644 index 0000000000..f0922c963d --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/OpenTraceHandler.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import java.io.FileNotFoundException; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.event.TmfEvent; +import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; +import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; +import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.ui.editors.TmfEditorInput; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IReusableEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +/** + * OpenTraceHandler + *

    + * TODO: Add support for multiple trace selection + */ +public class OpenTraceHandler extends AbstractHandler { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private TmfTraceElement fTrace = null; + + // ------------------------------------------------------------------------ + // Validation + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure there is only one selection and that it is a trace + fTrace = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + // There should be only one item selected as per the plugin.xml + Object element = sel.getFirstElement(); + if (element instanceof TmfTraceElement) { + fTrace = (TmfTraceElement) element; + } + } + + // We only enable opening from the Traces folder for now + return (fTrace != null); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Check that the trace is valid + if (fTrace == null) { + return null; + } + + TmfEvent traceEvent = fTrace.instantiateEvent(); + ITmfTrace trace = fTrace.instantiateTrace(); + if (trace == null) { + displayErrorMsg(Messages.OpenTraceHandler_NoTraceType); + return null; + } + + // Get the editor_id from the extension point + String editorId = fTrace.getEditorId(); + boolean usesEditor = editorId != null && editorId.length() > 0; + + try { + trace.initTrace(fTrace.getLocation().getPath(), traceEvent.getClass(), usesEditor); + } catch (FileNotFoundException e) { + displayErrorMsg(Messages.OpenTraceHandler_NoTrace); + return null; + } + + if (usesEditor) { + try { + IResource resource = fTrace.getResource(); + IEditorInput editorInput = new TmfEditorInput(resource, trace); + IWorkbench wb = PlatformUI.getWorkbench(); + IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage(); + + IEditorPart editor = activePage.findEditor(editorInput); + if (editor != null && editor instanceof IReusableEditor) { + activePage.reuseEditor((IReusableEditor) editor, editorInput); + activePage.activate(editor); + } else { + editor = activePage.openEditor(editorInput, editorId); + } + } catch (PartInitException e) { + e.printStackTrace(); + } + + } else { + ITmfTrace[] traces = new ITmfTrace[] { trace }; + TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), fTrace.getName(), traces, + trace.getCacheSize()); + TmfExperiment.setCurrentExperiment(experiment); + TmfSignalManager.dispatchSignal(new TmfExperimentSelectedSignal(this, experiment)); + } + return null; + } + + private void displayErrorMsg(String errorMsg) { + MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); + mb.setText(Messages.OpenTraceHandler_Title); + mb.setMessage(errorMsg); + mb.open(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/PropertyTester.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/PropertyTester.java new file mode 100644 index 0000000000..db55ccbfbc --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/PropertyTester.java @@ -0,0 +1,36 @@ +package org.eclipse.linuxtools.tmf.ui.project.handlers; + +import java.util.Iterator; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; + +public class PropertyTester extends org.eclipse.core.expressions.PropertyTester { + + @Override + public boolean test(Object receiver, String property, Object[] args, + Object expectedValue) { + if (property.equals("isInTraceFolder")) { //$NON-NLS-1$ + boolean result = false; + if (receiver instanceof IStructuredSelection) { + Iterator iter = ((IStructuredSelection) receiver).iterator(); + while (iter.hasNext()) { + Object o = iter.next(); + if (o instanceof TmfTraceElement) { + if (((TmfTraceElement)o).getParent() instanceof TmfTraceFolder) { + result = true; + } else { + return false; + } + } else { + return false; + } + } + } + return result; + } + return false; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RefreshHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RefreshHandler.java new file mode 100644 index 0000000000..c6e35f823c --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RefreshHandler.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * RefreshHandler + *

    + * TODO: Handle multiple selections + */ +public class RefreshHandler extends AbstractHandler { + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + if (selection instanceof TreeSelection) { + TreeSelection treeSelection = (TreeSelection) selection; + Object element = treeSelection.getFirstElement(); + if (element instanceof TmfTraceFolder) { + TmfTraceFolder folder = (TmfTraceFolder) element; + TmfProjectElement project = (TmfProjectElement) folder.getProject(); + project.refresh(); + } + else if (element instanceof TmfExperimentFolder) { + TmfExperimentFolder folder = (TmfExperimentFolder) element; + TmfProjectElement project = (TmfProjectElement) folder.getProject(); + project.refresh(); + } + else if (element instanceof TmfExperimentElement) { + TmfExperimentElement folder = (TmfExperimentElement) element; + TmfProjectElement project = folder.getProject(); + project.refresh(); + } + } + + + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameExperimentHandler.java new file mode 100644 index 0000000000..27dabd81bf --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameExperimentHandler.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.wizards.RenameExperimentDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * RenameExperimentHandler + *

    + */ +public class RenameExperimentHandler extends AbstractHandler { + + private TmfExperimentElement fExperiment = null; + + // ------------------------------------------------------------------------ + // isEnabled + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure there is only selection and that it is an experiment + fExperiment = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + Object element = sel.getFirstElement(); + if (element instanceof TmfExperimentElement) { + fExperiment = (TmfExperimentElement) element; + } + } + + return (fExperiment != null); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Fire the Rename Experiment dialog + Shell shell = window.getShell(); + RenameExperimentDialog dialog = new RenameExperimentDialog(shell, fExperiment); + dialog.open(); + + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameTraceHandler.java new file mode 100644 index 0000000000..40ba686a53 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/RenameTraceHandler.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.linuxtools.tmf.ui.project.wizards.RenameTraceDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; + +/** + * RenameTraceHandler + *

    + * TODO: Implement me. Please. + */ +public class RenameTraceHandler extends AbstractHandler { + + private TmfTraceElement fTrace = null; + + // ------------------------------------------------------------------------ + // isEnabled + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure there is only selection and that it is an experiment + fTrace = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + // There should be only one item selected as per the plugin.xml + Object element = sel.getFirstElement(); + if (element instanceof TmfTraceElement) { + fTrace = (TmfTraceElement) element; + } + } + + // We only enable opening from the Traces folder for now + return (fTrace != null && fTrace.getParent() instanceof TmfTraceFolder); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Fire the Rename Trace dialog + Shell shell = window.getShell(); + TmfTraceFolder traceFolder = (TmfTraceFolder) fTrace.getParent(); + TmfTraceElement oldTrace = fTrace; + RenameTraceDialog dialog = new RenameTraceDialog(shell, fTrace); + if (dialog.open() != Window.OK) + return null; + + // Locate the new trace object + TmfTraceElement newTrace = null; + String newTraceName = dialog.getNewTraceName(); + for (ITmfProjectModelElement element : traceFolder.getChildren()) { + if (element instanceof TmfTraceElement) { + TmfTraceElement trace = (TmfTraceElement) element; + if (trace.getName().equals(newTraceName)) { + newTrace = trace; + break; + } + } + } + if (newTrace == null) + return null; + + List removeOps = new ArrayList(); + TmfExperimentFolder experimentFolder = newTrace.getProject().getExperimentsFolder(); + for (final ITmfProjectModelElement experiment : experimentFolder.getChildren()) { + for (final ITmfProjectModelElement trace : experiment.getChildren()) { + if (trace.equals(oldTrace)) { + // Create a link to the renamed trace + createTraceLink(newTrace, experiment); + + // Queue the removal of the old trace link + removeOps.add(new WorkspaceModifyOperation() { + @Override + protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { + experiment.removeChild(trace); + trace.getResource().delete(true, null); + experiment.refresh(); + } + }); + } + } + } + + for (WorkspaceModifyOperation operation : removeOps) { + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); + } catch (InterruptedException exception) { + } catch (InvocationTargetException exception) { + } catch (RuntimeException exception) { + } + } + + return null; + } + + private void createTraceLink(TmfTraceElement trace, final ITmfProjectModelElement experiment) { + try { + IResource resource = trace.getResource(); + IPath location = resource.getLocation(); + if (resource instanceof IFolder) { + IFolder folder = ((IFolder) experiment.getResource()).getFolder(trace.getName()); + if (ResourcesPlugin.getWorkspace().validateLinkLocation(folder, location).isOK()) { + folder.createLink(location, IResource.REPLACE, null); + } + else { + System.out.println("Invalid Trace Location"); //$NON-NLS-1$ + } + } + else { + IFile file = ((IFolder) experiment.getResource()).getFile(trace.getName()); + if (ResourcesPlugin.getWorkspace().validateLinkLocation(file, location).isOK()) { + file.createLink(location, IResource.REPLACE, null); + } + else { + System.out.println("Invalid Trace Location"); //$NON-NLS-1$ + } + } + experiment.refresh(); + } catch (CoreException e) { + e.printStackTrace(); + } + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java new file mode 100644 index 0000000000..bbc6f92d3e --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Patrick Tasse - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.handlers; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Map; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.linuxtools.tmf.TmfCorePlugin; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.CompoundContributionItem; +import org.eclipse.ui.menus.CommandContributionItem; +import org.eclipse.ui.menus.CommandContributionItemParameter; + +public class SelectTraceTypeContributionItem extends CompoundContributionItem { + + //private static final ImageDescriptor SELECTED_ICON = ImageDescriptor.createFromImage(TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/bullet.gif")); //$NON-NLS-1$ + private static final ImageDescriptor SELECTED_ICON = TmfUiPlugin.getDefault().getImageDescripterFromPath( + "icons/elcl16/bullet.gif"); //$NON-NLS-1$ + + @Override + protected IContributionItem[] getContributionItems() { + final String CATEGORY_ELEMENT = "category"; //$NON-NLS-1$ + final String TYPE_ELEMENT = "type"; //$NON-NLS-1$ + final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$ + final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ + final String BUNDLE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.bundle"; //$NON-NLS-1$ + final String TYPE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.type"; //$NON-NLS-1$ + final String ICON_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.icon"; //$NON-NLS-1$ + final String SELECT_TRACE_TYPE_COMMAND_ID = "org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type"; //$NON-NLS-1$ + + Map params; + LinkedList list = new LinkedList(); + + HashMap categoriesMap = new HashMap(); + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( + TmfCorePlugin.TMF_TRACE_TYPE_ID); + for (IConfigurationElement ce : config) { + if (ce.getName().equals(CATEGORY_ELEMENT)) { + MenuManager subMenu = new MenuManager(ce.getAttribute(NAME_ATTRIBUTE)); + categoriesMap.put(ce.getAttribute(ID_ATTRIBUTE), subMenu); + list.add(subMenu); + } + } + + HashSet selectedTraceTypes = new HashSet(); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchPage page = window.getActivePage(); + ISelection selection = page.getSelection(); + if (selection instanceof StructuredSelection) { + for (Object element : ((StructuredSelection) selection).toList()) { + if (element instanceof TmfTraceElement) { + TmfTraceElement trace = (TmfTraceElement) element; + selectedTraceTypes.add(trace.getTraceType()); + } + } + } + + for (IConfigurationElement ce : config) { + if (ce.getName().equals(TYPE_ELEMENT)) { + String traceBundle = ce.getContributor().getName(); + String traceType = ce.getAttribute(ID_ATTRIBUTE); + String traceIcon = ce.getAttribute(TmfTraceElement.ICON); + params = new HashMap(); + params.put(BUNDLE_PARAMETER, traceBundle); + params.put(TYPE_PARAMETER, traceType); + params.put(ICON_PARAMETER, traceIcon); + + String label = ce.getAttribute(NAME_ATTRIBUTE).replaceAll("&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$ + ImageDescriptor icon = null; + if (selectedTraceTypes.contains(traceType)) { + icon = SELECTED_ICON; + } + + CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(), "my.parameterid", // id //$NON-NLS-1$ + SELECT_TRACE_TYPE_COMMAND_ID, // commandId + params, // parameters + icon, // icon + icon, // disabled icon + icon, // hover icon + label, // label + null, // mnemonic + null, // tooltip + CommandContributionItem.STYLE_PUSH, // style + null, // help context id + true // visibleEnable + ); + + MenuManager subMenu = categoriesMap.get(ce.getAttribute(TmfTraceElement.CATEGORY)); + if (subMenu != null) { + subMenu.add(new CommandContributionItem(param)); + } else { + list.add(new CommandContributionItem(param)); + } + } + } + + return list.toArray(new IContributionItem[list.size()]); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeHandler.java new file mode 100644 index 0000000000..ea4e36a7b6 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTraceTypeHandler.java @@ -0,0 +1,185 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.handlers; + +import java.util.Iterator; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * SetTraceTypeHandler + *

    + */ +public class SelectTraceTypeHandler extends AbstractHandler { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + private final String BUNDLE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.bundle"; //$NON-NLS-1$ + private final String TYPE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.type"; //$NON-NLS-1$ + private final String ICON_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.icon"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private TreeSelection fSelection = null; + + // ------------------------------------------------------------------------ + // Validation + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure selection contains only traces + fSelection = null; + if (selection instanceof TreeSelection) { + fSelection = (TreeSelection) selection; + @SuppressWarnings("unchecked") + Iterator iterator = fSelection.iterator(); + while (iterator.hasNext()) { + Object element = iterator.next(); + if (!(element instanceof TmfTraceElement)) { + return false; + } + } + } + + // If we get here, either nothing is selected or everything is a trace + return !selection.isEmpty(); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + boolean ok = true; + for (Object element : fSelection.toList()) { + TmfTraceElement trace = (TmfTraceElement) element; + IResource resource = trace.getResource(); + if (resource != null) { + try { + // Set the properties for this resource + String bundleName = event.getParameter(BUNDLE_PARAMETER); + String traceType = event.getParameter(TYPE_PARAMETER); + String iconUrl = event.getParameter(ICON_PARAMETER); + ok &= propagateProperties(trace, bundleName, traceType, iconUrl); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + ((ITmfProjectModelElement) fSelection.getFirstElement()).getProject().refresh(); + + if (!ok) { + MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_ERROR); + mb.setText(Messages.SelectTraceTypeHandler_Title); + mb.setMessage(Messages.SelectTraceTypeHandler_InvalidTraceType); + mb.open(); + } + + return null; + } + + private boolean propagateProperties(TmfTraceElement trace, String bundleName, String traceType, String iconUrl) throws CoreException { + + IResource svResource = trace.getResource(); + String svBundleName = svResource.getPersistentProperty(TmfTraceElement.TRACEBUNDLE); + String svTraceType = svResource.getPersistentProperty(TmfTraceElement.TRACETYPE); + String svIconUrl = svResource.getPersistentProperty(TmfTraceElement.TRACEICON); + + setProperties(trace.getResource(), bundleName, traceType, iconUrl); + trace.refreshTraceType(); + if (!validateTraceType(trace)) { + setProperties(trace.getResource(), svBundleName, svTraceType, svIconUrl); + trace.refreshTraceType(); + return false; + } + + trace.refreshTraceType(); + + if (trace.getParent() instanceof TmfTraceFolder) { + TmfExperimentFolder experimentFolder = trace.getProject().getExperimentsFolder(); + for (final ITmfProjectModelElement experiment : experimentFolder.getChildren()) { + for (final ITmfProjectModelElement child : experiment.getChildren()) { + if (child instanceof TmfTraceElement) { + TmfTraceElement linkedTrace = (TmfTraceElement) child; + if (linkedTrace.equals(trace)) { + IResource resource = linkedTrace.getResource(); + setProperties(resource, bundleName, traceType, iconUrl); + linkedTrace.refreshTraceType(); + } + } + } + } + } + return true; + } + + private void setProperties(IResource resource, String bundleName, String traceType, String iconUrl) throws CoreException { + resource.setPersistentProperty(TmfTraceElement.TRACEBUNDLE, bundleName); + resource.setPersistentProperty(TmfTraceElement.TRACETYPE, traceType); + resource.setPersistentProperty(TmfTraceElement.TRACEICON, iconUrl); + } + + private boolean validateTraceType(TmfTraceElement trace) { + IProject project = trace.getProject().getResource(); + ITmfTrace tmfTrace = null; + try { + tmfTrace = trace.instantiateTrace(); + return (tmfTrace != null && tmfTrace.validate(project, trace.getLocation().getPath())); + } finally { + if (tmfTrace != null) + tmfTrace.dispose(); + } + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTracesHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTracesHandler.java new file mode 100644 index 0000000000..9a6493939a --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/SelectTracesHandler.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.linuxtools.tmf.ui.project.wizards.SelectTracesWizard; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * SelectTracesHandler + *

    + */ +public class SelectTracesHandler extends AbstractHandler { + + private TmfExperimentElement fExperiment = null; + + // ------------------------------------------------------------------------ + // Validation + // ------------------------------------------------------------------------ + + @Override + public boolean isEnabled() { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Get the selection + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part = page.getActivePart(); + ISelection selection = part.getSite().getSelectionProvider().getSelection(); + + // Make sure there is only one selection and that it is an experiment + fExperiment = null; + if (selection instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) selection; + // There should be only one item selected as per the plugin.xml + Object element = sel.getFirstElement(); + if (element instanceof TmfExperimentElement) { + fExperiment = (TmfExperimentElement) element; + } + } + + return (fExperiment != null); + } + + // ------------------------------------------------------------------------ + // Execution + // ------------------------------------------------------------------------ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return null; + + // Fire the Select Traces Wizard + IWorkbench workbench = PlatformUI.getWorkbench(); + Shell shell = workbench.getActiveWorkbenchWindow().getShell(); + + TmfExperimentFolder experiments = (TmfExperimentFolder) fExperiment.getParent(); + TmfProjectElement project = (TmfProjectElement) experiments.getParent(); + SelectTracesWizard wizard = new SelectTracesWizard(project, fExperiment); + wizard.init(PlatformUI.getWorkbench(), null); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.open(); + + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/messages.properties new file mode 100644 index 0000000000..eeede92e16 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/handlers/messages.properties @@ -0,0 +1,16 @@ +# Open trace error messages +OpenTraceHandler_Title = Open Trace +OpenTraceHandler_NoTraceType = No trace type associated to that trace\nPlease select a valid type +OpenTraceHandler_NoTrace = Trace not found. Moved or deleted? + +# Open experiment error messages +OpenExperimentHandler_Title = Open Experiment + +# Delete message +DeleteDialog_Title = Confirm Delete +DeleteTraceHandler_Message = Are you sure you want to delete this trace? +DeleteExperimentHandler_Message = Are you sure you want to delete this experiment? + +# Set Trace Type +SelectTraceTypeHandler_Title = Validation Error +SelectTraceTypeHandler_InvalidTraceType = Type could not be set for one or more traces diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfProjectModelElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfProjectModelElement.java new file mode 100644 index 0000000000..957f49089c --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfProjectModelElement.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 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.tmf.ui.project.model; + +import java.net.URI; +import java.util.List; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; + +/** + * ITmfProjectModelElement + *

    + * TODO: Make ITmfProjectModelElement extend IAdaptable + */ +public interface ITmfProjectModelElement { + + public String getName(); + + public IResource getResource(); + + public IPath getPath(); + + public URI getLocation(); + + public TmfProjectElement getProject(); + + public ITmfProjectModelElement getParent(); + + public boolean hasChildren(); + + public List getChildren(); + + public void addChild(ITmfProjectModelElement child); + + public void removeChild(ITmfProjectModelElement child); + + public void refresh(); +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java new file mode 100644 index 0000000000..69fce64238 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 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.tmf.ui.project.model; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.IPropertySource2; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +/** + * TmfExperimentElement + *

    + */ +public class TmfExperimentElement extends TmfProjectModelElement implements IPropertySource2 { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + // Property View stuff + private static final String sfInfoCategory = "Info"; //$NON-NLS-1$ + private static final String sfName = "name"; //$NON-NLS-1$ + private static final String sfPath = "path"; //$NON-NLS-1$ + private static final String sfLocation = "location"; //$NON-NLS-1$ + + private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); + private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); + private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, + sfLocation); + + private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, + sfLocationDescriptor }; + + static { + sfNameDescriptor.setCategory(sfInfoCategory); + sfPathDescriptor.setCategory(sfInfoCategory); + sfLocationDescriptor.setCategory(sfInfoCategory); + } + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + public TmfExperimentElement(String name, IFolder folder, TmfExperimentFolder parent) { + super(name, folder, parent); + parent.addChild(this); + } + + // ------------------------------------------------------------------------ + // TmfProjectModelElement + // ------------------------------------------------------------------------ + + @Override + public IFolder getResource() { + return (IFolder) fResource; + } + + @Override + public TmfProjectElement getProject() { + return (TmfProjectElement) getParent().getParent(); + } + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + + public List getTraces() { + List children = getChildren(); + List traces = new ArrayList(); + for (ITmfProjectModelElement child : children) { + if (child instanceof TmfTraceElement) { + traces.add((TmfTraceElement) child); + } + } + return traces; + } + + // ------------------------------------------------------------------------ + // IPropertySource2 + // ------------------------------------------------------------------------ + + @Override + public Object getEditableValue() { + return null; + } + + @Override + public IPropertyDescriptor[] getPropertyDescriptors() { + return sfDescriptors; + } + + @Override + public Object getPropertyValue(Object id) { + + if (sfName.equals(id)) + return getName(); + + if (sfPath.equals(id)) + return getPath().toString(); + + if (sfLocation.equals(id)) + return getLocation().toString(); + + return null; + } + + @Override + public void resetPropertyValue(Object id) { + } + + @Override + public void setPropertyValue(Object id, Object value) { + } + + @Override + public boolean isPropertyResettable(Object id) { + return false; + } + + @Override + public boolean isPropertySet(Object id) { + return false; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentFolder.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentFolder.java new file mode 100644 index 0000000000..82fd2cf751 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentFolder.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 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.tmf.ui.project.model; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.IPropertySource2; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +/** + * TmfExperimentFolder + *

    + */ +public class TmfExperimentFolder extends TmfProjectModelElement implements IPropertySource2 { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + public static final String EXPER_FOLDER_NAME = "Experiments"; //$NON-NLS-1$ + + // Property View stuff + private static final String sfInfoCategory = "Info"; //$NON-NLS-1$ + private static final String sfName = "name"; //$NON-NLS-1$ + private static final String sfPath = "path"; //$NON-NLS-1$ + private static final String sfLocation = "location"; //$NON-NLS-1$ + + private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); + private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); + private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, sfLocation); + + private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor }; + + static { + sfNameDescriptor.setCategory(sfInfoCategory); + sfPathDescriptor.setCategory(sfInfoCategory); + sfLocationDescriptor.setCategory(sfInfoCategory); + } + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + public TmfExperimentFolder(String name, IFolder folder, TmfProjectElement parent) { + super(name, folder, parent); + parent.addChild(this); + } + + // ------------------------------------------------------------------------ + // TmfProjectModelElement + // ------------------------------------------------------------------------ + + @Override + public IFolder getResource() { + return (IFolder) fResource; + } + + @Override + public TmfProjectElement getProject() { + return (TmfProjectElement) getParent(); + } + + @Override + public void refresh() { + TmfProjectElement project = (TmfProjectElement) getParent(); + project.refresh(); + } + + // ------------------------------------------------------------------------} + // IPropertySource2 // ------------------------------------------------------------------------ @Override public Object getEditableValue() { return null; } @Override public IPropertyDescriptor[] getPropertyDescriptors() { return sfDescriptors; } @Override public Object getPropertyValue(Object id) { if (sfName.equals(id)) return getName(); if (sfPath.equals(id)) return getPath().toString(); if (sfLocation.equals(id)) return getLocation().toString(); return null; } @Override public void resetPropertyValue(Object id) { } @Override public void setPropertyValue(Object id, Object value) { } @Override public boolean isPropertyResettable(Object id) { return false; } @Override public boolean isPropertySet(Object id) { return false; } + +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java new file mode 100644 index 0000000000..d2a9e294b8 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorContentProvider.java @@ -0,0 +1,367 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 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.tmf.ui.project.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.navigator.ICommonContentExtensionSite; +import org.eclipse.ui.navigator.ICommonContentProvider; +import org.eclipse.ui.navigator.IPipelinedTreeContentProvider; +import org.eclipse.ui.navigator.PipelinedShapeModification; +import org.eclipse.ui.navigator.PipelinedViewerUpdate; + +/** + * TmfNavigatorContentProvider + *

    + */ +public class TmfNavigatorContentProvider implements ICommonContentProvider, IPipelinedTreeContentProvider { + + // ------------------------------------------------------------------------ + // ICommonContentProvider + // ------------------------------------------------------------------------ + + @Override + public Object[] getElements(Object inputElement) { + return null; + } + + @Override + public Object getParent(Object element) { + return null; + } + + @Override + public boolean hasChildren(Object element) { + if (element instanceof IProject) { + IProject project = (IProject) element; + return project.isAccessible(); + } + if (element instanceof TmfTraceFolder) { + TmfTraceFolder folder = (TmfTraceFolder) element; + return folder.hasChildren(); + } + if (element instanceof TmfExperimentFolder) { + TmfExperimentFolder folder = (TmfExperimentFolder) element; + return folder.hasChildren(); + } + if (element instanceof TmfExperimentElement) { + TmfExperimentElement folder = (TmfExperimentElement) element; + return folder.hasChildren(); + } + return false; + } + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + @Override + public void restoreState(IMemento aMemento) { + } + + @Override + public void saveState(IMemento aMemento) { + } + + @Override + public void init(ICommonContentExtensionSite aConfig) { + } + + // ------------------------------------------------------------------------ + // ICommonContentProvider - getChildren() + // ------------------------------------------------------------------------ + + @Override + public synchronized Object[] getChildren(Object parentElement) { + + // Tracing project level + if (parentElement instanceof IProject) { + return getProjectChildren((IProject) parentElement); + } + + // Traces "folder" level + if (parentElement instanceof TmfTraceFolder) { + return getTraceFolderChildren((TmfTraceFolder) parentElement); + } + + // Experiments "folder" level + if (parentElement instanceof TmfExperimentFolder) { + return getExperimentFolderChildren((TmfExperimentFolder) parentElement); + } + + // Experiment + if (parentElement instanceof TmfExperimentElement) { + return getExperimentChildren((TmfExperimentElement) parentElement); + } + + return new Object[0]; + } + + private Object[] getProjectChildren(IProject project) { + // The children structure + List children = new ArrayList(); + + // Get the children from the model + Map childrenMap = new HashMap(); + TmfProjectElement tmfProject = TmfProjectRegistry.getProject(project); + for (ITmfProjectModelElement element : tmfProject.getChildren()) { + if (element instanceof TmfTraceFolder) { + TmfTraceFolder child = (TmfTraceFolder) element; + childrenMap.put(child.getResource().getName(), child); + } + if (element instanceof TmfExperimentFolder) { + TmfExperimentFolder child = (TmfExperimentFolder) element; + childrenMap.put(child.getResource().getName(), child); + } + } + + // Add the model folder if the corresponding resource exists and is not + // accounted for + IFolder folder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); + if (folder != null) { + String name = folder.getName(); + ITmfProjectModelElement element = childrenMap.get(name); + if (element == null) { + element = new TmfTraceFolder(TmfTraceFolder.TRACE_FOLDER_NAME, folder, tmfProject); + } + children.add(element); + childrenMap.remove(name); + getTraceFolderChildren((TmfTraceFolder) element); + } + + // Add the model folder if the corresponding resource exists and is not + // accounted for + folder = project.getFolder(TmfExperimentFolder.EXPER_FOLDER_NAME); + if (folder != null) { + String name = folder.getName(); + ITmfProjectModelElement element = childrenMap.get(name); + if (element == null) { + element = new TmfExperimentFolder(TmfExperimentFolder.EXPER_FOLDER_NAME, folder, tmfProject); + } + children.add(element); + childrenMap.remove(name); + getExperimentFolderChildren((TmfExperimentFolder) element); + } + + // Remove the leftovers (what was in the model but removed from the + // project) + cleanupModel(tmfProject, childrenMap); + + return children.toArray(); + } + + private Object[] getTraceFolderChildren(TmfTraceFolder tmfTraceFolder) { + // The children structure + List children = new ArrayList(); + + // Get the children from the model + Map childrenMap = new HashMap(); + for (ITmfProjectModelElement element : tmfTraceFolder.getChildren()) { + if (element instanceof TmfTraceElement) { + String name = element.getResource().getName(); + childrenMap.put(name, element); + } + } + + IFolder folder = tmfTraceFolder.getResource(); + try { + IResource[] members = folder.members(); + for (IResource resource : members) { + String name = resource.getName(); + ITmfProjectModelElement trace = childrenMap.get(name); + if (trace == null) { + trace = new TmfTraceElement(name, resource, tmfTraceFolder); + } + children.add(trace); + childrenMap.remove(name); + } + } catch (CoreException e) { + } + + // Remove the leftovers (what was in the model but removed from the + // project) + cleanupModel(tmfTraceFolder, childrenMap); + + return children.toArray(); + } + + private Object[] getExperimentFolderChildren(TmfExperimentFolder tmfExperimentFolder) { + // The children structure + List children = new ArrayList(); + + // Get the children from the model + Map childrenMap = new HashMap(); + for (ITmfProjectModelElement element : tmfExperimentFolder.getChildren()) { + if (element instanceof TmfExperimentElement) { + String name = element.getResource().getName(); + childrenMap.put(name, element); + } + } + + IFolder folder = tmfExperimentFolder.getResource(); + try { + IResource[] members = folder.members(); + for (IResource resource : members) { + if (resource instanceof IFolder) { + IFolder expFolder = (IFolder) resource; + String name = resource.getName(); + ITmfProjectModelElement experiment = childrenMap.get(name); + if (experiment == null) { + experiment = new TmfExperimentElement(name, expFolder, tmfExperimentFolder); + } + children.add(experiment); + childrenMap.remove(name); + getExperimentChildren((TmfExperimentElement) experiment); + } + } + } catch (CoreException e) { + } + + // Remove the leftovers (what was in the model but removed from the + // project) + cleanupModel(tmfExperimentFolder, childrenMap); + + return children.toArray(); + } + + private Object[] getExperimentChildren(TmfExperimentElement tmfExperiment) { + // The children structure + List children = new ArrayList(); + + // Get the children from the model + Map childrenMap = new HashMap(); + for (ITmfProjectModelElement element : tmfExperiment.getChildren()) { + if (element instanceof TmfTraceElement) { + String name = element.getResource().getName(); + childrenMap.put(name, element); + } + } + + IFolder folder = tmfExperiment.getResource(); + try { + IResource[] members = folder.members(); + for (IResource resource : members) { + String name = resource.getName(); + ITmfProjectModelElement trace = childrenMap.get(name); + if (trace == null) { + trace = new TmfTraceElement(name, resource, tmfExperiment); + } + children.add(trace); + childrenMap.remove(name); + } + } catch (CoreException e) { + } + + // Remove the leftovers (what was in the model but removed from the + // project) + cleanupModel(tmfExperiment, childrenMap); + + return children.toArray(); + } + + private void cleanupModel(ITmfProjectModelElement parent, Map danglingChildren) { + if (parent != null) { + for (ITmfProjectModelElement child : danglingChildren.values()) { + Map grandChildren = new HashMap(); + for (ITmfProjectModelElement element : child.getChildren()) { + String name = element.getResource().getName(); + grandChildren.put(name, element); + } + cleanupModel(child, grandChildren); + parent.removeChild(child); + } + } + } + + // ------------------------------------------------------------------------ + // IPipelinedTreeContentProvider + // ------------------------------------------------------------------------ + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void getPipelinedChildren(Object parent, Set currentChildren) { + customizeTmfElements(getChildren(parent), currentChildren); + } + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void getPipelinedElements(Object input, Set currentElements) { + customizeTmfElements(getElements(input), currentElements); + } + + /** + * Add/replace the ITmfProjectElement to the list of children + * + * @param elements + * the list returned by getChildren() + * @param children + * the current children + */ + private void customizeTmfElements(Object[] elements, Set children) { + if (elements != null && children != null) { + for (Object element : elements) { + if (element instanceof ITmfProjectModelElement) { + ITmfProjectModelElement tmfElement = (ITmfProjectModelElement) element; + IResource resource = tmfElement.getResource(); + if (resource != null) { + children.remove(resource); + } + children.add(element); + } + else if (element != null) { + children.add(element); + } + } + } + } + + @Override + public Object getPipelinedParent(Object anObject, Object aSuggestedParent) { + return null; + } + + @Override + public PipelinedShapeModification interceptAdd(PipelinedShapeModification anAddModification) { + return null; + } + + @Override + public PipelinedShapeModification interceptRemove(PipelinedShapeModification aRemoveModification) { + return null; + } + + @Override + public boolean interceptRefresh(PipelinedViewerUpdate aRefreshSynchronization) { + return false; + } + + @Override + public boolean interceptUpdate(PipelinedViewerUpdate anUpdateSynchronization) { + return false; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java new file mode 100644 index 0000000000..0d10025692 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java @@ -0,0 +1,167 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.model; + +import java.net.URL; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.navigator.ICommonContentExtensionSite; +import org.eclipse.ui.navigator.ICommonLabelProvider; +import org.osgi.framework.Bundle; + +/** + * TmfNavigatorLabelProvider + *

    + */ +public class TmfNavigatorLabelProvider implements ICommonLabelProvider { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + private final Image fFolderIcon = PlatformUI.getWorkbench().getSharedImages() + .getImage(ISharedImages.IMG_OBJ_FOLDER); + private final String fTraceIconFile = "icons/elcl16/trace.gif"; //$NON-NLS-1$ + private final String fExperimentIconFile = "icons/elcl16/experiment.gif"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private final Image fTraceFolderIcon = fFolderIcon; + private final Image fExperimentFolderIcon = fFolderIcon; + + private final Image fDefaultTraceIcon; + private final Image fExperimentIcon; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + public TmfNavigatorLabelProvider() { + Bundle bundle = TmfUiPlugin.getDefault().getBundle(); + fDefaultTraceIcon = loadIcon(bundle, fTraceIconFile); + fExperimentIcon = loadIcon(bundle, fExperimentIconFile); + } + + private Image loadIcon(Bundle bundle, String url) { + TmfUiPlugin plugin = TmfUiPlugin.getDefault(); + String key = bundle.getSymbolicName() + "/" + url; //$NON-NLS-1$ + Image icon = plugin.getImageRegistry().get(key); + if (icon == null) { + URL imageURL = bundle.getResource(url); + ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL); + icon = descriptor.createImage(); + plugin.getImageRegistry().put(key, icon); + } + return icon; + } + + // ------------------------------------------------------------------------ + // ICommonLabelProvider + // ------------------------------------------------------------------------ + + @Override + public Image getImage(Object element) { + + if (element instanceof TmfTraceElement) { + TmfTraceElement trace = (TmfTraceElement) element; + String icon = null; + try { + String name = trace.getResource().getPersistentProperty(TmfTraceElement.TRACEBUNDLE); + icon = trace.getResource().getPersistentProperty(TmfTraceElement.TRACEICON); + if (name != null && icon != null) { + Bundle bundle = Platform.getBundle(name); + return loadIcon(bundle, icon); + } + } catch (CoreException e) { + } + return fDefaultTraceIcon; + } + + if (element instanceof TmfExperimentElement) + return fExperimentIcon; + + if (element instanceof TmfExperimentFolder) + return fExperimentFolderIcon; + + if (element instanceof TmfTraceFolder) + return fTraceFolderIcon; + + return null; + } + + @Override + public String getText(Object element) { + + if (element instanceof TmfTraceFolder) { + TmfTraceFolder folder = (TmfTraceFolder) element; + return folder.getName() + " [" + folder.getTraces().size() + "]"; //$NON-NLS-1$//$NON-NLS-2$ + } + + if (element instanceof TmfExperimentElement) { + TmfExperimentElement folder = (TmfExperimentElement) element; + return folder.getName() + " [" + folder.getTraces().size() + "]"; //$NON-NLS-1$//$NON-NLS-2$ + } + + // Catch all + if (element instanceof ITmfProjectModelElement) { + return ((ITmfProjectModelElement) element).getName(); + } + + return null; + } + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } + + @Override + public void restoreState(IMemento aMemento) { + } + + @Override + public void saveState(IMemento aMemento) { + } + + @Override + public String getDescription(Object anElement) { + return getText(anElement); + } + + @Override + public void init(ICommonContentExtensionSite aConfig) { + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectElement.java new file mode 100644 index 0000000000..532b950506 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectElement.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.model; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.actions.WorkspaceModifyOperation; + +/** + * TmfProjectElement + *

    + */ +public class TmfProjectElement extends TmfProjectModelElement { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + TmfTraceFolder fTraceFolder = null; + TmfExperimentFolder fExperimentFolder = null; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public TmfProjectElement(String name, IProject project, ITmfProjectModelElement parent) { + super(name, project, parent); + } + + // ------------------------------------------------------------------------ + // TmfProjectModelElement + // ------------------------------------------------------------------------ + + @Override + public IProject getResource() { + return (IProject) fResource; + } + + @Override + public void addChild(ITmfProjectModelElement child) { + super.addChild(child); + if (child instanceof TmfTraceFolder) { + fTraceFolder = (TmfTraceFolder) child; + return; + } + if (child instanceof TmfExperimentFolder) { + fExperimentFolder = (TmfExperimentFolder) child; + return; + } + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + + public TmfTraceFolder getTracesFolder() { + return fTraceFolder; + } + + public TmfExperimentFolder getExperimentsFolder() { + return fExperimentFolder; + } + + // ------------------------------------------------------------------------ + // TmfProjectElement + // ------------------------------------------------------------------------ + + @Override + public void refresh() { + try { + new WorkspaceModifyOperation() { + @Override + protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { + IProject project = getResource(); + project.touch(null); + } + }.run(null); + } catch (InvocationTargetException e) { + } catch (InterruptedException e) { + } catch (RuntimeException e) { + } + } + + @Override + public void resourceChanged(IResourceChangeEvent event) { + if (event.getType() == IResourceChangeEvent.POST_CHANGE) { + refresh(); + } + } + + @Override + public TmfProjectElement getProject() { + return this; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectModelElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectModelElement.java new file mode 100644 index 0000000000..402be10df3 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectModelElement.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 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.tmf.ui.project.model; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; + +/** + * TmfProjectModelElement + *

    + */ +public abstract class TmfProjectModelElement implements ITmfProjectModelElement, IResourceChangeListener { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private final String fName; + protected final IResource fResource; + protected final URI fLocation; + protected final IPath fPath; + private final ITmfProjectModelElement fParent; + protected final List fChildren; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + protected TmfProjectModelElement(String name, IResource resource, ITmfProjectModelElement parent) { + fName = name; + fResource = resource; + fPath = resource.getFullPath(); + fLocation = resource.getLocationURI(); + fParent = parent; + fChildren = new ArrayList(); + ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + } + + // ------------------------------------------------------------------------ + // ITmfProjectModelElement + // ------------------------------------------------------------------------ + + @Override + public String getName() { + return fName; + } + + @Override + public IResource getResource() { + return fResource; + } + + @Override + public IPath getPath() { + return fPath; + } + + @Override + public URI getLocation() { + return fLocation; + } + + @Override + public ITmfProjectModelElement getParent() { + return fParent; + } + + @Override + public boolean hasChildren() { + return fChildren.size() > 0; + } + + @Override + public List getChildren() { + return fChildren; + } + + @Override + public void addChild(ITmfProjectModelElement child) { + fChildren.add(child); + } + + @Override + public void removeChild(ITmfProjectModelElement child) { + fChildren.remove(child); + refresh(); + } + + @Override + public void refresh() { + // Do nothing by default: sub-classes override this on an "as-needed" + // basis. + } + + // ------------------------------------------------------------------------ + // IResourceChangeListener + // ------------------------------------------------------------------------ + + @Override + public void resourceChanged(IResourceChangeEvent event) { + // Do nothing by default: sub-classes override this on an "as-needed" + // basis. + } + + // ------------------------------------------------------------------------ + // Object + // ------------------------------------------------------------------------ + + @Override + public boolean equals(Object other) { + if (this == other) + return true; + if (!(other instanceof TmfProjectModelElement)) + return false; + TmfProjectModelElement o = (TmfProjectModelElement) other; + return o.fName.equals(fName) && o.fLocation.equals(fLocation); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java new file mode 100644 index 0000000000..6d4fe12da0 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.model; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.resources.IProject; + +/** + * TmfProjectRegistry + *

    + */ +public class TmfProjectRegistry { + + private static Map registry = new HashMap(); + + public static synchronized TmfProjectElement getProject(IProject project) { + TmfProjectElement element = registry.get(project); + if (element == null) { + registry.put(project, new TmfProjectElement(project.getName(), project, null)); + element = registry.get(project); + } + return element; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java new file mode 100644 index 0000000000..8f41f29a09 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java @@ -0,0 +1,290 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 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.tmf.ui.project.model; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.linuxtools.tmf.TmfCorePlugin; +import org.eclipse.linuxtools.tmf.event.TmfEvent; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.ui.IActionFilter; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.IPropertySource2; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +/** + * TmfTraceElement + *

    + */ +public class TmfTraceElement extends TmfProjectModelElement implements IActionFilter, IPropertySource2 { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + // Property keys + public static final QualifiedName TRACEBUNDLE = new QualifiedName("org.eclipse.linuxtools.tmf", "tracetype.bundle"); //$NON-NLS-1$//$NON-NLS-2$ + public static final QualifiedName TRACETYPE = new QualifiedName("org.eclipse.linuxtools.tmf", "tracetype.id"); //$NON-NLS-1$//$NON-NLS-2$ + public static final QualifiedName TRACEICON = new QualifiedName("org.eclipse.linuxtools.tmf", "tracetype.icon"); //$NON-NLS-1$//$NON-NLS-2$ + + // Extension point fields + public static final String TYPE = "type"; //$NON-NLS-1$ + public static final String ID = "id"; //$NON-NLS-1$ + public static final String CATEGORY = "category"; //$NON-NLS-1$ + public static final String NAME = "name"; //$NON-NLS-1$ + public static final String TRACE_TYPE = "trace_type"; //$NON-NLS-1$ + public static final String EVENT_TYPE = "event_type"; //$NON-NLS-1$ + public static final String ICON = "icon"; //$NON-NLS-1$ + + public static final String DEFAULT_EDITOR = "defaultEditor"; //$NON-NLS-1$ + public static final String EVENTS_TABLE_TYPE = "eventsTableType"; //$NON-NLS-1$ + public static final String CLASS = "class"; //$NON-NLS-1$ + + // Other attributes + public static final String BUNDLE = "bundle"; //$NON-NLS-1$ + public static final String IS_LINKED = "isLinked"; //$NON-NLS-1$ + + // Property View stuff + private static final String sfInfoCategory = "Info"; //$NON-NLS-1$ + private static final String sfName = "name"; //$NON-NLS-1$ + private static final String sfPath = "path"; //$NON-NLS-1$ + private static final String sfLocation = "location"; //$NON-NLS-1$ + private static final String sfEventType = "type"; //$NON-NLS-1$ + private static final String sfIsLinked = "linked"; //$NON-NLS-1$ + + private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); + private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); + private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, sfLocation); + private static final TextPropertyDescriptor sfTypeDescriptor = new TextPropertyDescriptor(sfEventType, sfEventType); + private static final TextPropertyDescriptor sfIsLinkedDescriptor = new TextPropertyDescriptor(sfIsLinked, sfIsLinked); + + private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor, + sfTypeDescriptor, sfIsLinkedDescriptor }; + + static { + sfNameDescriptor.setCategory(sfInfoCategory); + sfPathDescriptor.setCategory(sfInfoCategory); + sfLocationDescriptor.setCategory(sfInfoCategory); + sfTypeDescriptor.setCategory(sfInfoCategory); + sfIsLinkedDescriptor.setCategory(sfInfoCategory); + } + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + // This trace type ID as defined in plugin.xml + private String fTraceTypeId = null; + + // ------------------------------------------------------------------------ + // Static initialization + // ------------------------------------------------------------------------ + + // The mapping of available trace type IDs to their corresponding configuration element + private static final Map sfTraceTypeAttributes = new HashMap(); + private static final Map sfTraceCategories = new HashMap(); + + // Initialize statically at startup + public static void init() { + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfCorePlugin.TMF_TRACE_TYPE_ID); + for (IConfigurationElement ce : config) { + String attribute = ce.getName(); + if (attribute.equals(TYPE)) { + String traceTypeId = ce.getAttribute(ID); + sfTraceTypeAttributes.put(traceTypeId, ce); + } else if (attribute.equals(CATEGORY)) { + String categoryId = ce.getAttribute(ID); + sfTraceCategories.put(categoryId, ce); + } + } + } + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + public TmfTraceElement(String name, IResource trace, TmfTraceFolder parent) { + this(name, trace, (TmfProjectModelElement) parent); + } + + public TmfTraceElement(String name, IResource trace, TmfExperimentElement parent) { + this(name, trace, (TmfProjectModelElement) parent); + } + + private TmfTraceElement(String name, IResource trace, TmfProjectModelElement parent) { + super(name, trace, parent); + parent.addChild(this); + refreshTraceType(); + } + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + + public String getTraceType() { + return fTraceTypeId; + } + + public void refreshTraceType() { + try { + fTraceTypeId = getResource().getPersistentProperty(TRACETYPE); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + public ITmfTrace instantiateTrace() { + try { + if (fTraceTypeId != null) { + IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); + ITmfTrace trace = (ITmfTrace) ce.createExecutableExtension(TRACE_TYPE); + return trace; + } + } catch (CoreException e) { + e.printStackTrace(); + } + return null; + } + + public TmfEvent instantiateEvent() { + try { + if (fTraceTypeId != null) { + IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); + TmfEvent event = (TmfEvent) ce.createExecutableExtension(EVENT_TYPE); + return event; + } + } catch (CoreException e) { + e.printStackTrace(); + } + return null; + } + + public String getEditorId() { + if (fTraceTypeId != null) { + IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); + IConfigurationElement[] defaultEditorCE = ce.getChildren(DEFAULT_EDITOR); + if (defaultEditorCE.length == 1) { + return defaultEditorCE[0].getAttribute(ID); + } + } + return null; + } + + // ------------------------------------------------------------------------ + // IActionFilter + // ------------------------------------------------------------------------ + + @Override + public boolean testAttribute(Object target, String name, String value) { + if (name.equals(IS_LINKED)) { + boolean isLinked = getResource().isLinked(); + return Boolean.toString(isLinked).equals(value); + } + return false; + } + + // ------------------------------------------------------------------------ + // TmfTraceElement + // ------------------------------------------------------------------------ + + @Override + public TmfProjectElement getProject() { + if (getParent() instanceof TmfTraceFolder) { + TmfTraceFolder folder = (TmfTraceFolder) getParent(); + TmfProjectElement project = (TmfProjectElement) folder.getParent(); + return project; + } + if (getParent() instanceof TmfExperimentElement) { + TmfExperimentElement experiment = (TmfExperimentElement) getParent(); + TmfExperimentFolder folder = (TmfExperimentFolder) experiment.getParent(); + TmfProjectElement project = (TmfProjectElement) folder.getParent(); + return project; + } + return null; + } + + // ------------------------------------------------------------------------ + // IPropertySource2 + // ------------------------------------------------------------------------ + + @Override + public Object getEditableValue() { + return null; + } + + @Override + public IPropertyDescriptor[] getPropertyDescriptors() { + return sfDescriptors; + } + + @Override + public Object getPropertyValue(Object id) { + + if (sfName.equals(id)) + return getName(); + + if (sfPath.equals(id)) + return getPath().toString(); + + if (sfLocation.equals(id)) + return getLocation().toString(); + + if (sfIsLinked.equals(id)) + return Boolean.valueOf(getResource().isLinked()).toString(); + + if (sfEventType.equals(id)) { + if (fTraceTypeId != null) { + IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); + return (ce != null) ? (getCategory(ce) + " : " + ce.getAttribute(NAME)) : ""; //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + return null; + } + + private String getCategory(IConfigurationElement ce) { + String categoryId = ce.getAttribute(CATEGORY); + if (categoryId != null) { + IConfigurationElement category = sfTraceCategories.get(categoryId); + if (category != null && !category.equals("")) { //$NON-NLS-1$ + return category.getAttribute(NAME); + } + } + return "[no category]"; //$NON-NLS-1$ + } + + @Override + public void resetPropertyValue(Object id) { + } + + @Override + public void setPropertyValue(Object id, Object value) { + } + + @Override + public boolean isPropertyResettable(Object id) { + return false; + } + + @Override + public boolean isPropertySet(Object id) { + return false; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceFolder.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceFolder.java new file mode 100644 index 0000000000..cca799d477 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceFolder.java @@ -0,0 +1,146 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.model; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.IPropertySource2; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +/** + * TmfTraceFolder + *

    + */ +public class TmfTraceFolder extends TmfProjectModelElement implements IPropertySource2 { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + public static final String TRACE_FOLDER_NAME = "Traces"; //$NON-NLS-1$ + + // Property View stuff + private static final String sfInfoCategory = "Info"; //$NON-NLS-1$ + private static final String sfName = "name"; //$NON-NLS-1$ + private static final String sfPath = "path"; //$NON-NLS-1$ + private static final String sfLocation = "location"; //$NON-NLS-1$ + + private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); + private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); + private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, + sfLocation); + + private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, + sfLocationDescriptor }; + + static { + sfNameDescriptor.setCategory(sfInfoCategory); + sfPathDescriptor.setCategory(sfInfoCategory); + sfLocationDescriptor.setCategory(sfInfoCategory); + } + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public TmfTraceFolder(String name, IFolder resource, TmfProjectElement parent) { + super(name, resource, parent); + parent.addChild(this); + } + + // ------------------------------------------------------------------------ + // TmfProjectModelElement + // ------------------------------------------------------------------------ + + @Override + public IFolder getResource() { + return (IFolder) fResource; + } + + @Override + public TmfProjectElement getProject() { + return (TmfProjectElement) getParent(); + } + + @Override + public void refresh() { + TmfProjectElement project = (TmfProjectElement) getParent(); + project.refresh(); + } + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + + public List getTraces() { + List children = getChildren(); + List traces = new ArrayList(); + for (ITmfProjectModelElement child : children) { + if (child instanceof TmfTraceElement) { + traces.add((TmfTraceElement) child); + } + } + return traces; + } + + // ------------------------------------------------------------------------ + // IPropertySource2 + // ------------------------------------------------------------------------ + + @Override + public Object getEditableValue() { + return null; + } + + @Override + public IPropertyDescriptor[] getPropertyDescriptors() { + return sfDescriptors; + } + + @Override + public Object getPropertyValue(Object id) { + + if (sfName.equals(id)) + return getName(); + + if (sfPath.equals(id)) + return getPath().toString(); + + if (sfLocation.equals(id)) + return getLocation().toString(); + + return null; + } + + @Override + public void resetPropertyValue(Object id) { + } + + @Override + public void setPropertyValue(Object id, Object value) { + } + + @Override + public boolean isPropertyResettable(Object id) { + return false; + } + + @Override + public boolean isPropertySet(Object id) { + return false; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderContentProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderContentProvider.java new file mode 100644 index 0000000000..962f629ba8 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderContentProvider.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 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.tmf.ui.project.model; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +/** + * TraceFolderContentProvider + *

    + * TODO: Implement me. Please. + */ +public class TraceFolderContentProvider implements IStructuredContentProvider { + + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof TmfTraceFolder) { + TmfTraceFolder folder = (TmfTraceFolder) inputElement; + List elements = new ArrayList(); + for (ITmfProjectModelElement element : folder.getChildren()) { + if (element instanceof TmfTraceElement) { + TmfTraceElement trace = (TmfTraceElement) element; + if (trace.getTraceType() != null) { + elements.add(trace); + } + } + } + return elements.toArray(); + } + return null; + } + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderLabelProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderLabelProvider.java new file mode 100644 index 0000000000..7361fd729e --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TraceFolderLabelProvider.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 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.tmf.ui.project.model; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +/** + * TraceFolderLabelProvider + *

    + */ +public class TraceFolderLabelProvider extends LabelProvider implements ITableLabelProvider { + + @Override + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (element instanceof TmfTraceElement) { + TmfTraceElement entry = (TmfTraceElement) element; + switch (columnIndex) { + case 0: + return entry.getName(); + default: + return null; + } + } + return null; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java new file mode 100644 index 0000000000..3687de1de9 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2011 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 - Copied and adapted from NewFolderDialog + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.eclipse.ui.dialogs.SelectionStatusDialog; + +/** + * CopyExperimentDialog + *

    + */ +public class CopyExperimentDialog extends SelectionStatusDialog { + + // ------------------------------------------------------------------------ + // Members + // ------------------------------------------------------------------------ + + private final TmfExperimentElement fExperiment; + private Text fNewExperimentName; + private IContainer fExperimentFolder; + private TmfProjectElement fProject; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public CopyExperimentDialog(Shell shell, TmfExperimentElement experiment) { + super(shell); + fExperiment = experiment; + TmfExperimentFolder folder = (TmfExperimentFolder) experiment.getParent(); + fExperimentFolder = folder.getResource(); + fProject = experiment.getProject(); + setTitle(Messages.CopyExperimentDialog_DialogTitle); + setStatusLineAboveButtons(true); + } + + // ------------------------------------------------------------------------ + // Dialog + // ------------------------------------------------------------------------ + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createNewExperimentNameGroup(composite); + return composite; + } + + private void createNewExperimentNameGroup(Composite parent) { + Font font = parent.getFont(); + Composite folderGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + folderGroup.setLayout(layout); + folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Old experiment name label + Label oldExperimentLabel = new Label(folderGroup, SWT.NONE); + oldExperimentLabel.setFont(font); + oldExperimentLabel.setText(Messages.CopyExperimentDialog_ExperimentName); + + // Old experiment name field + Text oldExperimentName = new Text(folderGroup, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + oldExperimentName.setLayoutData(data); + oldExperimentName.setFont(font); + oldExperimentName.setText(fExperiment.getName()); + oldExperimentName.setEnabled(false); + + // New experiment name label + Label newExperimentLabel = new Label(folderGroup, SWT.NONE); + newExperimentLabel.setFont(font); + newExperimentLabel.setText(Messages.CopyExperimentDialog_ExperimentNewName); + + // New experiment name entry field + fNewExperimentName = new Text(folderGroup, SWT.BORDER); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + fNewExperimentName.setLayoutData(data); + fNewExperimentName.setFont(font); + fNewExperimentName.addListener(SWT.Modify, new Listener() { + @Override + public void handleEvent(Event event) { + validateNewExperimentName(); + } + }); + } + + private void validateNewExperimentName() { + + String name = fNewExperimentName.getText(); + IWorkspace workspace = fExperimentFolder.getWorkspace(); + IStatus nameStatus = workspace.validateName(name, IResource.FOLDER); + + if ("".equals(name)) { //$NON-NLS-1$ + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_EmptyNameError, null)); + return; + } + + if (nameStatus.isOK() == false) { + updateStatus(nameStatus); + return; + } + + IPath path = new Path(name); + if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) { + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_ExistingNameError, null)); + return; + } + + updateStatus(new Status(IStatus.OK, TmfUiPlugin.PLUGIN_ID, "")); //$NON-NLS-1$ + } + + // ------------------------------------------------------------------------ + // SelectionStatusDialog + // ------------------------------------------------------------------------ + + @Override + protected void computeResult() { + } + + @Override + public void create() { + super.create(); + getButton(IDialogConstants.OK_ID).setEnabled(false); + } + + @Override + protected void okPressed() { + IFolder folder = copyExperiment(fNewExperimentName.getText()); + if (folder == null) { + return; + } + setSelectionResult(new IFolder[] { folder }); + super.okPressed(); + + if (fProject != null) { + fProject.refresh(); + } + } + + private IFolder copyExperiment(String newName) { + + IPath oldPath = fExperiment.getResource().getFullPath(); + final IPath newPath = oldPath.append("../" + newName); //$NON-NLS-1$ + + WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { + @Override + public void execute(IProgressMonitor monitor) throws CoreException { + try { + monitor.beginTask("", 1000); //$NON-NLS-1$ + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + fExperiment.getResource().copy(newPath, IResource.FORCE | IResource.SHALLOW, null); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } finally { + monitor.done(); + } + } + }; + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); + } catch (InterruptedException exception) { + return null; + } catch (InvocationTargetException exception) { + MessageDialog.openError(getShell(), "", NLS.bind("", exception.getTargetException().getMessage())); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } catch (RuntimeException exception) { + return null; + } + + return fExperiment.getResource(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyTraceDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyTraceDialog.java new file mode 100644 index 0000000000..f4fd58a638 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyTraceDialog.java @@ -0,0 +1,225 @@ +/******************************************************************************* + * Copyright (c) 2011 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 - Copied and adapted from NewFolderDialog + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.eclipse.ui.dialogs.SelectionStatusDialog; + +/** + * CopyExperimentDialog + *

    + */ +public class CopyTraceDialog extends SelectionStatusDialog { + + // ------------------------------------------------------------------------ + // Members + // ------------------------------------------------------------------------ + + private final TmfTraceElement fTrace; + private Text fNewTraceName; + private IContainer fTraceFolder; + private TmfProjectElement fProject; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public CopyTraceDialog(Shell shell, TmfTraceElement trace) { + super(shell); + fTrace = trace; + ITmfProjectModelElement parent = trace.getParent(); + fTraceFolder = (IContainer) parent.getResource(); + fProject = trace.getProject(); + setTitle(Messages.CopyTraceDialog_DialogTitle); + setStatusLineAboveButtons(true); + } + + // ------------------------------------------------------------------------ + // Dialog + // ------------------------------------------------------------------------ + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createNewTraceNameGroup(composite); + return composite; + } + + private void createNewTraceNameGroup(Composite parent) { + Font font = parent.getFont(); + Composite folderGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + folderGroup.setLayout(layout); + folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Old trace name label + Label oldTraceLabel = new Label(folderGroup, SWT.NONE); + oldTraceLabel.setFont(font); + oldTraceLabel.setText(Messages.CopyTraceDialog_TraceName); + + // Old trace name field + Text oldTraceName = new Text(folderGroup, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + oldTraceName.setLayoutData(data); + oldTraceName.setFont(font); + oldTraceName.setText(fTrace.getName()); + oldTraceName.setEnabled(false); + + // New trace name label + Label newTraceLabel = new Label(folderGroup, SWT.NONE); + newTraceLabel.setFont(font); + newTraceLabel.setText(Messages.CopyTraceDialog_TraceNewName); + + // New trace name entry field + fNewTraceName = new Text(folderGroup, SWT.BORDER); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + fNewTraceName.setLayoutData(data); + fNewTraceName.setFont(font); + fNewTraceName.addListener(SWT.Modify, new Listener() { + @Override + public void handleEvent(Event event) { + validateNewTraceName(); + } + }); + } + + private void validateNewTraceName() { + + String name = fNewTraceName.getText(); + IWorkspace workspace = fTraceFolder.getWorkspace(); + IStatus nameStatus = workspace.validateName(name, IResource.FOLDER); + + if ("".equals(name)) { //$NON-NLS-1$ + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, + Messages.Dialog_EmptyNameError, null)); + return; + } + + if (nameStatus.isOK() == false) { + updateStatus(nameStatus); + return; + } + + IPath path = new Path(name); + if (fTraceFolder.getFolder(path).exists() || fTraceFolder.getFile(path).exists()) { + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, + Messages.Dialog_ExistingNameError, null)); + return; + } + + updateStatus(new Status(IStatus.OK, TmfUiPlugin.PLUGIN_ID, "")); //$NON-NLS-1$ + } + + // ------------------------------------------------------------------------ + // SelectionStatusDialog + // ------------------------------------------------------------------------ + + @Override + protected void computeResult() { + } + + @Override + public void create() { + super.create(); + getButton(IDialogConstants.OK_ID).setEnabled(false); + } + + @Override + protected void okPressed() { + IResource trace = copyTrace(fNewTraceName.getText()); + if (trace == null) { + return; + } + setSelectionResult(new IResource[] { trace }); + super.okPressed(); + + if (fProject != null) { + fProject.refresh(); + } + } + + private IResource copyTrace(String newName) { + + IPath oldPath = fTrace.getResource().getFullPath(); + final IPath newPath = oldPath.append("../" + newName); //$NON-NLS-1$ + + WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { + @Override + public void execute(IProgressMonitor monitor) throws CoreException { + try { + monitor.beginTask("", 1000); //$NON-NLS-1$ + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + fTrace.getResource().copy(newPath, IResource.FORCE | IResource.SHALLOW, null); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } finally { + monitor.done(); + } + } + }; + + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); + } catch (InterruptedException exception) { + return null; + } catch (InvocationTargetException exception) { + MessageDialog.openError(getShell(), "", NLS.bind("", exception.getTargetException().getMessage())); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } catch (RuntimeException exception) { + return null; + } + + return fTrace.getResource(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java new file mode 100644 index 0000000000..956b18bcfd --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizard.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 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.tmf.ui.project.wizards; + +import java.util.List; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.ui.IImportWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.ide.IDE; + +/** + * ImportTraceWizard + *

    + */ +public class ImportTraceWizard extends Wizard implements IImportWizard { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + static private final String PLUGIN_ID = TmfUiPlugin.PLUGIN_ID; + static private final String IMPORT_WIZARD = "ImportTraceWizard"; //$NON-NLS-1$ + static private final String ICON_PATH = "icons/wizban/trace_import_wiz.png"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private IWorkbench fWorkbench; + private IStructuredSelection fSelection; + private ImportTraceWizardPage fTraceImportWizardPage; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public ImportTraceWizard() { + IDialogSettings workbenchSettings = TmfUiPlugin.getDefault().getDialogSettings(); + IDialogSettings section = workbenchSettings.getSection(IMPORT_WIZARD); + if (section == null) { + section = workbenchSettings.addNewSection(IMPORT_WIZARD); + } + setDialogSettings(section); + } + + // ------------------------------------------------------------------------ + // Wizard + // ------------------------------------------------------------------------ + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + fWorkbench = workbench; + fSelection = selection; + + List selectedResources = IDE.computeSelectedResources(selection); + if (!selectedResources.isEmpty()) { + fSelection = new StructuredSelection(selectedResources); + } + + setWindowTitle(Messages.ImportTraceWizard_DialogTitle); + setDefaultPageImageDescriptor(TmfUiPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH)); + setNeedsProgressMonitor(true); + } + + @Override + public void addPages() { + super.addPages(); + fTraceImportWizardPage = new ImportTraceWizardPage(fWorkbench, fSelection); + addPage(fTraceImportWizardPage); + } + + @Override + public boolean performFinish() { + return fTraceImportWizardPage.finish(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java new file mode 100644 index 0000000000..ab0222f648 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/ImportTraceWizardPage.java @@ -0,0 +1,839 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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 + * Francois Chouinard - Got rid of dependency on internal platform class + * Francois Chouinard - Complete re-design + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.wizards; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTreeViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.linuxtools.tmf.TmfCorePlugin; +import org.eclipse.linuxtools.tmf.TmfProjectNature; +import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.dialogs.FileSystemElement; +import org.eclipse.ui.dialogs.WizardResourceImportPage; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider; +import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider; +import org.eclipse.ui.wizards.datatransfer.ImportOperation; + +/** + * ImportTraceWizardPage + *

    + * A variant of the standard resource import wizard with the following changes: + *

      + *
    • A folder/file combined checkbox tree viewer to select traces + *
    • Cherry-picking of traces in the file structure without re-creating the file hierarchy + *
    • A trace types dropbox for optional characterization + *
    + * For our purpose, a trace can either be a single file or a whole directory sub-tree, whichever is reached first from + * the root directory. + *

    + * TODO: Consider adding Filter/Select/Deselect buttons + */ +public class ImportTraceWizardPage extends WizardResourceImportPage implements Listener { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + static private final String IMPORT_WIZARD_PAGE = "ImportTraceWizardPage"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + // Folder navigation start point (saved between invocations) + private static String fRootDirectory = null; + + // Navigation folder content viewer and selector + private CheckboxTreeViewer fFolderViewer; + + // Parent tracing project + private IProject fProject; + + // Target import directory ('Traces' folder) + private IFolder fTargetFolder; + + // Selected trace attributes + private final Map fTraceAttributes = new HashMap(); + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + protected ImportTraceWizardPage(String name, IStructuredSelection selection) { + super(name, selection); + } + + public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) { + this(IMPORT_WIZARD_PAGE, selection); + setTitle(Messages.ImportTraceWizard_FileSystemTitle); + setDescription(Messages.ImportTraceWizard_ImportTrace); + + // Locate the target trace folder + IFolder traceFolder = null; + Object element = selection.getFirstElement(); + + if (element instanceof TmfTraceFolder) { + TmfTraceFolder tmfTraceFolder = (TmfTraceFolder) element; + fProject = tmfTraceFolder.getProject().getResource(); + traceFolder = tmfTraceFolder.getResource(); + } else if (element instanceof IProject) { + IProject project = (IProject) element; + try { + if (project.hasNature(TmfProjectNature.ID)) { + traceFolder = (IFolder) project.findMember(TmfTraceFolder.TRACE_FOLDER_NAME); + } + } catch (CoreException e) { + } + } + + // Set the target trace folder + if (traceFolder != null) { + fTargetFolder = traceFolder; + String path = traceFolder.getFullPath().toOSString(); + setContainerFieldValue(path); + } + } + + // ------------------------------------------------------------------------ + // WizardResourceImportPage + // ------------------------------------------------------------------------ + + @Override + public void createControl(Composite parent) { + super.createControl(parent); + // Restore last directory if applicable + if (fRootDirectory != null) { + directoryNameField.setText(fRootDirectory); + updateFromSourceField(); + } + } + + @Override + protected void createSourceGroup(Composite parent) { + createDirectorySelectionGroup(parent); + createFileSelectionGroup(parent); + createTraceTypeGroup(parent); + validateSourceGroup(); + } + + @Override + protected void createFileSelectionGroup(Composite parent) { + + // This Composite is only used for widget alignment purposes + Composite composite = new Composite(parent, SWT.NONE); + composite.setFont(parent.getFont()); + GridLayout layout = new GridLayout(); + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + final int PREFERRED_LIST_HEIGHT = 150; + + fFolderViewer = new CheckboxTreeViewer(composite, SWT.BORDER); + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = PREFERRED_LIST_HEIGHT; + fFolderViewer.getTree().setLayoutData(data); + fFolderViewer.getTree().setFont(parent.getFont()); + + fFolderViewer.setContentProvider(getFileProvider()); + fFolderViewer.setLabelProvider(new WorkbenchLabelProvider()); + fFolderViewer.addCheckStateListener(new ICheckStateListener() { + @Override + public void checkStateChanged(CheckStateChangedEvent event) { + Object elem = event.getElement(); + if (elem instanceof FileSystemElement) { + FileSystemElement element = (FileSystemElement) elem; + if (fFolderViewer.getGrayed(element)) { + fFolderViewer.setSubtreeChecked(element, false); + fFolderViewer.setGrayed(element, false); + } else if (event.getChecked()) { + fFolderViewer.setSubtreeChecked(event.getElement(), true); + } else { + fFolderViewer.setParentsGrayed(element, true); + if (!element.isDirectory()) { + fFolderViewer.setGrayed(element, false); + } + } + updateWidgetEnablements(); + } + } + }); + } + + @Override + protected ITreeContentProvider getFolderProvider() { + return null; + } + + @Override + protected ITreeContentProvider getFileProvider() { + return new WorkbenchContentProvider() { + @Override + public Object[] getChildren(Object o) { + if (o instanceof FileSystemElement) { + FileSystemElement element = (FileSystemElement) o; + populateChildren(element); + // For our purpose, we need folders + files + Object[] folders = element.getFolders().getChildren(); + Object[] files = element.getFiles().getChildren(); + + List result = new LinkedList(); + for (Object folder : folders) + result.add(folder); + for (Object file : files) + result.add(file); + + return result.toArray(); + } + return new Object[0]; + } + }; + } + + private void populateChildren(FileSystemElement parent) { + // Do not re-populate if the job was done already... + FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE; + if (parent.getFolders().size() == 0 && parent.getFiles().size() == 0) { + Object fileSystemObject = parent.getFileSystemObject(); + List children = provider.getChildren(fileSystemObject); + if (children != null) { + Iterator iterator = children.iterator(); + while (iterator.hasNext()) { + Object child = iterator.next(); + String label = provider.getLabel(child); + FileSystemElement element = new FileSystemElement(label, parent, provider.isFolder(child)); + element.setFileSystemObject(child); + } + } + } + } + + @Override + protected List getSelectedResources() { + List resources = new ArrayList(); + Object[] checkedItems = fFolderViewer.getCheckedElements(); + for (Object item : checkedItems) { + if (item instanceof FileSystemElement && !fFolderViewer.getGrayed(item)) { + resources.add((FileSystemElement) item); + } + } + return resources; + } + + // ------------------------------------------------------------------------ + // Directory Selection Group (forked WizardFileSystemResourceImportPage1) + // ------------------------------------------------------------------------ + + protected Combo directoryNameField; + protected Button directoryBrowseButton; + private boolean entryChanged = false; + + protected void createDirectorySelectionGroup(Composite parent) { + + Composite directoryContainerGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + directoryContainerGroup.setLayout(layout); + directoryContainerGroup.setFont(parent.getFont()); + directoryContainerGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + // Label ("Trace directory:") + Label groupLabel = new Label(directoryContainerGroup, SWT.NONE); + groupLabel.setText(Messages.ImportTraceWizard_DirectoryLocation); + groupLabel.setFont(parent.getFont()); + + // Directory name entry field + directoryNameField = new Combo(directoryContainerGroup, SWT.BORDER); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + directoryNameField.setLayoutData(data); + directoryNameField.setFont(parent.getFont()); + + directoryNameField.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateFromSourceField(); + } + }); + + directoryNameField.addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + // If there has been a key pressed then mark as dirty + entryChanged = true; + if (e.character == SWT.CR) { // Windows... + entryChanged = false; + updateFromSourceField(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + } + }); + + directoryNameField.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + // Do nothing when getting focus + } + + @Override + public void focusLost(FocusEvent e) { + // Clear the flag to prevent constant update + if (entryChanged) { + entryChanged = false; + updateFromSourceField(); + } + } + }); + + // Browse button + directoryBrowseButton = new Button(directoryContainerGroup, SWT.PUSH); + directoryBrowseButton.setText(Messages.ImportTraceWizard_BrowseButton); + directoryBrowseButton.addListener(SWT.Selection, this); + directoryBrowseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + directoryBrowseButton.setFont(parent.getFont()); + setButtonLayoutData(directoryBrowseButton); + } + + // ------------------------------------------------------------------------ + // Browse for the source directory + // ------------------------------------------------------------------------ + + @Override + public void handleEvent(Event event) { + if (event.widget == directoryBrowseButton) { + handleSourceDirectoryBrowseButtonPressed(); + } + super.handleEvent(event); + } + + protected void handleSourceDirectoryBrowseButtonPressed() { + String currentSource = directoryNameField.getText(); + DirectoryDialog dialog = new DirectoryDialog(directoryNameField.getShell(), SWT.SAVE | SWT.SHEET); + dialog.setText(Messages.ImportTraceWizard_SelectTraceDirectoryTitle); + dialog.setMessage(Messages.ImportTraceWizard_SelectTraceDirectoryMessage); + dialog.setFilterPath(getSourceDirectoryName(currentSource)); + + String selectedDirectory = dialog.open(); + if (selectedDirectory != null) { + // Just quit if the directory is not valid + if ((getSourceDirectory(selectedDirectory) == null) || selectedDirectory.equals(currentSource)) { + return; + } + // If it is valid then proceed to populate + setErrorMessage(null); + setSourceName(selectedDirectory); + } + } + + private File getSourceDirectory() { + return getSourceDirectory(directoryNameField.getText()); + } + + private File getSourceDirectory(String path) { + File sourceDirectory = new File(getSourceDirectoryName(path)); + if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) { + return null; + } + + return sourceDirectory; + } + + private String getSourceDirectoryName(String sourceName) { + IPath result = new Path(sourceName.trim()); + if (result.getDevice() != null && result.segmentCount() == 0) { + result = result.addTrailingSeparator(); + } else { + result = result.removeTrailingSeparator(); + } + return result.toOSString(); + } + + private String getSourceDirectoryName() { + return getSourceDirectoryName(directoryNameField.getText()); + } + + private void updateFromSourceField() { + setSourceName(directoryNameField.getText()); + updateWidgetEnablements(); + } + + private void setSourceName(String path) { + if (path.length() > 0) { + String[] currentItems = directoryNameField.getItems(); + int selectionIndex = -1; + for (int i = 0; i < currentItems.length; i++) { + if (currentItems[i].equals(path)) { + selectionIndex = i; + } + } + if (selectionIndex < 0) { + int oldLength = currentItems.length; + String[] newItems = new String[oldLength + 1]; + System.arraycopy(currentItems, 0, newItems, 0, oldLength); + newItems[oldLength] = path; + directoryNameField.setItems(newItems); + selectionIndex = oldLength; + } + directoryNameField.select(selectionIndex); + } + resetSelection(); + } + + // ------------------------------------------------------------------------ + // File Selection Group (forked WizardFileSystemResourceImportPage1) + // ------------------------------------------------------------------------ + + private void resetSelection() { + FileSystemElement root = getFileSystemTree(); + populateListViewer(root); + } + + private void populateListViewer(final Object treeElement) { + fFolderViewer.setInput(treeElement); + } + + private FileSystemElement getFileSystemTree() { + File sourceDirectory = getSourceDirectory(); + if (sourceDirectory == null) { + return null; + } + return selectFiles(sourceDirectory, FileSystemStructureProvider.INSTANCE); + } + + private FileSystemElement selectFiles(final Object rootFileSystemObject, + final IImportStructureProvider structureProvider) { + final FileSystemElement[] results = new FileSystemElement[1]; + BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { + @Override + public void run() { + // Create the root element from the supplied file system object + results[0] = createRootElement(rootFileSystemObject, structureProvider); + } + }); + return results[0]; + } + + private FileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) { + + boolean isContainer = provider.isFolder(fileSystemObject); + String elementLabel = provider.getLabel(fileSystemObject); + + FileSystemElement dummyParent = new FileSystemElement("", null, true); //$NON-NLS-1$ + FileSystemElement element = new FileSystemElement(elementLabel, dummyParent, isContainer); + element.setFileSystemObject(fileSystemObject); + + // Get the first level + populateChildren(element); + + return dummyParent; + } + + // ------------------------------------------------------------------------ + // Trace Type Group + // ------------------------------------------------------------------------ + + private Combo fTraceTypes; + + private final void createTraceTypeGroup(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + layout.makeColumnsEqualWidth = false; + composite.setLayout(layout); + composite.setFont(parent.getFont()); + GridData buttonData = new GridData(SWT.FILL, SWT.FILL, true, false); + composite.setLayoutData(buttonData); + + // Trace type label ("Trace Type:") + Label typeLabel = new Label(composite, SWT.NONE); + typeLabel.setText(Messages.ImportTraceWizard_TraceType); + typeLabel.setFont(parent.getFont()); + + // Trace type combo + fTraceTypes = new Combo(composite, SWT.BORDER); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1); + fTraceTypes.setLayoutData(data); + fTraceTypes.setFont(parent.getFont()); + + String[] availableTraceTypes = getAvailableTraceTypes(); + fTraceTypes.setItems(availableTraceTypes); + + fTraceTypes.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + validateSourceGroup(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + + private String[] getAvailableTraceTypes() { + List traceTypes = new ArrayList(); + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( + TmfCorePlugin.TMF_TRACE_TYPE_ID); + for (IConfigurationElement ce : config) { + String traceTypeName = ce.getAttribute("name"); //$NON-NLS-1$ + fTraceAttributes.put(traceTypeName, ce); + traceTypes.add(traceTypeName); + } + Collections.sort(traceTypes); + + // TODO: Add Custom Parsers + + // Format result + String[] result = new String[traceTypes.size()]; + result = traceTypes.toArray(result); + return result; + } + + // ------------------------------------------------------------------------ + // Options + // ------------------------------------------------------------------------ + + private Button overwriteExistingResourcesCheckbox; + private Button createLinksInWorkspaceButton; + + @Override + protected void createOptionsGroupButtons(Group optionsGroup) { + + // Overwrite checkbox + overwriteExistingResourcesCheckbox = new Button(optionsGroup, SWT.CHECK); + overwriteExistingResourcesCheckbox.setFont(optionsGroup.getFont()); + overwriteExistingResourcesCheckbox.setText(Messages.ImportTraceWizard_OverwriteExistingTrace); + overwriteExistingResourcesCheckbox.setSelection(false); + + // Create links checkbox + createLinksInWorkspaceButton = new Button(optionsGroup, SWT.CHECK); + createLinksInWorkspaceButton.setFont(optionsGroup.getFont()); + createLinksInWorkspaceButton.setText(Messages.ImportTraceWizard_CreateLinksInWorkspace); + createLinksInWorkspaceButton.setSelection(true); + + createLinksInWorkspaceButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateWidgetEnablements(); + } + }); + + updateWidgetEnablements(); + } + + // ------------------------------------------------------------------------ + // Determine if the finish button can be enabled + // ------------------------------------------------------------------------ + + @Override + public boolean validateSourceGroup() { + + File sourceDirectory = getSourceDirectory(); + if (sourceDirectory == null) { + setMessage(Messages.ImportTraceWizard_SelectTraceSourceEmpty); + return false; + } + + if (sourceConflictsWithDestination(new Path(sourceDirectory.getPath()))) { + setMessage(null); + setErrorMessage(getSourceConflictMessage()); + return false; + } + + List resourcesToImport = getSelectedResources(); + if (resourcesToImport.size() == 0) { + setMessage(null); + setErrorMessage(Messages.ImportTraceWizard_SelectTraceNoneSelected); + return false; + } + + IContainer container = getSpecifiedContainer(); + if (container != null && container.isVirtual()) { + if (Platform.getPreferencesService().getBoolean(TmfUiPlugin.PLUGIN_ID, + ResourcesPlugin.PREF_DISABLE_LINKING, false, null)) { + setMessage(null); + setErrorMessage(Messages.ImportTraceWizard_CannotImportFilesUnderAVirtualFolder); + return false; + } + if (createLinksInWorkspaceButton == null || createLinksInWorkspaceButton.getSelection() == false) { + setMessage(null); + setErrorMessage(Messages.ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder); + return false; + } + } + + // Perform trace validation + String traceTypeName = fTraceTypes.getText(); + if (traceTypeName != null && !"".equals(traceTypeName)) { //$NON-NLS-1$ + List traces = isolateTraces(); + for (File trace : traces) { + IConfigurationElement ce = fTraceAttributes.get(traceTypeName); + ITmfTrace tmfTrace = null; + try { + tmfTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceElement.TRACE_TYPE); + if (!tmfTrace.validate(fProject, trace.getAbsolutePath())) { + setMessage(null); + setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed); + return false; + } + if (tmfTrace != null) + tmfTrace.dispose(); + } catch (CoreException e) { + } finally { + if (tmfTrace != null) + tmfTrace.dispose(); + } + } + } + + setErrorMessage(null); + return true; + } + + private List isolateTraces() { + + List traces = new ArrayList(); + + // Get the selection + List selectedResources = getSelectedResources(); + Iterator resources = selectedResources.iterator(); + + // Get the sorted list of unique entries + Map fileSystemObjects = new HashMap(); + while (resources.hasNext()) { + File resource = (File) resources.next().getFileSystemObject(); + String key = resource.getAbsolutePath(); + fileSystemObjects.put(key, resource); + } + List files = new ArrayList(fileSystemObjects.keySet()); + Collections.sort(files); + + // After sorting, traces correspond to the unique prefixes + String prefix = null; + for (int i = 0; i < files.size(); i++) { + File file = fileSystemObjects.get(files.get(i)); + String name = file.getAbsolutePath(); + if (prefix == null || !name.startsWith(prefix)) { + prefix = name; // new prefix + traces.add(file); + } + } + + return traces; + } + + // ------------------------------------------------------------------------ + // Import the trace(s) + // ------------------------------------------------------------------------ + + public boolean finish() { + // Ensure source is valid + File sourceDir = new File(getSourceDirectoryName()); + if (!sourceDir.isDirectory()) { + setErrorMessage(Messages.ImportTraceWizard_InvalidTraceDirectory); + return false; + } + + String sourceDirPath; + try { + sourceDirPath = sourceDir.getCanonicalPath(); + } catch (IOException e) { + MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information, + Messages.ImportTraceWizard_InvalidTraceDirectory); + return false; + } + + // Save directory for next import operation + fRootDirectory = getSourceDirectoryName(); + + List selectedResources = getSelectedResources(); + Iterator resources = selectedResources.iterator(); + + // Use a map to end up with unique resources (getSelectedResources() can return duplicates) + Map fileSystemObjects = new HashMap(); + while (resources.hasNext()) { + File file = (File) resources.next().getFileSystemObject(); + String key = file.getAbsolutePath(); + fileSystemObjects.put(key, file); + } + + if (fileSystemObjects.size() > 0) { + boolean ok = importResources(sourceDirPath, fileSystemObjects); + String traceType = fTraceTypes.getText(); + IConfigurationElement ce = fTraceAttributes.get(traceType); + if (ok && !traceType.equals("") && ce != null) { //$NON-NLS-1$ + // Tag the selected traces with their type + List files = new ArrayList(fileSystemObjects.keySet()); + Collections.sort(files); + // After sorting, traces correspond to the unique prefixes + String prefix = null; + for (int i = 0; i < files.size(); i++) { + File file = fileSystemObjects.get(files.get(i)); + String name = file.getAbsolutePath(); + if (prefix == null || !name.startsWith(prefix)) { + prefix = name; // new prefix + IResource resource = fTargetFolder.findMember(file.getName()); + if (resource != null) { + try { + // Set the trace properties for this resource + resource.setPersistentProperty(TmfTraceElement.TRACEBUNDLE, ce.getContributor() + .getName()); + resource.setPersistentProperty(TmfTraceElement.TRACETYPE, + ce.getAttribute(TmfTraceElement.ID)); + resource.setPersistentProperty(TmfTraceElement.TRACEICON, + ce.getAttribute(TmfTraceElement.ICON)); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + } + } + return ok; + } + + MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information, + Messages.ImportTraceWizard_SelectTraceNoneSelected); + return false; + } + + private boolean importResources(String rootDirectory, Map fileSystemObjects) { + + // Determine the sorted canonical list of items to import + List fileList = new ArrayList(); + for (String key : fileSystemObjects.keySet()) { + fileList.add(fileSystemObjects.get(key)); + } + Collections.sort(fileList); + + // Perform a distinct import operation for everything that has the same prefix + // (distinct prefixes correspond to traces - we don't want to re-create parent structures) + boolean ok = true; + boolean isLinked = createLinksInWorkspaceButton.getSelection(); + for (int i = 0; i < fileList.size(); i++) { + File resource = fileList.get(i); + File parentFolder = new File(resource.getParent()); + + List subList = new ArrayList(); + subList.add(resource); + if (resource.isDirectory()) { + String prefix = resource.getAbsolutePath(); + boolean hasSamePrefix = true; + for (int j = i; j < fileList.size() && hasSamePrefix; j++) { + File res = fileList.get(j); + hasSamePrefix = res.getAbsolutePath().startsWith(prefix); + if (hasSamePrefix) { + // Import children individually if not linked + if (!isLinked) { + subList.add(res); + } + i = j; + } + } + } + + // Perform the import operation for this subset + FileSystemStructureProvider fileSystemStructureProvider = FileSystemStructureProvider.INSTANCE; + ImportOperation operation = new ImportOperation(getContainerFullPath(), parentFolder, + fileSystemStructureProvider, this, subList); + operation.setContext(getShell()); + ok = executeImportOperation(operation); + } + + return ok; + } + + private boolean executeImportOperation(ImportOperation op) { + initializeOperation(op); + + try { + getContainer().run(true, true, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + displayErrorDialog(e.getTargetException()); + return false; + } + + IStatus status = op.getStatus(); + if (!status.isOK()) { + ErrorDialog.openError(getContainer().getShell(), Messages.ImportTraceWizard_ImportProblem, null, status); + return false; + } + + return true; + } + + private void initializeOperation(ImportOperation op) { + op.setCreateContainerStructure(false); + op.setOverwriteResources(overwriteExistingResourcesCheckbox.getSelection()); + op.setCreateLinks(createLinksInWorkspaceButton.getSelection()); + op.setVirtualFolders(false); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java new file mode 100644 index 0000000000..b0ada6757c --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.ui.project.wizards; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.project.wizards.messages"; //$NON-NLS-1$ + + public static String NewProjectWizard_DialogHeader; + public static String NewProjectWizard_DialogMessage; + + public static String ImportTraceWizard_DialogTitle; + public static String ImportTraceWizard_FileSystemTitle; + public static String ImportTraceWizard_ImportTrace; + public static String ImportTraceWizard_DirectoryLocation; + public static String ImportTraceWizard_SelectTraceDirectoryTitle; + public static String ImportTraceWizard_SelectTraceDirectoryMessage; + public static String ImportTraceWizard_TraceType; + public static String ImportTraceWizard_OverwriteExistingTrace; + public static String ImportTraceWizard_CreateLinksInWorkspace; + public static String ImportTraceWizard_InvalidTraceDirectory; + public static String ImportTraceWizard_TraceValidationFailed; + public static String ImportTraceWizard_SelectTraceSourceEmpty; + public static String ImportTraceWizard_SelectTraceNoneSelected; + public static String ImportTraceWizard_ImportProblem; + public static String ImportTraceWizard_CannotImportFilesUnderAVirtualFolder; + public static String ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder; + public static String ImportTraceWizard_BrowseButton; + public static String ImportTraceWizard_Information; + + public static String SelectTracesWizard_WindowTitle; + public static String SelectTracesWizardPage_TraceColumnHeader; + public static String SelectTracesWizardPage_WindowTitle; + public static String SelectTracesWizardPage_Description; + + public static String Dialog_EmptyNameError; + public static String Dialog_ExistingNameError; + + public static String NewExperimentDialog_DialogTitle; + public static String NewExperimentDialog_ExperimentName; + + public static String RenameExperimentDialog_DialogTitle; + public static String RenameExperimentDialog_ExperimentName; + public static String RenameExperimentDialog_ExperimentNewName; + + public static String CopyExperimentDialog_DialogTitle; + public static String CopyExperimentDialog_ExperimentName; + public static String CopyExperimentDialog_ExperimentNewName; + + public static String RenameTraceDialog_DialogTitle; + public static String RenameTraceDialog_TraceName; + public static String RenameTraceDialog_TraceNewName; + + public static String CopyTraceDialog_DialogTitle; + public static String CopyTraceDialog_TraceName; + public static String CopyTraceDialog_TraceNewName; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewExperimentDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewExperimentDialog.java new file mode 100644 index 0000000000..d78a2c41e1 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewExperimentDialog.java @@ -0,0 +1,213 @@ +/******************************************************************************* + * Copyright (c) 2009, 2011 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 - Copied and adapted from NewFolderDialog + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.eclipse.ui.dialogs.SelectionStatusDialog; + +/** + * NewExperimentHandler + *

    + */ +public class NewExperimentDialog extends SelectionStatusDialog { + + // ------------------------------------------------------------------------ + // Members + // ------------------------------------------------------------------------ + + private Text fExperimentName; + private final IContainer fExperimentFolder; + private TmfProjectElement fProject; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public NewExperimentDialog(Shell shell, TmfExperimentFolder experimentFolder) { + super(shell); + fExperimentFolder = experimentFolder.getResource(); + fProject = experimentFolder.getProject(); + setTitle(Messages.NewExperimentDialog_DialogTitle); + setStatusLineAboveButtons(true); + } + + // ------------------------------------------------------------------------ + // Dialog + // ------------------------------------------------------------------------ + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createExperimentNameGroup(composite); + return composite; + } + + private void createExperimentNameGroup(Composite parent) { + Font font = parent.getFont(); + Composite folderGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + folderGroup.setLayout(layout); + folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // New experiment label + Label experimentLabel = new Label(folderGroup, SWT.NONE); + experimentLabel.setFont(font); + experimentLabel.setText(Messages.NewExperimentDialog_ExperimentName); + + // New experiment name entry field + fExperimentName = new Text(folderGroup, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + fExperimentName.setLayoutData(data); + fExperimentName.setFont(font); + fExperimentName.addListener(SWT.Modify, new Listener() { + @Override + public void handleEvent(Event event) { + validateNewExperimentName(); + } + }); + } + + private void validateNewExperimentName() { + + String name = fExperimentName.getText(); + IWorkspace workspace = fExperimentFolder.getWorkspace(); + IStatus nameStatus = workspace.validateName(name, IResource.FOLDER); + + if ("".equals(name)) { //$NON-NLS-1$ + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_EmptyNameError, null)); + return; + } + + if (nameStatus.isOK() == false) { + updateStatus(nameStatus); + return; + } + + IPath path = new Path(name); + if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) { + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_ExistingNameError, null)); + return; + } + + updateStatus(new Status(IStatus.OK, TmfUiPlugin.PLUGIN_ID, "")); //$NON-NLS-1$ + } + + // ------------------------------------------------------------------------ + // SelectionStatusDialog + // ------------------------------------------------------------------------ + + @Override + protected void computeResult() { + } + + @Override + public void create() { + super.create(); + getButton(IDialogConstants.OK_ID).setEnabled(false); + } + + @Override + protected void okPressed() { + IFolder folder = createNewExperiment(fExperimentName.getText()); + if (folder == null) { + return; + } + setSelectionResult(new IFolder[] { folder }); + super.okPressed(); + + if (fProject != null) { + fProject.refresh(); + } + } + + private IFolder createNewExperiment(String experimentName) { + + final IFolder experimentFolder = createExperiment(experimentName); + + WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { + @Override + public void execute(IProgressMonitor monitor) throws CoreException { + try { + monitor.beginTask("", 1000); //$NON-NLS-1$ + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + experimentFolder.create(false, true, monitor); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } finally { + monitor.done(); + } + } + }; + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); + } catch (InterruptedException exception) { + return null; + } catch (InvocationTargetException exception) { + MessageDialog.openError(getShell(), "", NLS.bind("", exception.getTargetException().getMessage())); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } catch (RuntimeException exception) { + return null; + } + + return experimentFolder; + } + + private IFolder createExperiment(String experimentName) { + IWorkspaceRoot workspaceRoot = fExperimentFolder.getWorkspace().getRoot(); + IPath folderPath = fExperimentFolder.getFullPath().append(experimentName); + IFolder folder = workspaceRoot.getFolder(folderPath); + + return folder; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewProjectMainWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectMainWizardPage.java similarity index 93% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewProjectMainWizardPage.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectMainWizardPage.java index b4c2f5ccc4..9a40759b14 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewProjectMainWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectMainWizardPage.java @@ -10,7 +10,7 @@ * Francois Chouinard - Initial API and implementation *******************************************************************************/ -package org.eclipse.linuxtools.tmf.ui.views.project.dialogs; +package org.eclipse.linuxtools.tmf.ui.project.wizards; import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewProjectWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectWizard.java similarity index 73% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewProjectWizard.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectWizard.java index 9f35d7db4b..a4e626e183 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewProjectWizard.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Ericsson + * Copyright (c) 2009, 2011 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,7 +10,7 @@ * Francois Chouinard - Initial API and implementation *******************************************************************************/ -package org.eclipse.linuxtools.tmf.ui.views.project.dialogs; +package org.eclipse.linuxtools.tmf.ui.project.wizards; import java.net.URI; @@ -22,23 +22,24 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.linuxtools.tmf.TmfProjectNature; import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.internal.Messages; -import org.eclipse.linuxtools.tmf.ui.views.project.TmfProjectNature; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; /** * NewProjectWizard *

    - * TODO: Implement me. Please. */ -public class NewProjectWizard extends BasicNewResourceWizard { +public class NewProjectWizard extends BasicNewResourceWizard implements IExecutableExtension { - private String fTtitle; - private String fDescription; + private final String fTtitle; + private final String fDescription; protected NewProjectMainWizardPage fMainPage; protected String fProjectName; @@ -68,18 +69,22 @@ public class NewProjectWizard extends BasicNewResourceWizard { fDescription = desc; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.jface.wizard.Wizard#addPages() */ @Override public void addPages() { - fMainPage= new NewProjectMainWizardPage(Messages.NewProjectWizard_DialogHeader); + fMainPage = new NewProjectMainWizardPage(Messages.NewProjectWizard_DialogHeader); fMainPage.setTitle(fTtitle); fMainPage.setDescription(fDescription); addPage(fMainPage); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.jface.wizard.Wizard#performCancel() */ @Override @@ -87,7 +92,9 @@ public class NewProjectWizard extends BasicNewResourceWizard { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.jface.wizard.Wizard#performFinish() */ @Override @@ -95,13 +102,10 @@ public class NewProjectWizard extends BasicNewResourceWizard { fProjectName = fMainPage.getProjectName(); fProjectLocation = fMainPage.useDefaults() ? null : fMainPage.getLocationURI(); fProject = createProject(fProjectName, fProjectLocation, new NullProgressMonitor()); + BasicNewProjectResourceWizard.updatePerspective(fConfigElement); return true; } - public IProject getProject() { - return fProject; - } - /** * @param projectName * @param projectLocation @@ -126,23 +130,31 @@ public class NewProjectWizard extends BasicNewResourceWizard { project.open(monitor); IProjectDescription description = project.getDescription(); - description.setNatureIds(new String[] { TmfProjectNature.ID } ); + description.setNatureIds(new String[] { TmfProjectNature.ID }); project.setDescription(description, null); - IFolder folder = project.getFolder(TmfProjectNode.TRACE_FOLDER_NAME); + IFolder folder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); if (!folder.exists()) folder.create(true, true, null); - folder = project.getFolder(TmfProjectNode.EXPER_FOLDER_NAME); + folder = project.getFolder(TmfExperimentFolder.EXPER_FOLDER_NAME); if (!folder.exists()) folder.create(true, true, null); return project; - } - catch (CoreException e) { + } catch (CoreException e) { e.printStackTrace(); } return null; } -} \ No newline at end of file + // ------------------------------------------------------------------------ + // IExecutableExtension + // ------------------------------------------------------------------------ + + @Override + public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { + fConfigElement = config; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java new file mode 100644 index 0000000000..d56524375b --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2011 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 - Copied and adapted from NewFolderDialog + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.eclipse.ui.dialogs.SelectionStatusDialog; + +/** + * RenameExperimentDialog + *

    + */ +public class RenameExperimentDialog extends SelectionStatusDialog { + + // ------------------------------------------------------------------------ + // Members + // ------------------------------------------------------------------------ + + private final TmfExperimentElement fExperiment; + private Text fNewExperimentName; + private IContainer fExperimentFolder; + private TmfProjectElement fProject; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public RenameExperimentDialog(Shell shell, TmfExperimentElement experiment) { + super(shell); + fExperiment = experiment; + TmfExperimentFolder folder = (TmfExperimentFolder) experiment.getParent(); + fExperimentFolder = folder.getResource(); + fProject = experiment.getProject(); + setTitle(Messages.RenameExperimentDialog_DialogTitle); + setStatusLineAboveButtons(true); + } + + // ------------------------------------------------------------------------ + // Dialog + // ------------------------------------------------------------------------ + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createNewExperimentNameGroup(composite); + return composite; + } + + private void createNewExperimentNameGroup(Composite parent) { + Font font = parent.getFont(); + Composite folderGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + folderGroup.setLayout(layout); + folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Old experiment name label + Label oldExperimentLabel = new Label(folderGroup, SWT.NONE); + oldExperimentLabel.setFont(font); + oldExperimentLabel.setText(Messages.RenameExperimentDialog_ExperimentName); + + // Old experiment name field + Text oldExperimentName = new Text(folderGroup, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + oldExperimentName.setLayoutData(data); + oldExperimentName.setFont(font); + oldExperimentName.setText(fExperiment.getName()); + oldExperimentName.setEnabled(false); + + // New experiment name label + Label newExperimentLabel = new Label(folderGroup, SWT.NONE); + newExperimentLabel.setFont(font); + newExperimentLabel.setText(Messages.RenameExperimentDialog_ExperimentNewName); + + // New experiment name entry field + fNewExperimentName = new Text(folderGroup, SWT.BORDER); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + fNewExperimentName.setLayoutData(data); + fNewExperimentName.setFont(font); + fNewExperimentName.addListener(SWT.Modify, new Listener() { + @Override + public void handleEvent(Event event) { + validateNewExperimentName(); + } + }); + } + + private void validateNewExperimentName() { + + String name = fNewExperimentName.getText(); + IWorkspace workspace = fExperimentFolder.getWorkspace(); + IStatus nameStatus = workspace.validateName(name, IResource.FOLDER); + + if ("".equals(name)) { //$NON-NLS-1$ + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_EmptyNameError, null)); + return; + } + + if (nameStatus.isOK() == false) { + updateStatus(nameStatus); + return; + } + + IPath path = new Path(name); + if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) { + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_ExistingNameError, null)); + return; + } + + updateStatus(new Status(IStatus.OK, TmfUiPlugin.PLUGIN_ID, "")); //$NON-NLS-1$ + } + + // ------------------------------------------------------------------------ + // SelectionStatusDialog + // ------------------------------------------------------------------------ + + @Override + protected void computeResult() { + } + + @Override + public void create() { + super.create(); + getButton(IDialogConstants.OK_ID).setEnabled(false); + } + + @Override + protected void okPressed() { + IFolder folder = renameExperiment(fNewExperimentName.getText()); + if (folder == null) { + return; + } + setSelectionResult(new IFolder[] { folder }); + super.okPressed(); + + if (fProject != null) { + fProject.refresh(); + } + } + + private IFolder renameExperiment(String newName) { + + IPath oldPath = fExperiment.getResource().getFullPath(); + final IPath newPath = oldPath.append("../" + newName); //$NON-NLS-1$ + + WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { + @Override + public void execute(IProgressMonitor monitor) throws CoreException { + try { + monitor.beginTask("", 1000); //$NON-NLS-1$ + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + fExperiment.getResource().move(newPath, IResource.FORCE | IResource.SHALLOW, null); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } finally { + monitor.done(); + } + } + }; + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); + } catch (InterruptedException exception) { + return null; + } catch (InvocationTargetException exception) { + MessageDialog.openError(getShell(), "", NLS.bind("", exception.getTargetException().getMessage())); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } catch (RuntimeException exception) { + return null; + } + + return fExperiment.getResource(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameTraceDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameTraceDialog.java new file mode 100644 index 0000000000..18cc7450a5 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameTraceDialog.java @@ -0,0 +1,230 @@ +/******************************************************************************* + * Copyright (c) 2011 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 - Copied and adapted from NewFolderDialog + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.eclipse.ui.dialogs.SelectionStatusDialog; + +/** + * RenameTraceDialog + *

    + */ +public class RenameTraceDialog extends SelectionStatusDialog { + + // ------------------------------------------------------------------------ + // Members + // ------------------------------------------------------------------------ + + private final TmfTraceElement fTrace; + private Text fNewTraceNameText; + private String fNewTraceName; + private IContainer fTraceFolder; + private TmfProjectElement fProject; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public RenameTraceDialog(Shell shell, TmfTraceElement trace) { + super(shell); + fTrace = trace; + TmfTraceFolder folder = (TmfTraceFolder) trace.getParent(); + fTraceFolder = folder.getResource(); + fProject = trace.getProject(); + setTitle(Messages.RenameTraceDialog_DialogTitle); + setStatusLineAboveButtons(true); + } + + // ------------------------------------------------------------------------ + // Dialog + // ------------------------------------------------------------------------ + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createNewTraceNameGroup(composite); + return composite; + } + + private void createNewTraceNameGroup(Composite parent) { + Font font = parent.getFont(); + Composite folderGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + folderGroup.setLayout(layout); + folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Old trace name label + Label oldTraceLabel = new Label(folderGroup, SWT.NONE); + oldTraceLabel.setFont(font); + oldTraceLabel.setText(Messages.RenameTraceDialog_TraceName); + + // Old trace name field + Text oldTraceName = new Text(folderGroup, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + oldTraceName.setLayoutData(data); + oldTraceName.setFont(font); + oldTraceName.setText(fTrace.getName()); + oldTraceName.setEnabled(false); + + // New trace name label + Label newTaceLabel = new Label(folderGroup, SWT.NONE); + newTaceLabel.setFont(font); + newTaceLabel.setText(Messages.RenameTraceDialog_TraceNewName); + + // New trace name entry field + fNewTraceNameText = new Text(folderGroup, SWT.BORDER); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + fNewTraceNameText.setLayoutData(data); + fNewTraceNameText.setFont(font); + fNewTraceNameText.addListener(SWT.Modify, new Listener() { + @Override + public void handleEvent(Event event) { + validateNewTraceName(); + } + }); + } + + public String getNewTraceName() { + return fNewTraceName; + } + + private void validateNewTraceName() { + + fNewTraceName = fNewTraceNameText.getText(); + IWorkspace workspace = fTraceFolder.getWorkspace(); + IStatus nameStatus = workspace.validateName(fNewTraceName, IResource.FOLDER); + + if ("".equals(fNewTraceName)) { //$NON-NLS-1$ + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, + Messages.Dialog_EmptyNameError, null)); + return; + } + + if (nameStatus.isOK() == false) { + updateStatus(nameStatus); + return; + } + + IPath path = new Path(fNewTraceName); + if (fTraceFolder.getFolder(path).exists() || fTraceFolder.getFile(path).exists()) { + updateStatus(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, IStatus.ERROR, + Messages.Dialog_ExistingNameError, null)); + return; + } + + updateStatus(new Status(IStatus.OK, TmfUiPlugin.PLUGIN_ID, "")); //$NON-NLS-1$ + } + + // ------------------------------------------------------------------------ + // SelectionStatusDialog + // ------------------------------------------------------------------------ + + @Override + protected void computeResult() { + } + + @Override + public void create() { + super.create(); + getButton(IDialogConstants.OK_ID).setEnabled(false); + } + + @Override + protected void okPressed() { + IResource trace = renameTrace(fNewTraceNameText.getText()); + if (trace == null) { + return; + } + setSelectionResult(new IResource[] { trace }); + super.okPressed(); + + if (fProject != null) { + fProject.refresh(); + } + } + + private IResource renameTrace(String newName) { + + IPath oldPath = fTrace.getResource().getFullPath(); + final IPath newPath = oldPath.append("../" + newName); //$NON-NLS-1$ + + WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { + @Override + public void execute(IProgressMonitor monitor) throws CoreException { + try { + monitor.beginTask("", 1000); //$NON-NLS-1$ + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + fTrace.getResource().move(newPath, IResource.FORCE | IResource.SHALLOW, null); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } finally { + monitor.done(); + } + } + }; + + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); + } catch (InterruptedException exception) { + return null; + } catch (InvocationTargetException exception) { + MessageDialog.openError(getShell(), "", NLS.bind("", exception.getTargetException().getMessage())); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } catch (RuntimeException exception) { + return null; + } + + return fTrace.getResource(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizard.java new file mode 100644 index 0000000000..2fbf3a8c95 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizard.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.ui.IImportWizard; +import org.eclipse.ui.IWorkbench; + +/** + * SelectTracesWizard + *

    + */ +public class SelectTracesWizard extends Wizard implements IImportWizard { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private final TmfProjectElement fProject; + private final TmfExperimentElement fExperiment; + private SelectTracesWizardPage fSelectTraceWizardPage; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + public SelectTracesWizard(TmfProjectElement project, TmfExperimentElement experiment) { + fProject = project; + fExperiment = experiment; + } + + // ------------------------------------------------------------------------ + // Wizard + // ------------------------------------------------------------------------ + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + setWindowTitle(Messages.SelectTracesWizard_WindowTitle); + } + + @Override + public void addPages() { + super.addPages(); + fSelectTraceWizardPage = new SelectTracesWizardPage(fProject, fExperiment); + addPage(fSelectTraceWizardPage); + } + + @Override + public boolean performFinish() { + return fSelectTraceWizardPage.performFinish(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java new file mode 100644 index 0000000000..c8959787ec --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/SelectTracesWizardPage.java @@ -0,0 +1,217 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010, 2011 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.tmf.ui.project.wizards; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; +import org.eclipse.linuxtools.tmf.ui.project.model.TraceFolderContentProvider; +import org.eclipse.linuxtools.tmf.ui.project.model.TraceFolderLabelProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + +/** + * SelectTracesWizardPage + *

    + */ +public class SelectTracesWizardPage extends WizardPage { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private final TmfProjectElement fProject; + private final TmfExperimentElement fExperiment; + private HashMap fPreviousTraces; + private CheckboxTableViewer fCheckboxTableViewer; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + protected SelectTracesWizardPage(TmfProjectElement project, TmfExperimentElement experiment) { + super(""); //$NON-NLS-1$ + setTitle(Messages.SelectTracesWizardPage_WindowTitle); + setDescription(Messages.SelectTracesWizardPage_Description); + fProject = project; + fExperiment = experiment; + } + + // ------------------------------------------------------------------------ + // Dialog + // ------------------------------------------------------------------------ + + @Override + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + container.setLayout(new FormLayout()); + setControl(container); + + fCheckboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER); + fCheckboxTableViewer.setContentProvider(new TraceFolderContentProvider()); + fCheckboxTableViewer.setLabelProvider(new TraceFolderLabelProvider()); + + final Table table = fCheckboxTableViewer.getTable(); + final FormData formData = new FormData(); + formData.bottom = new FormAttachment(100, 0); + formData.right = new FormAttachment(100, 0); + formData.top = new FormAttachment(0, 0); + formData.left = new FormAttachment(0, 0); + table.setLayoutData(formData); + table.setHeaderVisible(true); + + final TableColumn tableColumn = new TableColumn(table, SWT.NONE); + tableColumn.setWidth(200); + tableColumn.setText(Messages.SelectTracesWizardPage_TraceColumnHeader); + + // Get the list of traces already part of the experiment + fPreviousTraces = new HashMap(); + for (ITmfProjectModelElement child : fExperiment.getChildren()) { + if (child instanceof TmfTraceElement) { + TmfTraceElement trace = (TmfTraceElement) child; + String name = trace.getResource().getName(); + fPreviousTraces.put(name, trace); + } + } + + // Populate the list of traces to choose from + Set keys = fPreviousTraces.keySet(); + TmfTraceFolder traceFolder = fProject.getTracesFolder(); + fCheckboxTableViewer.setInput(traceFolder); + + // Set the checkbox for the traces already included + int index = 0; + Object element = fCheckboxTableViewer.getElementAt(index++); + while (element != null) { + if (element instanceof TmfTraceElement) { + TmfTraceElement trace = (TmfTraceElement) element; + if (keys.contains(trace.getResource().getName())) { + fCheckboxTableViewer.setChecked(element, true); + } + } + element = fCheckboxTableViewer.getElementAt(index++); + } + } + + public boolean performFinish() { + + IFolder experiment = fExperiment.getResource(); + + // Add the selected traces to the experiment + Set keys = fPreviousTraces.keySet(); + TmfTraceElement[] traces = getSelection(); + for (TmfTraceElement trace : traces) { + String name = trace.getResource().getName(); + if (keys.contains(name)) { + fPreviousTraces.remove(name); + } else { + IResource resource = trace.getResource(); + IPath location = resource.getLocation(); + createLink(experiment, trace, resource, location); + } + } + + // Remove traces that were unchecked (thus left in fPreviousTraces) + keys = fPreviousTraces.keySet(); + for (String key : keys) { + fExperiment.removeChild(fPreviousTraces.get(key)); + IResource resource = experiment.findMember(key); + try { + resource.delete(true, null); + } catch (CoreException e) { + e.printStackTrace(); + } + } + fProject.refresh(); + + return true; + } + + /** + * Create a link to the actual trace and set the trace type + */ + private void createLink(IFolder experiment, TmfTraceElement trace, IResource resource, IPath location) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + try { + Map properties = trace.getResource().getPersistentProperties(); + String bundleName = properties.get(TmfTraceElement.TRACEBUNDLE); + String traceType = properties.get(TmfTraceElement.TRACETYPE); + String iconUrl = properties.get(TmfTraceElement.TRACEICON); + + if (resource instanceof IFolder) { + IFolder folder = experiment.getFolder(trace.getName()); + if (workspace.validateLinkLocation(folder, location).isOK()) { + folder.createLink(location, IResource.REPLACE, null); + setProperties(folder, bundleName, traceType, iconUrl); + + } else { + System.out.println("Invalid Trace Location"); //$NON-NLS-1$ + } + } else { + IFile file = experiment.getFile(trace.getName()); + if (workspace.validateLinkLocation(file, location).isOK()) { + file.createLink(location, IResource.REPLACE, null); + setProperties(file, bundleName, traceType, iconUrl); + } else { + System.out.println("Invalid Trace Location"); //$NON-NLS-1$ + } + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + + private void setProperties(IResource resource, String bundleName, String traceType, String iconUrl) throws CoreException { + resource.setPersistentProperty(TmfTraceElement.TRACEBUNDLE, bundleName); + resource.setPersistentProperty(TmfTraceElement.TRACETYPE, traceType); + resource.setPersistentProperty(TmfTraceElement.TRACEICON, iconUrl); + } + + /** + * Get the list of selected traces + */ + private TmfTraceElement[] getSelection() { + Vector traces = new Vector(); + Object[] selection = fCheckboxTableViewer.getCheckedElements(); + for (Object sel : selection) { + if (sel instanceof TmfTraceElement) + traces.add((TmfTraceElement) sel); + } + TmfTraceElement[] result = new TmfTraceElement[traces.size()]; + traces.toArray(result); + return result; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/messages.properties new file mode 100644 index 0000000000..f007fc80e2 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/messages.properties @@ -0,0 +1,57 @@ +# NewProjectWizard +NewProjectWizard_DialogHeader = Tracing Project +NewProjectWizard_DialogMessage = Create a Tracing Project + +# ImportTraceWizard +ImportTraceWizard_DialogTitle=Trace Import +ImportTraceWizard_FileSystemTitle=File system +ImportTraceWizard_ImportTrace=Import a trace from the local file system +ImportTraceWizard_DirectoryLocation=Source directory: +ImportTraceWizard_BrowseButton=B&rowse... +ImportTraceWizard_TraceType=Trace Type: +ImportTraceWizard_SelectTraceDirectoryTitle=Select trace directory +ImportTraceWizard_SelectTraceDirectoryMessage=Select directory to import trace from +ImportTraceWizard_OverwriteExistingTrace=Overwrite existing trace without warning +ImportTraceWizard_CreateLinksInWorkspace=Create lin&ks in workspace +ImportTraceWizard_TraceValidationFailed=Validation failed +ImportTraceWizard_InvalidTraceDirectory=Invalid trace directory +ImportTraceWizard_SelectTraceSourceEmpty=Source must not be empty +ImportTraceWizard_SelectTraceNoneSelected=No trace selected +ImportTraceWizard_ImportProblem=Import problem +ImportTraceWizard_CannotImportFilesUnderAVirtualFolder=Can not import trace under a virtual folder +ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder=Have to create link under a virtual folder +ImportTraceWizard_Information=Information + +# SelectTracesWizard +SelectTracesWizard_WindowTitle=Select Traces +SelectTracesWizardPage_TraceColumnHeader=Trace +SelectTracesWizardPage_WindowTitle=Select Traces +SelectTracesWizardPage_Description=Select the traces to add to the experiment + +# Common Experiment/Trace dialog errors +Dialog_EmptyNameError = No name specified +Dialog_ExistingNameError = Name already used + +# NewExperiment dialog +NewExperimentDialog_DialogTitle = New Experiment +NewExperimentDialog_ExperimentName = Experiment name: + +# RenameExperiment dialog +RenameExperimentDialog_DialogTitle = Rename Experiment +RenameExperimentDialog_ExperimentName = Old Experiment name: +RenameExperimentDialog_ExperimentNewName = New Experiment name: + +# CopyExperiment dialog +CopyExperimentDialog_DialogTitle = Copy Experiment +CopyExperimentDialog_ExperimentName = Source Experiment name: +CopyExperimentDialog_ExperimentNewName = New Experiment name: + +# RenameTrace dialog +RenameTraceDialog_DialogTitle = Rename Trace +RenameTraceDialog_TraceName = Old Trace name: +RenameTraceDialog_TraceNewName = New Trace name: + +# CopyTrace dialog +CopyTraceDialog_DialogTitle = Copy Trace +CopyTraceDialog_TraceName = Source Trace name: +CopyTraceDialog_TraceNewName = New Trace name: diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/ITmfEventsFilterListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/ITmfEventsFilterListener.java index e3a59c9d68..3626936e5f 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/ITmfEventsFilterListener.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/ITmfEventsFilterListener.java @@ -17,8 +17,8 @@ import org.eclipse.linuxtools.tmf.trace.ITmfTrace; public interface ITmfEventsFilterListener { - public void filterApplied(ITmfFilter filter, ITmfTrace trace); + public void filterApplied(ITmfFilter filter, ITmfTrace trace); - public void searchApplied(ITmfFilter filter, ITmfTrace trace); + public void searchApplied(ITmfFilter filter, ITmfTrace trace); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java index caf7bca91c..02de0e61ad 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java @@ -56,7 +56,7 @@ import org.eclipse.linuxtools.tmf.filter.model.TmfFilterNode; import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType; import org.eclipse.linuxtools.tmf.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.request.TmfEventRequest; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal; +import org.eclipse.linuxtools.tmf.signal.TmfExperimentRangeUpdatedSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal; @@ -105,37 +105,41 @@ import org.eclipse.ui.themes.ColorUtil; /** * TmfEventsTable */ -public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorSettingsListener, ITmfEventsFilterProvider { - - private static final Image BOOKMARK_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/bookmark_obj.gif"); //$NON-NLS-1$ - private static final Image SEARCH_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/search.gif"); //$NON-NLS-1$ - private static final Image SEARCH_MATCH_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/search_match.gif"); //$NON-NLS-1$ - private static final Image SEARCH_MATCH_BOOKMARK_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/search_match_bookmark.gif"); //$NON-NLS-1$ - private static final Image FILTER_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/filter_items.gif"); //$NON-NLS-1$ - private static final Image STOP_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/stop.gif"); //$NON-NLS-1$ - private static final String SEARCH_HINT = Messages.TmfEventsTable_SearchHint; - private static final String FILTER_HINT = Messages.TmfEventsTable_FilterHint; - - public interface Key { - String SEARCH_TXT = "$srch_txt"; //$NON-NLS-1$ - String SEARCH_OBJ = "$srch_obj"; //$NON-NLS-1$ - String FILTER_TXT = "$fltr_txt"; //$NON-NLS-1$ - String FILTER_OBJ = "$fltr_obj"; //$NON-NLS-1$ - String TIMESTAMP = "$time"; //$NON-NLS-1$ - String RANK = "$rank"; //$NON-NLS-1$ - String FIELD_ID = "$field_id"; //$NON-NLS-1$ - } - - public static enum HeaderState { - SEARCH, - FILTER - } - - interface Direction { - int FORWARD = +1; - int BACKWARD = -1; - } - +public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorSettingsListener, + ITmfEventsFilterProvider { + + private static final Image BOOKMARK_IMAGE = TmfUiPlugin.getDefault().getImageFromPath( + "icons/elcl16/bookmark_obj.gif"); //$NON-NLS-1$ + private static final Image SEARCH_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/search.gif"); //$NON-NLS-1$ + private static final Image SEARCH_MATCH_IMAGE = TmfUiPlugin.getDefault().getImageFromPath( + "icons/elcl16/search_match.gif"); //$NON-NLS-1$ + private static final Image SEARCH_MATCH_BOOKMARK_IMAGE = TmfUiPlugin.getDefault().getImageFromPath( + "icons/elcl16/search_match_bookmark.gif"); //$NON-NLS-1$ + private static final Image FILTER_IMAGE = TmfUiPlugin.getDefault() + .getImageFromPath("icons/elcl16/filter_items.gif"); //$NON-NLS-1$ + private static final Image STOP_IMAGE = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/stop.gif"); //$NON-NLS-1$ + private static final String SEARCH_HINT = Messages.TmfEventsTable_SearchHint; + private static final String FILTER_HINT = Messages.TmfEventsTable_FilterHint; + + public interface Key { + String SEARCH_TXT = "$srch_txt"; //$NON-NLS-1$ + String SEARCH_OBJ = "$srch_obj"; //$NON-NLS-1$ + String FILTER_TXT = "$fltr_txt"; //$NON-NLS-1$ + String FILTER_OBJ = "$fltr_obj"; //$NON-NLS-1$ + String TIMESTAMP = "$time"; //$NON-NLS-1$ + String RANK = "$rank"; //$NON-NLS-1$ + String FIELD_ID = "$field_id"; //$NON-NLS-1$ + } + + public static enum HeaderState { + SEARCH, FILTER + } + + interface Direction { + int FORWARD = +1; + int BACKWARD = -1; + } + // ------------------------------------------------------------------------ // Table data // ------------------------------------------------------------------------ @@ -148,7 +152,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS protected boolean fPackDone = false; protected HeaderState fHeaderState = HeaderState.SEARCH; protected long fSelectedRank = 0; - + // Filter data protected long fFilterMatchCount; protected long fFilterCheckCount; @@ -157,12 +161,12 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS protected SearchThread fSearchThread; protected final Object fSearchSyncObj = new Object(); protected ArrayList fEventsFilterListeners = new ArrayList(); - + // Bookmark map protected Map fBookmarksMap = new HashMap(); protected IResource fBookmarksResource; protected long fPendingGotoRank = -1; - + // SWT resources protected LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources()); protected Color fGrayColor; @@ -170,21 +174,13 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS protected Font fBoldFont; // Table column names - static private final String[] COLUMN_NAMES = new String[] { - Messages.TmfEventsTable_TimestampColumnHeader, - Messages.TmfEventsTable_SourceColumnHeader, - Messages.TmfEventsTable_TypeColumnHeader, - Messages.TmfEventsTable_ReferenceColumnHeader, - Messages.TmfEventsTable_ContentColumnHeader - }; - - static private ColumnData[] COLUMN_DATA = new ColumnData[] { - new ColumnData(COLUMN_NAMES[0], 100, SWT.LEFT), - new ColumnData(COLUMN_NAMES[1], 100, SWT.LEFT), - new ColumnData(COLUMN_NAMES[2], 100, SWT.LEFT), - new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT), - new ColumnData(COLUMN_NAMES[4], 100, SWT.LEFT) - }; + static private final String[] COLUMN_NAMES = new String[] { Messages.TmfEventsTable_TimestampColumnHeader, + Messages.TmfEventsTable_SourceColumnHeader, Messages.TmfEventsTable_TypeColumnHeader, + Messages.TmfEventsTable_ReferenceColumnHeader, Messages.TmfEventsTable_ContentColumnHeader }; + + static private ColumnData[] COLUMN_DATA = new ColumnData[] { new ColumnData(COLUMN_NAMES[0], 100, SWT.LEFT), + new ColumnData(COLUMN_NAMES[1], 100, SWT.LEFT), new ColumnData(COLUMN_NAMES[2], 100, SWT.LEFT), + new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT), new ColumnData(COLUMN_NAMES[4], 100, SWT.LEFT) }; // Event cache private final TmfEventsCache fCache; @@ -193,7 +189,6 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS private boolean fCacheUpdateCompleted = false; private Object fCacheUpdateSyncObj = new Object(); - private boolean fDisposeOnClose; // ------------------------------------------------------------------------ @@ -201,12 +196,12 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS // ------------------------------------------------------------------------ public TmfEventsTable(Composite parent, int cacheSize) { - this(parent, cacheSize, COLUMN_DATA); + this(parent, cacheSize, COLUMN_DATA); } public TmfEventsTable(Composite parent, int cacheSize, ColumnData[] columnData) { super("TmfEventsTable"); //$NON-NLS-1$ - + fComposite = new Composite(parent, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.marginHeight = 0; @@ -216,7 +211,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS fSashForm = new SashForm(fComposite, SWT.HORIZONTAL); fSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - + // Create a virtual table final int style = SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION; fTable = new TmfVirtualTable(fSashForm, style); @@ -231,110 +226,110 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS // Set the columns setColumnHeaders(columnData); - + // Set the default column field ids if this is not a subclass - if (Arrays.equals(columnData, COLUMN_DATA)) { - fTable.getColumns()[0].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TIMESTAMP); - fTable.getColumns()[1].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_SOURCE); - fTable.getColumns()[2].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TYPE); - fTable.getColumns()[3].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_REFERENCE); - fTable.getColumns()[4].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_CONTENT); - } + if (Arrays.equals(columnData, COLUMN_DATA)) { + fTable.getColumns()[0].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TIMESTAMP); + fTable.getColumns()[1].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_SOURCE); + fTable.getColumns()[2].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TYPE); + fTable.getColumns()[3].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_REFERENCE); + fTable.getColumns()[4].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_CONTENT); + } // Set the frozen row for header row fTable.setFrozenRowCount(1); // Create the header row cell editor createHeaderEditor(); - + // Handle the table item selection fTable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - TableItem[] selection = fTable.getSelection(); - if (selection.length > 0) { - TableItem selectedTableItem = selection[0]; - if (selectedTableItem != null) { - if (selectedTableItem.getData(Key.RANK) instanceof Long) { - fSelectedRank = (Long) selectedTableItem.getData(Key.RANK); - fRawViewer.selectAndReveal((Long) selectedTableItem.getData(Key.RANK)); - } - if (selectedTableItem.getData(Key.TIMESTAMP) instanceof TmfTimestamp) { - TmfTimestamp ts = (TmfTimestamp) selectedTableItem.getData(Key.TIMESTAMP); - broadcast(new TmfTimeSynchSignal(fTable, ts)); - } - } - } + TableItem[] selection = fTable.getSelection(); + if (selection.length > 0) { + TableItem selectedTableItem = selection[0]; + if (selectedTableItem != null) { + if (selectedTableItem.getData(Key.RANK) instanceof Long) { + fSelectedRank = (Long) selectedTableItem.getData(Key.RANK); + fRawViewer.selectAndReveal((Long) selectedTableItem.getData(Key.RANK)); + } + if (selectedTableItem.getData(Key.TIMESTAMP) instanceof TmfTimestamp) { + TmfTimestamp ts = (TmfTimestamp) selectedTableItem.getData(Key.TIMESTAMP); + broadcast(new TmfTimeSynchSignal(fTable, ts)); + } + } + } } }); cacheSize = Math.max(cacheSize, Display.getDefault().getBounds().height / fTable.getItemHeight()); fCache = new TmfEventsCache(cacheSize, this); - // Handle the table item requests + // Handle the table item requests fTable.addListener(SWT.SetData, new Listener() { @Override - public void handleEvent(Event event) { + public void handleEvent(Event event) { final TableItem item = (TableItem) event.item; int index = event.index - 1; // -1 for the header row if (event.index == 0) { - setHeaderRowItemData(item); + setHeaderRowItemData(item); return; } if (fTable.getData(Key.FILTER_OBJ) != null) { - if (event.index == 1 || event.index == fTable.getItemCount() - 1) { - setFilterStatusRowItemData(item); - return; - } - index = index - 1; // -1 for top filter status row + if (event.index == 1 || event.index == fTable.getItemCount() - 1) { + setFilterStatusRowItemData(item); + return; + } + index = index - 1; // -1 for top filter status row } - + CachedEvent cachedEvent = fCache.getEvent(index); if (cachedEvent != null) { setItemData(item, cachedEvent.event, cachedEvent.rank); return; } - + // Else, fill the cache asynchronously (and off the UI thread) event.doit = false; } }); fTable.addMouseListener(new MouseAdapter() { - @Override - public void mouseDoubleClick(MouseEvent event) { - if (event.button != 1) { - return; - } - // Identify the selected row - Point point = new Point(event.x, event.y); - TableItem item = fTable.getItem(point); - if (item != null) { - Rectangle imageBounds = item.getImageBounds(0); - imageBounds.width = BOOKMARK_IMAGE.getBounds().width; - if (imageBounds.contains(point)) { - Long rank = (Long) item.getData(Key.RANK); - if (rank != null) { - toggleBookmark(rank); - } - } - } - } + @Override + public void mouseDoubleClick(MouseEvent event) { + if (event.button != 1) { + return; + } + // Identify the selected row + Point point = new Point(event.x, event.y); + TableItem item = fTable.getItem(point); + if (item != null) { + Rectangle imageBounds = item.getImageBounds(0); + imageBounds.width = BOOKMARK_IMAGE.getBounds().width; + if (imageBounds.contains(point)) { + Long rank = (Long) item.getData(Key.RANK); + if (rank != null) { + toggleBookmark(rank); + } + } + } + } }); - + // Create resources createResources(); ColorSettingsManager.addColorSettingsListener(this); - + fTable.setItemCount(1); // +1 for header row - + fRawViewer = new TmfRawEventViewer(fSashForm, SWT.H_SCROLL | SWT.V_SCROLL); - + fRawViewer.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -342,12 +337,12 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS long rank = (Long) e.data; int index = (int) rank; if (fTable.getData(Key.FILTER_OBJ) != null) { - index = fCache.getFilteredEventIndex(rank) + 1; // +1 for top filter status row + index = fCache.getFilteredEventIndex(rank) + 1; // +1 for top filter status row } fTable.setSelection(index + 1); // +1 for header row fSelectedRank = rank; } else if (e.data instanceof ITmfLocation) { - // DOES NOT WORK: rank undefined in context from seekLocation() + // DOES NOT WORK: rank undefined in context from seekLocation() // ITmfLocation location = (ITmfLocation) e.data; // TmfContext context = fTrace.seekLocation(location); // fTable.setSelection((int) context.getRank()); @@ -359,13 +354,13 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS if (selection != null && selection.length > 0) { TmfTimestamp ts = (TmfTimestamp) fTable.getSelection()[0].getData(Key.TIMESTAMP); if (ts != null) { - broadcast(new TmfTimeSynchSignal(fTable, ts)); + broadcast(new TmfTimeSynchSignal(fTable, ts)); } } } }); - fSashForm.setWeights(new int[] {1, 1}); + fSashForm.setWeights(new int[] { 1, 1 }); fRawViewer.setVisible(false); createPopupMenu(); @@ -379,7 +374,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS fSashForm.layout(); } }; - + final IAction hideTableAction = new Action(Messages.TmfEventsTable_HideTableActionText) { @Override public void run() { @@ -387,7 +382,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS fSashForm.layout(); } }; - + final IAction showRawAction = new Action(Messages.TmfEventsTable_ShowRawActionText) { @Override public void run() { @@ -395,11 +390,11 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS fSashForm.layout(); int index = fTable.getSelectionIndex(); if (index >= +1) { // +1 for header row - fRawViewer.selectAndReveal(index - 1); + fRawViewer.selectAndReveal(index - 1); } } }; - + final IAction hideRawAction = new Action(Messages.TmfEventsTable_HideRawActionText) { @Override public void run() { @@ -411,38 +406,39 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS final IAction showSearchBarAction = new Action(Messages.TmfEventsTable_ShowSearchBarActionText) { @Override public void run() { - fHeaderState = HeaderState.SEARCH; - fTable.refresh(); + fHeaderState = HeaderState.SEARCH; + fTable.refresh(); } }; final IAction showFilterBarAction = new Action(Messages.TmfEventsTable_ShowFilterBarActionText) { @Override public void run() { - fHeaderState = HeaderState.FILTER; - fTable.refresh(); + fHeaderState = HeaderState.FILTER; + fTable.refresh(); } }; final IAction clearFiltersAction = new Action(Messages.TmfEventsTable_ClearFiltersActionText) { @Override public void run() { - stopFilterThread(); - stopSearchThread(); - clearFilters(); + stopFilterThread(); + stopSearchThread(); + clearFilters(); } }; class ToggleBookmarkAction extends Action { - long fRank; - public ToggleBookmarkAction(String text, long rank) { - super(text); - fRank = rank; - } - - @Override + long fRank; + + public ToggleBookmarkAction(String text, long rank) { + super(text); + fRank = rank; + } + + @Override public void run() { - toggleBookmark(fRank); + toggleBookmark(fRank); } } @@ -451,34 +447,36 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS tablePopupMenu.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { - if (fTable.getSelectionIndex() == 0) { - // Right-click on header row - if (fHeaderState == HeaderState.FILTER) { - tablePopupMenu.add(showSearchBarAction); - } else { + if (fTable.getSelectionIndex() == 0) { + // Right-click on header row + if (fHeaderState == HeaderState.FILTER) { + tablePopupMenu.add(showSearchBarAction); + } else { tablePopupMenu.add(showFilterBarAction); - } - return; - } - Point point = fTable.toControl(Display.getDefault().getCursorLocation()); - TableItem item = fTable.getItem(point); - if (item != null) { - Rectangle imageBounds = item.getImageBounds(0); - imageBounds.width = BOOKMARK_IMAGE.getBounds().width; - if (imageBounds.contains(point)) { - // Right-click on left margin - Long rank = (Long) item.getData(Key.RANK); - if (rank != null && fBookmarksResource != null) { - if (fBookmarksMap.containsKey(rank)) { - tablePopupMenu.add(new ToggleBookmarkAction(Messages.TmfEventsTable_RemoveBookmarkActionText, rank)); - } else { - tablePopupMenu.add(new ToggleBookmarkAction(Messages.TmfEventsTable_AddBookmarkActionText, rank)); - } - } - return; - } - } - // Right-click on table + } + return; + } + Point point = fTable.toControl(Display.getDefault().getCursorLocation()); + TableItem item = fTable.getItem(point); + if (item != null) { + Rectangle imageBounds = item.getImageBounds(0); + imageBounds.width = BOOKMARK_IMAGE.getBounds().width; + if (imageBounds.contains(point)) { + // Right-click on left margin + Long rank = (Long) item.getData(Key.RANK); + if (rank != null && fBookmarksResource != null) { + if (fBookmarksMap.containsKey(rank)) { + tablePopupMenu.add(new ToggleBookmarkAction( + Messages.TmfEventsTable_RemoveBookmarkActionText, rank)); + } else { + tablePopupMenu.add(new ToggleBookmarkAction( + Messages.TmfEventsTable_AddBookmarkActionText, rank)); + } + } + return; + } + } + // Right-click on table if (fTable.isVisible() && fRawViewer.isVisible()) { tablePopupMenu.add(hideTableAction); tablePopupMenu.add(hideRawAction); @@ -493,67 +491,69 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS if (savedFilters.length > 0) { MenuManager subMenu = new MenuManager(Messages.TmfEventsTable_ApplyPresetFilterMenuName); for (ITmfFilterTreeNode node : savedFilters) { - if (node instanceof TmfFilterNode) { - final TmfFilterNode filter = (TmfFilterNode) node; - subMenu.add(new Action(filter.getFilterName()) { - @Override - public void run() { - stopFilterThread(); - fFilterMatchCount = 0; - fFilterCheckCount = 0; - fCache.applyFilter(filter); - fTable.clearAll(); - fTable.setData(Key.FILTER_OBJ, filter); - fTable.setItemCount(3); // +1 for header row, +2 for top and bottom filter status rows - startFilterThread(); - fireFilterApplied(filter); - }}); - } + if (node instanceof TmfFilterNode) { + final TmfFilterNode filter = (TmfFilterNode) node; + subMenu.add(new Action(filter.getFilterName()) { + @Override + public void run() { + stopFilterThread(); + fFilterMatchCount = 0; + fFilterCheckCount = 0; + fCache.applyFilter(filter); + fTable.clearAll(); + fTable.setData(Key.FILTER_OBJ, filter); + fTable.setItemCount(3); // +1 for header row, +2 for top and bottom filter status + // rows + startFilterThread(); + fireFilterApplied(filter); + } + }); + } } tablePopupMenu.add(subMenu); } appendToTablePopupMenu(tablePopupMenu, item); } }); - + final MenuManager rawViewerPopupMenu = new MenuManager(); rawViewerPopupMenu.setRemoveAllWhenShown(true); rawViewerPopupMenu.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { if (fTable.isVisible() && fRawViewer.isVisible()) { - rawViewerPopupMenu.add(hideTableAction); - rawViewerPopupMenu.add(hideRawAction); + rawViewerPopupMenu.add(hideTableAction); + rawViewerPopupMenu.add(hideRawAction); } else if (!fTable.isVisible()) { - rawViewerPopupMenu.add(showTableAction); + rawViewerPopupMenu.add(showTableAction); } else if (!fRawViewer.isVisible()) { - rawViewerPopupMenu.add(showRawAction); + rawViewerPopupMenu.add(showRawAction); } appendToRawPopupMenu(tablePopupMenu); } }); - + Menu menu = tablePopupMenu.createContextMenu(fTable); fTable.setMenu(menu); - + menu = rawViewerPopupMenu.createContextMenu(fRawViewer); fRawViewer.setMenu(menu); } protected void appendToTablePopupMenu(MenuManager tablePopupMenu, TableItem selectedItem) { - // override to append more actions + // override to append more actions } - + protected void appendToRawPopupMenu(MenuManager rawViewerPopupMenu) { - // override to append more actions + // override to append more actions } - + @Override - public void dispose() { - stopSearchThread(); - stopFilterThread(); + public void dispose() { + stopSearchThread(); + stopFilterThread(); ColorSettingsManager.removeColorSettingsListener(this); - fComposite.dispose(); + fComposite.dispose(); if (fTrace != null && fDisposeOnClose) { fTrace.dispose(); } @@ -562,63 +562,63 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS } public void setLayoutData(Object layoutData) { - fComposite.setLayoutData(layoutData); + fComposite.setLayoutData(layoutData); } - + public TmfVirtualTable getTable() { return fTable; } - + /** * @param table * - * FIXME: Add support for column selection + * FIXME: Add support for column selection */ protected void setColumnHeaders(ColumnData[] columnData) { - fTable.setColumnHeaders(columnData); + fTable.setColumnHeaders(columnData); } protected void setItemData(TableItem item, TmfEvent event, long rank) { - item.setText(extractItemFields(event)); - item.setData(Key.TIMESTAMP, new TmfTimestamp(event.getTimestamp())); - item.setData(Key.RANK, rank); - - boolean bookmark = false; - if (fBookmarksMap.containsKey(rank)) { - bookmark = true; - } - - boolean searchMatch = false; - boolean searchNoMatch = false; - ITmfFilter searchFilter = (ITmfFilter) fTable.getData(Key.SEARCH_OBJ); - if (searchFilter != null) { - if (searchFilter.matches(event)) { - searchMatch = true; - } else { - searchNoMatch = true; - } - } - - ColorSetting colorSetting = ColorSettingsManager.getColorSetting(event); - if (searchNoMatch) { - item.setForeground(colorSetting.getDimmedForegroundColor()); - item.setBackground(colorSetting.getDimmedBackgroundColor()); - } else { - item.setForeground(colorSetting.getForegroundColor()); - item.setBackground(colorSetting.getBackgroundColor()); - } - - if (searchMatch) { - if (bookmark) { - item.setImage(SEARCH_MATCH_BOOKMARK_IMAGE); - } else { - item.setImage(SEARCH_MATCH_IMAGE); - } - } else if (bookmark) { - item.setImage(BOOKMARK_IMAGE); - } else { - item.setImage((Image) null); - } + item.setText(extractItemFields(event)); + item.setData(Key.TIMESTAMP, new TmfTimestamp(event.getTimestamp())); + item.setData(Key.RANK, rank); + + boolean bookmark = false; + if (fBookmarksMap.containsKey(rank)) { + bookmark = true; + } + + boolean searchMatch = false; + boolean searchNoMatch = false; + ITmfFilter searchFilter = (ITmfFilter) fTable.getData(Key.SEARCH_OBJ); + if (searchFilter != null) { + if (searchFilter.matches(event)) { + searchMatch = true; + } else { + searchNoMatch = true; + } + } + + ColorSetting colorSetting = ColorSettingsManager.getColorSetting(event); + if (searchNoMatch) { + item.setForeground(colorSetting.getDimmedForegroundColor()); + item.setBackground(colorSetting.getDimmedBackgroundColor()); + } else { + item.setForeground(colorSetting.getForegroundColor()); + item.setBackground(colorSetting.getBackgroundColor()); + } + + if (searchMatch) { + if (bookmark) { + item.setImage(SEARCH_MATCH_BOOKMARK_IMAGE); + } else { + item.setImage(SEARCH_MATCH_IMAGE); + } + } else if (bookmark) { + item.setImage(BOOKMARK_IMAGE); + } else { + item.setImage((Image) null); + } } protected void setHeaderRowItemData(TableItem item) { @@ -649,612 +649,628 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS } } } - + protected void setFilterStatusRowItemData(TableItem item) { - for (int i = 0; i < fTable.getColumns().length; i++) { - if (i == 0) { - if (fTrace == null || fFilterCheckCount == fTrace.getNbEvents()) { - item.setImage(FILTER_IMAGE); - } else { - item.setImage(STOP_IMAGE); - } - item.setText(0, fFilterMatchCount + "/" + fFilterCheckCount); //$NON-NLS-1$ - } else { - item.setText(i, ""); //$NON-NLS-1$ - } - } - item.setData(Key.TIMESTAMP, null); - item.setData(Key.RANK, null); - item.setForeground(null); - item.setBackground(null); + for (int i = 0; i < fTable.getColumns().length; i++) { + if (i == 0) { + if (fTrace == null || fFilterCheckCount == fTrace.getNbEvents()) { + item.setImage(FILTER_IMAGE); + } else { + item.setImage(STOP_IMAGE); + } + item.setText(0, fFilterMatchCount + "/" + fFilterCheckCount); //$NON-NLS-1$ + } else { + item.setText(i, ""); //$NON-NLS-1$ + } + } + item.setData(Key.TIMESTAMP, null); + item.setData(Key.RANK, null); + item.setForeground(null); + item.setBackground(null); } - + protected void createHeaderEditor() { - final TableEditor tableEditor = fTable.createTableEditor(); - tableEditor.horizontalAlignment = SWT.LEFT; - tableEditor.verticalAlignment = SWT.CENTER; - tableEditor.grabHorizontal = true; - tableEditor.minimumWidth = 50; + final TableEditor tableEditor = fTable.createTableEditor(); + tableEditor.horizontalAlignment = SWT.LEFT; + tableEditor.verticalAlignment = SWT.CENTER; + tableEditor.grabHorizontal = true; + tableEditor.minimumWidth = 50; // Handle the header row selection fTable.addMouseListener(new MouseAdapter() { - int columnIndex; - TableColumn column; - TableItem item; - - @Override - public void mouseDown(MouseEvent event) { - if (event.button != 1) { - return; - } - // Identify the selected row - Point point = new Point(event.x, event.y); - item = fTable.getItem(point); - - // Header row selected - if (item != null && fTable.indexOf(item) == 0) { - - // Icon selected - if (item.getImageBounds(0).contains(point)) { - if (fHeaderState == HeaderState.SEARCH) { - fHeaderState = HeaderState.FILTER; - } else if (fHeaderState == HeaderState.FILTER) { - fHeaderState = HeaderState.SEARCH; - } - fTable.refresh(); - return; - } - - // Identify the selected column - columnIndex = -1; - for (int i = 0; i < fTable.getColumns().length; i++) { - Rectangle rect = item.getBounds(i); - if (rect.contains(point)) { - columnIndex = i; - break; - } - } - - if (columnIndex == -1) { - return; - } - - column = fTable.getColumns()[columnIndex]; - - String txtKey = null; - if (fHeaderState == HeaderState.SEARCH) { - txtKey = Key.SEARCH_TXT; - } else if (fHeaderState == HeaderState.FILTER) { - txtKey = Key.FILTER_TXT; - } - - // The control that will be the editor must be a child of the Table - final Text newEditor = (Text) fTable.createTableEditorControl(Text.class); - String headerString = (String) column.getData(txtKey); - if (headerString != null) { - newEditor.setText(headerString); - } - newEditor.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - boolean changed = updateHeader(newEditor.getText()); - if (changed) { - applyHeader(); - } - } - }); - newEditor.addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if (e.character == SWT.CR) { - updateHeader(newEditor.getText()); - applyHeader(); - } else if (e.character == SWT.ESC) { - tableEditor.getEditor().dispose(); - } - } - }); - newEditor.selectAll(); - newEditor.setFocus(); - tableEditor.setEditor(newEditor, item, columnIndex); - } - } - - /* - * returns true is value was changed - */ - private boolean updateHeader(String text) { - String objKey = null; - String txtKey = null; - if (fHeaderState == HeaderState.SEARCH) { - objKey = Key.SEARCH_OBJ; - txtKey = Key.SEARCH_TXT; - } else if (fHeaderState == HeaderState.FILTER) { - objKey = Key.FILTER_OBJ; - txtKey = Key.FILTER_TXT; - } - if (text.trim().length() > 0) { - try { - String regex = TmfFilterMatchesNode.regexFix(text); - Pattern.compile(regex); - if (regex.equals(column.getData(txtKey))) { - tableEditor.getEditor().dispose(); - return false; - } - TmfFilterMatchesNode filter = new TmfFilterMatchesNode(null); - String fieldId = (String) column.getData(Key.FIELD_ID); - if (fieldId == null) { - fieldId = column.getText(); - } - filter.setField(fieldId); - filter.setRegex(regex); - column.setData(objKey, filter); - column.setData(txtKey, regex); - } catch (PatternSyntaxException ex) { - tableEditor.getEditor().dispose(); - MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ex.getDescription(), ex.getMessage()); - return false; - } - } else { - if (column.getData(txtKey) == null) { - tableEditor.getEditor().dispose(); - return false; - } - column.setData(objKey, null); - column.setData(txtKey, null); - } - return true; - } - - private void applyHeader() { - stopSearchThread(); - if (fHeaderState == HeaderState.SEARCH) { - final TmfFilterAndNode filter = new TmfFilterAndNode(null); - for (TableColumn column : fTable.getColumns()) { - Object filterObj = column.getData(Key.SEARCH_OBJ); - if (filterObj instanceof ITmfFilterTreeNode) { - filter.addChild((ITmfFilterTreeNode) filterObj); - } - } - if (filter.getChildrenCount() > 0) { - fTable.setData(Key.SEARCH_OBJ, filter); - fTable.refresh(); - searchNext(); - fireSearchApplied(filter); - } else { - fTable.setData(Key.SEARCH_OBJ, null); - fTable.refresh(); - fireSearchApplied(null); - } - } else if (fHeaderState == HeaderState.FILTER) { - stopFilterThread(); - fFilterMatchCount = 0; - fFilterCheckCount = 0; - TmfFilterAndNode filter = new TmfFilterAndNode(null); - for (TableColumn column : fTable.getColumns()) { - Object filterObj = column.getData(Key.FILTER_OBJ); - if (filterObj instanceof ITmfFilterTreeNode) { - filter.addChild((ITmfFilterTreeNode) filterObj); - } - } - if (filter.getChildrenCount() > 0) { - fCache.applyFilter(filter); - fTable.clearAll(); - fTable.setData(Key.FILTER_OBJ, filter); - fTable.setItemCount(3); // +1 for header row, +2 for top and bottom filter status rows - startFilterThread(); - fireFilterApplied(filter); - } else { - fCache.clearFilter(); - stopFilterThread(); - fTable.clearAll(); - fTable.setData(Key.FILTER_OBJ, null); - if (fTrace != null) { - fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row - } else { - fTable.setItemCount(1); // +1 for header row - } - fireFilterApplied(null); - } - } - - tableEditor.getEditor().dispose(); - } + int columnIndex; + TableColumn column; + TableItem item; + + @Override + public void mouseDown(MouseEvent event) { + if (event.button != 1) { + return; + } + // Identify the selected row + Point point = new Point(event.x, event.y); + item = fTable.getItem(point); + + // Header row selected + if (item != null && fTable.indexOf(item) == 0) { + + // Icon selected + if (item.getImageBounds(0).contains(point)) { + if (fHeaderState == HeaderState.SEARCH) { + fHeaderState = HeaderState.FILTER; + } else if (fHeaderState == HeaderState.FILTER) { + fHeaderState = HeaderState.SEARCH; + } + fTable.refresh(); + return; + } + + // Identify the selected column + columnIndex = -1; + for (int i = 0; i < fTable.getColumns().length; i++) { + Rectangle rect = item.getBounds(i); + if (rect.contains(point)) { + columnIndex = i; + break; + } + } + + if (columnIndex == -1) { + return; + } + + column = fTable.getColumns()[columnIndex]; + + String txtKey = null; + if (fHeaderState == HeaderState.SEARCH) { + txtKey = Key.SEARCH_TXT; + } else if (fHeaderState == HeaderState.FILTER) { + txtKey = Key.FILTER_TXT; + } + + // The control that will be the editor must be a child of the Table + final Text newEditor = (Text) fTable.createTableEditorControl(Text.class); + String headerString = (String) column.getData(txtKey); + if (headerString != null) { + newEditor.setText(headerString); + } + newEditor.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + boolean changed = updateHeader(newEditor.getText()); + if (changed) { + applyHeader(); + } + } + }); + newEditor.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.character == SWT.CR) { + updateHeader(newEditor.getText()); + applyHeader(); + } else if (e.character == SWT.ESC) { + tableEditor.getEditor().dispose(); + } + } + }); + newEditor.selectAll(); + newEditor.setFocus(); + tableEditor.setEditor(newEditor, item, columnIndex); + } + } + + /* + * returns true is value was changed + */ + private boolean updateHeader(String text) { + String objKey = null; + String txtKey = null; + if (fHeaderState == HeaderState.SEARCH) { + objKey = Key.SEARCH_OBJ; + txtKey = Key.SEARCH_TXT; + } else if (fHeaderState == HeaderState.FILTER) { + objKey = Key.FILTER_OBJ; + txtKey = Key.FILTER_TXT; + } + if (text.trim().length() > 0) { + try { + String regex = TmfFilterMatchesNode.regexFix(text); + Pattern.compile(regex); + if (regex.equals(column.getData(txtKey))) { + tableEditor.getEditor().dispose(); + return false; + } + TmfFilterMatchesNode filter = new TmfFilterMatchesNode(null); + String fieldId = (String) column.getData(Key.FIELD_ID); + if (fieldId == null) { + fieldId = column.getText(); + } + filter.setField(fieldId); + filter.setRegex(regex); + column.setData(objKey, filter); + column.setData(txtKey, regex); + } catch (PatternSyntaxException ex) { + tableEditor.getEditor().dispose(); + MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + ex.getDescription(), ex.getMessage()); + return false; + } + } else { + if (column.getData(txtKey) == null) { + tableEditor.getEditor().dispose(); + return false; + } + column.setData(objKey, null); + column.setData(txtKey, null); + } + return true; + } + + private void applyHeader() { + stopSearchThread(); + if (fHeaderState == HeaderState.SEARCH) { + final TmfFilterAndNode filter = new TmfFilterAndNode(null); + for (TableColumn column : fTable.getColumns()) { + Object filterObj = column.getData(Key.SEARCH_OBJ); + if (filterObj instanceof ITmfFilterTreeNode) { + filter.addChild((ITmfFilterTreeNode) filterObj); + } + } + if (filter.getChildrenCount() > 0) { + fTable.setData(Key.SEARCH_OBJ, filter); + fTable.refresh(); + searchNext(); + fireSearchApplied(filter); + } else { + fTable.setData(Key.SEARCH_OBJ, null); + fTable.refresh(); + fireSearchApplied(null); + } + } else if (fHeaderState == HeaderState.FILTER) { + stopFilterThread(); + fFilterMatchCount = 0; + fFilterCheckCount = 0; + TmfFilterAndNode filter = new TmfFilterAndNode(null); + for (TableColumn column : fTable.getColumns()) { + Object filterObj = column.getData(Key.FILTER_OBJ); + if (filterObj instanceof ITmfFilterTreeNode) { + filter.addChild((ITmfFilterTreeNode) filterObj); + } + } + if (filter.getChildrenCount() > 0) { + fCache.applyFilter(filter); + fTable.clearAll(); + fTable.setData(Key.FILTER_OBJ, filter); + fTable.setItemCount(3); // +1 for header row, +2 for top and bottom filter status rows + startFilterThread(); + fireFilterApplied(filter); + } else { + fCache.clearFilter(); + stopFilterThread(); + fTable.clearAll(); + fTable.setData(Key.FILTER_OBJ, null); + if (fTrace != null) { + fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row + } else { + fTable.setItemCount(1); // +1 for header row + } + fireFilterApplied(null); + } + } + + tableEditor.getEditor().dispose(); + } }); - + fTable.addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - e.doit = false; - if (e.character == SWT.ESC) { - stopFilterThread(); - stopSearchThread(); - fTable.refresh(); - } else if (e.character == SWT.DEL) { - stopFilterThread(); - stopSearchThread(); - if (fHeaderState == HeaderState.SEARCH) { - for (TableColumn column : fTable.getColumns()) { - column.setData(Key.SEARCH_OBJ, null); - column.setData(Key.SEARCH_TXT, null); - } - fTable.setData(Key.SEARCH_OBJ, null); - fTable.refresh(); - fireSearchApplied(null); - } else if (fHeaderState == HeaderState.FILTER) { - clearFilters(); - } - } else if (e.character == SWT.CR) { - if ((e.stateMask & SWT.SHIFT) == 0) { - searchNext(); - } else { - searchPrevious(); - } - } - } + @Override + public void keyPressed(KeyEvent e) { + e.doit = false; + if (e.character == SWT.ESC) { + stopFilterThread(); + stopSearchThread(); + fTable.refresh(); + } else if (e.character == SWT.DEL) { + stopFilterThread(); + stopSearchThread(); + if (fHeaderState == HeaderState.SEARCH) { + for (TableColumn column : fTable.getColumns()) { + column.setData(Key.SEARCH_OBJ, null); + column.setData(Key.SEARCH_TXT, null); + } + fTable.setData(Key.SEARCH_OBJ, null); + fTable.refresh(); + fireSearchApplied(null); + } else if (fHeaderState == HeaderState.FILTER) { + clearFilters(); + } + } else if (e.character == SWT.CR) { + if ((e.stateMask & SWT.SHIFT) == 0) { + searchNext(); + } else { + searchPrevious(); + } + } + } }); - } + } protected void fireFilterApplied(ITmfFilter filter) { for (ITmfEventsFilterListener listener : fEventsFilterListeners) { listener.filterApplied(filter, fTrace); } } - + protected void fireSearchApplied(ITmfFilter filter) { for (ITmfEventsFilterListener listener : fEventsFilterListeners) { listener.searchApplied(filter, fTrace); } } - + protected void startFilterThread() { - synchronized (fFilterSyncObj) { - if (fFilterThread != null) { - fFilterThread.cancel(); - } - final ITmfFilterTreeNode filter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ); - fFilterThread = new FilterThread(filter); - fFilterThread.start(); - } + synchronized (fFilterSyncObj) { + if (fFilterThread != null) { + fFilterThread.cancel(); + } + final ITmfFilterTreeNode filter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ); + fFilterThread = new FilterThread(filter); + fFilterThread.start(); + } } protected void stopFilterThread() { - synchronized (fFilterSyncObj) { - if (fFilterThread != null) { - fFilterThread.cancel(); - } - } + synchronized (fFilterSyncObj) { + if (fFilterThread != null) { + fFilterThread.cancel(); + } + } } protected void clearFilters() { - if (fTable.getData(Key.FILTER_OBJ) == null) { - return; - } - fCache.clearFilter(); - fTable.clearAll(); - for (TableColumn column : fTable.getColumns()) { - column.setData(Key.FILTER_OBJ, null); - column.setData(Key.FILTER_TXT, null); - } - fTable.setData(Key.FILTER_OBJ, null); - if (fTrace != null) { - fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row - } else { - fTable.setItemCount(1); // +1 for header row - } - fFilterMatchCount = 0; - fFilterCheckCount = 0; - if (fSelectedRank >= 0) { - fTable.setSelection((int) fSelectedRank + 1); // +1 for header row - } else { - fTable.setSelection(0); - } - fireFilterApplied(null); + if (fTable.getData(Key.FILTER_OBJ) == null) { + return; + } + fCache.clearFilter(); + fTable.clearAll(); + for (TableColumn column : fTable.getColumns()) { + column.setData(Key.FILTER_OBJ, null); + column.setData(Key.FILTER_TXT, null); + } + fTable.setData(Key.FILTER_OBJ, null); + if (fTrace != null) { + fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row + } else { + fTable.setItemCount(1); // +1 for header row + } + fFilterMatchCount = 0; + fFilterCheckCount = 0; + if (fSelectedRank >= 0) { + fTable.setSelection((int) fSelectedRank + 1); // +1 for header row + } else { + fTable.setSelection(0); + } + fireFilterApplied(null); } - + protected class FilterThread extends Thread { - private final ITmfFilterTreeNode filter; - private TmfEventRequest request; + private final ITmfFilterTreeNode filter; + private TmfEventRequest request; private boolean refreshBusy = false; private boolean refreshPending = false; private Object syncObj = new Object(); - public FilterThread(ITmfFilterTreeNode filter) { - super("Filter Thread"); //$NON-NLS-1$ - this.filter = filter; - } - - @SuppressWarnings("unchecked") - @Override - public void run() { - if (fTrace == null) { - return; - } - int nbRequested = (int) (fTrace.getNbEvents() - fFilterCheckCount); - if (nbRequested <= 0) { - return; - } - request = new TmfEventRequest(TmfEvent.class, TmfTimeRange.Eternity, (int) fFilterCheckCount, nbRequested, fTrace.getCacheSize(), ExecutionType.BACKGROUND) { - @Override - public void handleData(TmfEvent event) { - super.handleData(event); - if (request.isCancelled()) return; - if (filter.matches(event)) { - long rank = fFilterCheckCount; - int index = (int) fFilterMatchCount; - fFilterMatchCount++; - fCache.storeEvent(event.clone(), rank, index); - refreshTable(); - } else if (fFilterCheckCount % 100 == 0) { - refreshTable(); - } - fFilterCheckCount++; - } - }; - ((ITmfDataProvider) fTrace).sendRequest(request); - try { - request.waitForCompletion(); - } catch (InterruptedException e) { - } - refreshTable(); - } - - public void refreshTable() { - synchronized (syncObj) { - if (refreshBusy) { - refreshPending = true; - return; - } else { - refreshBusy = true; - } - } - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - if (request.isCancelled()) return; - if (fTable.isDisposed()) return; - fTable.setItemCount((int) fFilterMatchCount + 3); // +1 for header row, +2 for top and bottom filter status rows - fTable.refresh(); - synchronized (syncObj) { - refreshBusy = false; - if (refreshPending) { - refreshPending = false; - refreshTable(); - } - } - } - }); - } - - public void cancel() { - if (request != null) { - request.cancel(); - } - } + public FilterThread(ITmfFilterTreeNode filter) { + super("Filter Thread"); //$NON-NLS-1$ + this.filter = filter; + } + + @SuppressWarnings("unchecked") + @Override + public void run() { + if (fTrace == null) { + return; + } + int nbRequested = (int) (fTrace.getNbEvents() - fFilterCheckCount); + if (nbRequested <= 0) { + return; + } + request = new TmfEventRequest(TmfEvent.class, TmfTimeRange.Eternity, (int) fFilterCheckCount, + nbRequested, fTrace.getCacheSize(), ExecutionType.BACKGROUND) { + @Override + public void handleData(TmfEvent event) { + super.handleData(event); + if (request.isCancelled()) + return; + if (filter.matches(event)) { + long rank = fFilterCheckCount; + int index = (int) fFilterMatchCount; + fFilterMatchCount++; + fCache.storeEvent(event.clone(), rank, index); + refreshTable(); + } else if (fFilterCheckCount % 100 == 0) { + refreshTable(); + } + fFilterCheckCount++; + } + }; + ((ITmfDataProvider) fTrace).sendRequest(request); + try { + request.waitForCompletion(); + } catch (InterruptedException e) { + } + refreshTable(); + } + + public void refreshTable() { + synchronized (syncObj) { + if (refreshBusy) { + refreshPending = true; + return; + } else { + refreshBusy = true; + } + } + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + if (request.isCancelled()) + return; + if (fTable.isDisposed()) + return; + fTable.setItemCount((int) fFilterMatchCount + 3); // +1 for header row, +2 for top and bottom filter + // status rows + fTable.refresh(); + synchronized (syncObj) { + refreshBusy = false; + if (refreshPending) { + refreshPending = false; + refreshTable(); + } + } + } + }); + } + + public void cancel() { + if (request != null) { + request.cancel(); + } + } } protected void searchNext() { - synchronized (fSearchSyncObj) { - if (fSearchThread != null) { - return; - } - final ITmfFilterTreeNode searchFilter = (ITmfFilterTreeNode) fTable.getData(Key.SEARCH_OBJ); - if (searchFilter == null) { - return; - } - int selectionIndex = fTable.getSelectionIndex(); - int startIndex; - if (selectionIndex > 0) { - startIndex = selectionIndex; // -1 for header row, +1 for next event - } else { - // header row is selected, start at top event - startIndex = Math.max(0, fTable.getTopIndex() - 1); // -1 for header row - } - final ITmfFilterTreeNode eventFilter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ); - if (eventFilter != null) { - startIndex = Math.max(0, startIndex - 1); // -1 for top filter status row - } - fSearchThread = new SearchThread(searchFilter, eventFilter, startIndex, fSelectedRank, Direction.FORWARD); - fSearchThread.schedule(); - } + synchronized (fSearchSyncObj) { + if (fSearchThread != null) { + return; + } + final ITmfFilterTreeNode searchFilter = (ITmfFilterTreeNode) fTable.getData(Key.SEARCH_OBJ); + if (searchFilter == null) { + return; + } + int selectionIndex = fTable.getSelectionIndex(); + int startIndex; + if (selectionIndex > 0) { + startIndex = selectionIndex; // -1 for header row, +1 for next event + } else { + // header row is selected, start at top event + startIndex = Math.max(0, fTable.getTopIndex() - 1); // -1 for header row + } + final ITmfFilterTreeNode eventFilter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ); + if (eventFilter != null) { + startIndex = Math.max(0, startIndex - 1); // -1 for top filter status row + } + fSearchThread = new SearchThread(searchFilter, eventFilter, startIndex, fSelectedRank, Direction.FORWARD); + fSearchThread.schedule(); + } } - + protected void searchPrevious() { - synchronized (fSearchSyncObj) { - if (fSearchThread != null) { - return; - } - final ITmfFilterTreeNode searchFilter = (ITmfFilterTreeNode) fTable.getData(Key.SEARCH_OBJ); - if (searchFilter == null) { - return; - } - int selectionIndex = fTable.getSelectionIndex(); - int startIndex; - if (selectionIndex > 0) { - startIndex = selectionIndex - 2; // -1 for header row, -1 for previous event - } else { - // header row is selected, start at precedent of top event - startIndex = fTable.getTopIndex() - 2; // -1 for header row, -1 for previous event - } - final ITmfFilterTreeNode eventFilter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ); - if (eventFilter != null) { - startIndex = startIndex - 1; // -1 for top filter status row - } - fSearchThread = new SearchThread(searchFilter, eventFilter, startIndex, fSelectedRank, Direction.BACKWARD); - fSearchThread.schedule(); - } + synchronized (fSearchSyncObj) { + if (fSearchThread != null) { + return; + } + final ITmfFilterTreeNode searchFilter = (ITmfFilterTreeNode) fTable.getData(Key.SEARCH_OBJ); + if (searchFilter == null) { + return; + } + int selectionIndex = fTable.getSelectionIndex(); + int startIndex; + if (selectionIndex > 0) { + startIndex = selectionIndex - 2; // -1 for header row, -1 for previous event + } else { + // header row is selected, start at precedent of top event + startIndex = fTable.getTopIndex() - 2; // -1 for header row, -1 for previous event + } + final ITmfFilterTreeNode eventFilter = (ITmfFilterTreeNode) fTable.getData(Key.FILTER_OBJ); + if (eventFilter != null) { + startIndex = startIndex - 1; // -1 for top filter status row + } + fSearchThread = new SearchThread(searchFilter, eventFilter, startIndex, fSelectedRank, Direction.BACKWARD); + fSearchThread.schedule(); + } } - + protected void stopSearchThread() { - fPendingGotoRank = -1; - synchronized (fSearchSyncObj) { - if (fSearchThread != null) { - fSearchThread.cancel(); - fSearchThread = null; - } - } + fPendingGotoRank = -1; + synchronized (fSearchSyncObj) { + if (fSearchThread != null) { + fSearchThread.cancel(); + fSearchThread = null; + } + } } - + protected class SearchThread extends Job { - protected ITmfFilterTreeNode searchFilter; - protected ITmfFilterTreeNode eventFilter; - protected int startIndex; - protected int direction; - protected long rank; - protected long foundRank = -1; - protected TmfDataRequest request; - - public SearchThread(ITmfFilterTreeNode searchFilter, ITmfFilterTreeNode eventFilter, int startIndex, long currentRank, int direction) { - super(Messages.TmfEventsTable_SearchingJobName); - this.searchFilter = searchFilter; - this.eventFilter = eventFilter; - this.startIndex = startIndex; - this.rank = currentRank; - this.direction = direction; - } - - @SuppressWarnings("unchecked") - @Override - protected IStatus run(final IProgressMonitor monitor) { - if (fTrace == null) { - return Status.OK_STATUS; - } - final Display display = Display.getDefault(); - if (startIndex < 0) { - rank = (int) fTrace.getNbEvents() - 1; - } else if (startIndex >= fTable.getItemCount() - (eventFilter == null ? 1 : 3)) { // -1 for header row, -2 for top and bottom filter status rows - rank = 0; - } else { - int idx = startIndex; - while (foundRank == -1) { - CachedEvent event = fCache.peekEvent(idx); - if (event == null) { - break; - } - rank = event.rank; - if (searchFilter.matches(event.event) && (eventFilter == null || eventFilter.matches(event.event))) { - foundRank = event.rank; - break; - } - if (direction == Direction.FORWARD) { - idx++; - } else { - idx--; - } - } - if (foundRank == -1) { - if (direction == Direction.FORWARD) { - rank++; - if (rank > fTrace.getNbEvents() - 1) { - rank = 0; - } - } else { - rank--; - if (rank < 0) { - rank = (int) fTrace.getNbEvents() - 1; - } - } - } - } - int startRank = (int) rank; - boolean wrapped = false; - while (!monitor.isCanceled() && foundRank == -1 && fTrace != null) { - int nbRequested = (direction == Direction.FORWARD ? Integer.MAX_VALUE : Math.min((int) rank + 1, fTrace.getCacheSize())); - if (direction == Direction.BACKWARD) { - rank = Math.max(0, rank - fTrace.getCacheSize() + 1); - } - request = new TmfDataRequest(TmfEvent.class, (int) rank, nbRequested) { - long currentRank = rank; - @Override - public void handleData(TmfEvent event) { - super.handleData(event); - if (searchFilter.matches(event) && (eventFilter == null || eventFilter.matches(event))) { - foundRank = currentRank; - if (direction == Direction.FORWARD) { - done(); - return; - } - } - currentRank++; - } - }; - ((ITmfDataProvider) fTrace).sendRequest(request); - try { - request.waitForCompletion(); - if (request.isCancelled()) { - return Status.OK_STATUS; - } - } catch (InterruptedException e) { - synchronized (fSearchSyncObj) { - fSearchThread = null; - } - return Status.OK_STATUS; - } - if (foundRank == -1) { - if (direction == Direction.FORWARD) { - if (rank == 0) { - synchronized (fSearchSyncObj) { - fSearchThread = null; - } - return Status.OK_STATUS; - } else { - nbRequested = (int) rank; - rank = 0; - wrapped = true; - } - } else { - rank--; - if (rank < 0) { - rank = (int) fTrace.getNbEvents() - 1; - wrapped = true; - } - if (rank <= startRank && wrapped) { - synchronized (fSearchSyncObj) { - fSearchThread = null; - } - return Status.OK_STATUS; - } - } - } - } - int index = (int) foundRank; - if (eventFilter != null) { - index = fCache.getFilteredEventIndex(foundRank); - } - final int selection = (int) index + 1 + (eventFilter != null ? +1 : 0); // +1 for header row, +1 for top filter status row - - display.asyncExec(new Runnable() { - @Override - public void run() { - if (monitor.isCanceled()) return; - if (fTable.isDisposed()) return; - fTable.setSelection(selection); - fSelectedRank = foundRank; - synchronized (fSearchSyncObj) { - fSearchThread = null; - } - } - }); - return Status.OK_STATUS; - } - - @Override - protected void canceling() { - request.cancel(); - synchronized (fSearchSyncObj) { - fSearchThread = null; - } - } + protected ITmfFilterTreeNode searchFilter; + protected ITmfFilterTreeNode eventFilter; + protected int startIndex; + protected int direction; + protected long rank; + protected long foundRank = -1; + protected TmfDataRequest request; + + public SearchThread(ITmfFilterTreeNode searchFilter, ITmfFilterTreeNode eventFilter, int startIndex, + long currentRank, int direction) { + super(Messages.TmfEventsTable_SearchingJobName); + this.searchFilter = searchFilter; + this.eventFilter = eventFilter; + this.startIndex = startIndex; + this.rank = currentRank; + this.direction = direction; + } + + @SuppressWarnings("unchecked") + @Override + protected IStatus run(final IProgressMonitor monitor) { + if (fTrace == null) { + return Status.OK_STATUS; + } + final Display display = Display.getDefault(); + if (startIndex < 0) { + rank = (int) fTrace.getNbEvents() - 1; + } else if (startIndex >= fTable.getItemCount() - (eventFilter == null ? 1 : 3)) { // -1 for header row, -2 + // for top and bottom + // filter status rows + rank = 0; + } else { + int idx = startIndex; + while (foundRank == -1) { + CachedEvent event = fCache.peekEvent(idx); + if (event == null) { + break; + } + rank = event.rank; + if (searchFilter.matches(event.event) && (eventFilter == null || eventFilter.matches(event.event))) { + foundRank = event.rank; + break; + } + if (direction == Direction.FORWARD) { + idx++; + } else { + idx--; + } + } + if (foundRank == -1) { + if (direction == Direction.FORWARD) { + rank++; + if (rank > fTrace.getNbEvents() - 1) { + rank = 0; + } + } else { + rank--; + if (rank < 0) { + rank = (int) fTrace.getNbEvents() - 1; + } + } + } + } + int startRank = (int) rank; + boolean wrapped = false; + while (!monitor.isCanceled() && foundRank == -1 && fTrace != null) { + int nbRequested = (direction == Direction.FORWARD ? Integer.MAX_VALUE : Math.min((int) rank + 1, + fTrace.getCacheSize())); + if (direction == Direction.BACKWARD) { + rank = Math.max(0, rank - fTrace.getCacheSize() + 1); + } + request = new TmfDataRequest(TmfEvent.class, (int) rank, nbRequested) { + long currentRank = rank; + + @Override + public void handleData(TmfEvent event) { + super.handleData(event); + if (searchFilter.matches(event) && (eventFilter == null || eventFilter.matches(event))) { + foundRank = currentRank; + if (direction == Direction.FORWARD) { + done(); + return; + } + } + currentRank++; + } + }; + ((ITmfDataProvider) fTrace).sendRequest(request); + try { + request.waitForCompletion(); + if (request.isCancelled()) { + return Status.OK_STATUS; + } + } catch (InterruptedException e) { + synchronized (fSearchSyncObj) { + fSearchThread = null; + } + return Status.OK_STATUS; + } + if (foundRank == -1) { + if (direction == Direction.FORWARD) { + if (rank == 0) { + synchronized (fSearchSyncObj) { + fSearchThread = null; + } + return Status.OK_STATUS; + } else { + nbRequested = (int) rank; + rank = 0; + wrapped = true; + } + } else { + rank--; + if (rank < 0) { + rank = (int) fTrace.getNbEvents() - 1; + wrapped = true; + } + if (rank <= startRank && wrapped) { + synchronized (fSearchSyncObj) { + fSearchThread = null; + } + return Status.OK_STATUS; + } + } + } + } + int index = (int) foundRank; + if (eventFilter != null) { + index = fCache.getFilteredEventIndex(foundRank); + } + final int selection = index + 1 + (eventFilter != null ? +1 : 0); // +1 for header row, +1 for top filter + // status row + + display.asyncExec(new Runnable() { + @Override + public void run() { + if (monitor.isCanceled()) + return; + if (fTable.isDisposed()) + return; + fTable.setSelection(selection); + fSelectedRank = foundRank; + synchronized (fSearchSyncObj) { + fSearchThread = null; + } + } + }); + return Status.OK_STATUS; + } + + @Override + protected void canceling() { + request.cancel(); + synchronized (fSearchSyncObj) { + fSearchThread = null; + } + } } protected void createResources() { - fGrayColor = fResourceManager.createColor(ColorUtil.blend(fTable.getBackground().getRGB(), fTable.getForeground().getRGB())); - fGreenColor = fTable.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN); - fBoldFont = fResourceManager.createFont(FontDescriptor.createFrom(fTable.getFont()).setStyle(SWT.BOLD)); + fGrayColor = fResourceManager.createColor(ColorUtil.blend(fTable.getBackground().getRGB(), fTable + .getForeground().getRGB())); + fGreenColor = fTable.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN); + fBoldFont = fResourceManager.createFont(FontDescriptor.createFrom(fTable.getFont()).setStyle(SWT.BOLD)); } - + protected void packColumns() { - if (fPackDone) return; + if (fPackDone) + return; for (TableColumn column : fTable.getColumns()) { int headerWidth = column.getWidth(); column.pack(); @@ -1264,23 +1280,19 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS } fPackDone = true; } - + /** * @param event * @return * - * FIXME: Add support for column selection + * FIXME: Add support for column selection */ protected String[] extractItemFields(TmfEvent event) { String[] fields = new String[0]; if (event != null) { - fields = new String[] { - new Long(event.getTimestamp().getValue()).toString(), - event.getSource().getSourceId().toString(), - event.getType().getTypeId().toString(), - event.getReference().getReference().toString(), - event.getContent().toString() - }; + fields = new String[] { new Long(event.getTimestamp().getValue()).toString(), + event.getSource().getSourceId().toString(), event.getType().getTypeId().toString(), + event.getReference().getReference().toString(), event.getContent().toString() }; } return fields; } @@ -1291,21 +1303,22 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS /** * @param trace - * @param disposeOnClose true if the trace should be disposed when the table is disposed + * @param disposeOnClose + * true if the trace should be disposed when the table is disposed */ public void setTrace(ITmfTrace trace, boolean disposeOnClose) { if (fTrace != null && fDisposeOnClose) { fTrace.dispose(); } fTrace = trace; - fPackDone = false; - fSelectedRank = 0; + fPackDone = false; + fSelectedRank = 0; fDisposeOnClose = disposeOnClose; - + // Perform the updates on the UI thread fTable.getDisplay().syncExec(new Runnable() { @Override - public void run() { + public void run() { fTable.removeAll(); fCache.setTrace(fTrace); // Clear the cache if (fTrace != null) { @@ -1332,15 +1345,15 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS public void cacheUpdated(final boolean completed) { synchronized (fCacheUpdateSyncObj) { - if (fCacheUpdateBusy) { - fCacheUpdatePending = true; - fCacheUpdateCompleted = completed; - return; - } else { - fCacheUpdateBusy = true; - } + if (fCacheUpdateBusy) { + fCacheUpdatePending = true; + fCacheUpdateCompleted = completed; + return; + } else { + fCacheUpdateBusy = true; + } } - // Event cache is now updated. Perform update on the UI thread + // Event cache is now updated. Perform update on the UI thread if (!fTable.isDisposed()) { fTable.getDisplay().asyncExec(new Runnable() { @Override @@ -1350,170 +1363,202 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS packColumns(); } if (completed) { - populateCompleted(); + populateCompleted(); + } + synchronized (fCacheUpdateSyncObj) { + fCacheUpdateBusy = false; + if (fCacheUpdatePending) { + fCacheUpdatePending = false; + cacheUpdated(fCacheUpdateCompleted); + } } - synchronized (fCacheUpdateSyncObj) { - fCacheUpdateBusy = false; - if (fCacheUpdatePending) { - fCacheUpdatePending = false; - cacheUpdated(fCacheUpdateCompleted); - } - } } }); } } - + protected void populateCompleted() { - // Nothing by default; + // Nothing by default; } // ------------------------------------------------------------------------ // Bookmark handling // ------------------------------------------------------------------------ - - public void addBookmark(IResource resource) { - fBookmarksResource = resource; - TableItem[] selection = fTable.getSelection(); - if (selection.length > 0) { - TableItem tableItem = selection[0]; - if (tableItem.getData(Key.RANK) != null) { - StringBuffer defaultMessage = new StringBuffer(); - for (int i = 0; i < fTable.getColumns().length; i++) { - if (i > 0) { - defaultMessage.append(", "); //$NON-NLS-1$ - } - defaultMessage.append(tableItem.getText(i)); - } - InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), - Messages.TmfEventsTable_AddBookmarkDialogTitle, Messages.TmfEventsTable_AddBookmarkDialogText, defaultMessage.toString(), null); - if (dialog.open() == Dialog.OK) { - String message = dialog.getValue(); - try { - IMarker bookmark = resource.createMarker(IMarker.BOOKMARK); - if (bookmark.exists()) { - bookmark.setAttribute(IMarker.MESSAGE, message.toString()); - long rank = (Long) tableItem.getData(Key.RANK); - int location = (int) rank; - bookmark.setAttribute(IMarker.LOCATION, (Integer) location); - fBookmarksMap.put(rank, bookmark.getId()); - fTable.refresh(); - } + + public void addBookmark(IResource resource) { + fBookmarksResource = resource; + TableItem[] selection = fTable.getSelection(); + if (selection.length > 0) { + TableItem tableItem = selection[0]; + if (tableItem.getData(Key.RANK) != null) { + StringBuffer defaultMessage = new StringBuffer(); + for (int i = 0; i < fTable.getColumns().length; i++) { + if (i > 0) { + defaultMessage.append(", "); //$NON-NLS-1$ + } + defaultMessage.append(tableItem.getText(i)); + } + InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + Messages.TmfEventsTable_AddBookmarkDialogTitle, Messages.TmfEventsTable_AddBookmarkDialogText, + defaultMessage.toString(), null); + if (dialog.open() == Dialog.OK) { + String message = dialog.getValue(); + try { + IMarker bookmark = resource.createMarker(IMarker.BOOKMARK); + if (bookmark.exists()) { + bookmark.setAttribute(IMarker.MESSAGE, message.toString()); + long rank = (Long) tableItem.getData(Key.RANK); + int location = (int) rank; + bookmark.setAttribute(IMarker.LOCATION, (Integer) location); + fBookmarksMap.put(rank, bookmark.getId()); + fTable.refresh(); + } } catch (CoreException e) { - e.printStackTrace(); + e.printStackTrace(); } - } - } - } - + } + } + } + + } + + public void removeBookmark(IMarker bookmark) { + for (Entry entry : fBookmarksMap.entrySet()) { + if (entry.getValue().equals(bookmark.getId())) { + fBookmarksMap.remove(entry.getKey()); + fTable.refresh(); + return; + } + } } - public void removeBookmark(IMarker bookmark) { - for (Entry entry : fBookmarksMap.entrySet()) { - if (entry.getValue().equals(bookmark.getId())) { - fBookmarksMap.remove(entry.getKey()); - fTable.refresh(); - return; - } - } - } - - private void toggleBookmark(long rank) { - if (fBookmarksResource == null) { - return; - } - if (fBookmarksMap.containsKey(rank)) { - Long markerId = fBookmarksMap.remove(rank); - fTable.refresh(); - try { - IMarker bookmark = fBookmarksResource.findMarker(markerId); - if (bookmark != null) { - bookmark.delete(); - } + private void toggleBookmark(long rank) { + if (fBookmarksResource == null) { + return; + } + if (fBookmarksMap.containsKey(rank)) { + Long markerId = fBookmarksMap.remove(rank); + fTable.refresh(); + try { + IMarker bookmark = fBookmarksResource.findMarker(markerId); + if (bookmark != null) { + bookmark.delete(); + } } catch (CoreException e) { - e.printStackTrace(); + e.printStackTrace(); } - } else { - addBookmark(fBookmarksResource); - } - } - - public void refreshBookmarks(IResource resource) { - fBookmarksResource = resource; - try { - fBookmarksMap.clear(); - for (IMarker bookmark : resource.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) { - int location = bookmark.getAttribute(IMarker.LOCATION, -1); - if (location != -1) { - long rank = (long) location; - fBookmarksMap.put(rank, bookmark.getId()); - } - } - fTable.refresh(); + } else { + addBookmark(fBookmarksResource); + } + } + + public void refreshBookmarks(IResource resource) { + fBookmarksResource = resource; + try { + fBookmarksMap.clear(); + for (IMarker bookmark : resource.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) { + int location = bookmark.getAttribute(IMarker.LOCATION, -1); + if (location != -1) { + long rank = location; + fBookmarksMap.put(rank, bookmark.getId()); + } + } + fTable.refresh(); } catch (CoreException e) { - e.printStackTrace(); + e.printStackTrace(); } } - - @Override - public void gotoMarker(IMarker marker) { + + @Override + public void gotoMarker(IMarker marker) { int rank = marker.getAttribute(IMarker.LOCATION, -1); if (rank != -1) { - int index = (int) rank; - if (fTable.getData(Key.FILTER_OBJ) != null) { - index = fCache.getFilteredEventIndex(rank) + 1; //+1 for top filter status row - } else if (rank >= fTable.getItemCount()) { - fPendingGotoRank = rank; - } - fTable.setSelection(index + 1); // +1 for header row + int index = rank; + if (fTable.getData(Key.FILTER_OBJ) != null) { + index = fCache.getFilteredEventIndex(rank) + 1; // +1 for top filter status row + } else if (rank >= fTable.getItemCount()) { + fPendingGotoRank = rank; + } + fTable.setSelection(index + 1); // +1 for header row } - } - + } + // ------------------------------------------------------------------------ // Listeners // ------------------------------------------------------------------------ - - /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.ui.views.colors.IColorSettingsListener#colorSettingsChanged(org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting[]) - */ - @Override + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.linuxtools.tmf.ui.views.colors.IColorSettingsListener#colorSettingsChanged(org.eclipse.linuxtools + * .tmf.ui.views.colors.ColorSetting[]) + */ + @Override public void colorSettingsChanged(ColorSetting[] colorSettings) { - fTable.refresh(); - } - + fTable.refresh(); + } + @Override public void addEventsFilterListener(ITmfEventsFilterListener listener) { - if (!fEventsFilterListeners.contains(listener)) { - fEventsFilterListeners.add(listener); - } + if (!fEventsFilterListeners.contains(listener)) { + fEventsFilterListeners.add(listener); + } } - @Override + @Override public void removeEventsFilterListener(ITmfEventsFilterListener listener) { - fEventsFilterListeners.remove(listener); + fEventsFilterListeners.remove(listener); } // ------------------------------------------------------------------------ // Signal handlers // ------------------------------------------------------------------------ - - @TmfSignalHandler - public void experimentUpdated(TmfExperimentUpdatedSignal signal) { - if ((signal.getExperiment() != fTrace) || fTable.isDisposed()) return; + +// @TmfSignalHandler +// public void experimentUpdated(TmfExperimentUpdatedSignal signal) { +// if ((signal.getExperiment() != fTrace) || fTable.isDisposed()) return; +// // Perform the refresh on the UI thread +// Display.getDefault().asyncExec(new Runnable() { +// @Override +// public void run() { +// if (!fTable.isDisposed() && fTrace != null) { +// if (fTable.getData(Key.FILTER_OBJ) == null) { +// fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row +// if (fPendingGotoRank != -1 && fPendingGotoRank + 1 < fTable.getItemCount()) { // +1 for header row +// fTable.setSelection((int) fPendingGotoRank + 1); // +1 for header row +// fPendingGotoRank = -1; +// } +// } else { +// startFilterThread(); +// } +// } +// if (!fRawViewer.isDisposed() && fTrace != null) { +// fRawViewer.refreshEventCount(); +// } +// } +// }); +// } + + @TmfSignalHandler + public void experimentUpdated(TmfExperimentRangeUpdatedSignal signal) { + if ((signal.getExperiment() != fTrace) || fTable.isDisposed()) + return; // Perform the refresh on the UI thread - Display.getDefault().asyncExec(new Runnable() { + Display.getDefault().asyncExec(new Runnable() { @Override - public void run() { + public void run() { if (!fTable.isDisposed() && fTrace != null) { - if (fTable.getData(Key.FILTER_OBJ) == null) { - fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row - if (fPendingGotoRank != -1 && fPendingGotoRank + 1 < fTable.getItemCount()) { // +1 for header row - fTable.setSelection((int) fPendingGotoRank + 1); // +1 for header row - fPendingGotoRank = -1; - } - } else { - startFilterThread(); - } + if (fTable.getData(Key.FILTER_OBJ) == null) { + fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row + if (fPendingGotoRank != -1 && fPendingGotoRank + 1 < fTable.getItemCount()) { // +1 for header + // row + fTable.setSelection((int) fPendingGotoRank + 1); // +1 for header row + fPendingGotoRank = -1; + } + } else { + startFilterThread(); + } } if (!fRawViewer.isDisposed() && fTrace != null) { fRawViewer.refreshEventCount(); @@ -1521,24 +1566,26 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS } }); } - + @TmfSignalHandler public void traceUpdated(TmfTraceUpdatedSignal signal) { - if ((signal.getTrace() != fTrace ) || fTable.isDisposed()) return; + if ((signal.getTrace() != fTrace) || fTable.isDisposed()) + return; // Perform the refresh on the UI thread Display.getDefault().asyncExec(new Runnable() { @Override - public void run() { + public void run() { if (!fTable.isDisposed() && fTrace != null) { - if (fTable.getData(Key.FILTER_OBJ) == null) { - fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row - if (fPendingGotoRank != -1 && fPendingGotoRank + 1 < fTable.getItemCount()) { // +1 for header row - fTable.setSelection((int) fPendingGotoRank + 1); // +1 for header row - fPendingGotoRank = -1; - } - } else { - startFilterThread(); - } + if (fTable.getData(Key.FILTER_OBJ) == null) { + fTable.setItemCount((int) fTrace.getNbEvents() + 1); // +1 for header row + if (fPendingGotoRank != -1 && fPendingGotoRank + 1 < fTable.getItemCount()) { // +1 for header + // row + fTable.setSelection((int) fPendingGotoRank + 1); // +1 for header row + fPendingGotoRank = -1; + } + } else { + startFilterThread(); + } } if (!fRawViewer.isDisposed() && fTrace != null) { fRawViewer.refreshEventCount(); @@ -1550,60 +1597,65 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS @SuppressWarnings("unchecked") @TmfSignalHandler public void currentTimeUpdated(final TmfTimeSynchSignal signal) { - if ((signal.getSource() != fTable) && (fTrace != null) && (!fTable.isDisposed())) { - - // Create a request for one event that will be queued after other ongoing requests. When this request is completed - // do the work to select the actual event with the timestamp specified in the signal. This procedure prevents - // the method fTrace.getRank() from interfering and delaying ongoing requests. - final TmfDataRequest subRequest = new TmfDataRequest(TmfEvent.class, 0, 1, ExecutionType.FOREGROUND) { - - TmfTimestamp ts = new TmfTimestamp(signal.getCurrentTime()); - - @Override - public void handleData(TmfEvent event) { - super.handleData(event); - } - - @Override - public void handleCompleted() { - super.handleCompleted(); - if (fTrace == null) { - return; - } - // Verify if event is within the trace range - final TmfTimestamp timestamp[] = new TmfTimestamp[1]; - timestamp[0] = ts; // signal.getCurrentTime(); - if (timestamp[0].compareTo(fTrace.getStartTime(), true) == -1) { - timestamp[0] = fTrace.getStartTime(); - } - if (timestamp[0].compareTo(fTrace.getEndTime(), true) == 1) { - timestamp[0] = fTrace.getEndTime(); - } - - // Get the rank for the event selection in the table - final long rank = fTrace.getRank(timestamp[0]); - fSelectedRank = rank; - - fTable.getDisplay().asyncExec(new Runnable() { - @Override + if ((signal.getSource() != fTable) && (fTrace != null) && (!fTable.isDisposed())) { + + // Create a request for one event that will be queued after other ongoing requests. When this request is + // completed + // do the work to select the actual event with the timestamp specified in the signal. This procedure + // prevents + // the method fTrace.getRank() from interfering and delaying ongoing requests. + final TmfDataRequest subRequest = new TmfDataRequest(TmfEvent.class, 0, 1, + ExecutionType.FOREGROUND) { + + TmfTimestamp ts = new TmfTimestamp(signal.getCurrentTime()); + + @Override + public void handleData(TmfEvent event) { + super.handleData(event); + } + + @Override + public void handleCompleted() { + super.handleCompleted(); + if (fTrace == null) { + return; + } + // Verify if event is within the trace range + final TmfTimestamp timestamp[] = new TmfTimestamp[1]; + timestamp[0] = ts; // signal.getCurrentTime(); + if (timestamp[0].compareTo(fTrace.getStartTime(), true) == -1) { + timestamp[0] = fTrace.getStartTime(); + } + if (timestamp[0].compareTo(fTrace.getEndTime(), true) == 1) { + timestamp[0] = fTrace.getEndTime(); + } + + // Get the rank for the event selection in the table + final long rank = fTrace.getRank(timestamp[0]); + fSelectedRank = rank; + + fTable.getDisplay().asyncExec(new Runnable() { + @Override public void run() { - // Return if table is disposed - if (fTable.isDisposed()) return; + // Return if table is disposed + if (fTable.isDisposed()) + return; int index = (int) rank; - if (fTable.isDisposed()) return; + if (fTable.isDisposed()) + return; if (fTable.getData(Key.FILTER_OBJ) != null) { - index = fCache.getFilteredEventIndex(rank) + 1; //+1 for top filter status row + index = fCache.getFilteredEventIndex(rank) + 1; // +1 for top filter status row } fTable.setSelection(index + 1); // +1 for header row fRawViewer.selectAndReveal(rank); - } - }); - } - }; + } + }); + } + }; ((ITmfDataProvider) fTrace).sendRequest(subRequest); - } - } + } + } -} +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TracingPerspectiveFactory.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TracingPerspectiveFactory.java new file mode 100644 index 0000000000..d4f7b7b774 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TracingPerspectiveFactory.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 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.tmf.ui.views; + +import org.eclipse.linuxtools.tmf.ui.views.events.TmfEventsView; +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +/** + * TracingPerspectiveFactory + *

    + * TODO: Implement me. Please. + */ +public class TracingPerspectiveFactory implements IPerspectiveFactory { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + // Perspective ID + public static final String ID = "org.eclipse.linuxtools.tmf.ui.perspective.tracing"; //$NON-NLS-1$ + + // Standard TMF views + private static final String EVENTS_VIEW_ID = TmfEventsView.ID; + + // Standard Eclipse views + private static final String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER; + private static final String PROPERTIES_VIEW_ID = IPageLayout.ID_PROP_SHEET; + + // ------------------------------------------------------------------------ + // IPerspectiveFactory + // ------------------------------------------------------------------------ + + @Override + public void createInitialLayout(IPageLayout layout) { + + // No editor part + layout.setEditorAreaVisible(false); + + // Goodies + addFastViews(layout); + addViewShortcuts(layout); + addPerspectiveShortcuts(layout); + + // Create the top left folder + IFolderLayout topLeftFolder = layout.createFolder( + "topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ + topLeftFolder.addView(PROJECT_VIEW_ID); + +// // Create the bottom left folder +// @SuppressWarnings("unused") +// IFolderLayout bottomLeftFolder = layout.createFolder( +// "bottomLeftFolder", IPageLayout.BOTTOM, 0.50f, "topLeftFolder"); //$NON-NLS-1$//$NON-NLS-2$ + + // Create the top right folder + IFolderLayout topRightFolder = layout.createFolder( + "topRightFolder", IPageLayout.TOP, 0.50f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ + topRightFolder.addView(EVENTS_VIEW_ID); + + // Create the middle right folder + @SuppressWarnings("unused") + IFolderLayout middleRightFolder = layout.createFolder( + "middleRightFolder", IPageLayout.BOTTOM, 0.50f, "topRightFolder"); //$NON-NLS-1$//$NON-NLS-2$ + + // Create the bottom right folder + IFolderLayout bottomRightFolder = layout.createFolder( + "bottomRightFolder", IPageLayout.BOTTOM, 0.65f, "middleRightFolder"); //$NON-NLS-1$ //$NON-NLS-2$ + bottomRightFolder.addView(PROPERTIES_VIEW_ID); + + } + + // ------------------------------------------------------------------------ + // Helper functions + // ------------------------------------------------------------------------ + + private void addFastViews(IPageLayout layout) { + } + + private void addViewShortcuts(IPageLayout layout) { + } + + private void addPerspectiveShortcuts(IPageLayout layout) { + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java similarity index 97% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java rename to org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java index ed1593d0bf..9c10ad369c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java @@ -11,7 +11,7 @@ * Patrick Tasse - Factored out events table *******************************************************************************/ -package org.eclipse.linuxtools.tmf.ui.views; +package org.eclipse.linuxtools.tmf.ui.views.events; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; @@ -20,6 +20,7 @@ import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; +import org.eclipse.linuxtools.tmf.ui.views.TmfView; import org.eclipse.swt.widgets.Composite; /** diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/ProjectView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/ProjectView.java deleted file mode 100644 index 1623f01ec6..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/ProjectView.java +++ /dev/null @@ -1,404 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.NotEnabledException; -import org.eclipse.core.commands.NotHandledException; -import org.eclipse.core.commands.common.NotDefinedException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.ViewerDropAdapter; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.linuxtools.tmf.event.TmfEvent; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.TmfUiPreferenceInitializer; -import org.eclipse.linuxtools.tmf.ui.editors.TmfEditorInput; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; -import org.eclipse.linuxtools.tmf.ui.views.TmfView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.ITmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectContentProvider; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectLabelProvider; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectRoot; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.ResourceTransfer; -import org.osgi.service.prefs.BackingStoreException; - -/** - * ProjectView - *

    - * The ProjectView keeps track of the Tmf projects in the workspace. - */ -public class ProjectView extends TmfView { - - public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.project"; //$NON-NLS-1$ - - // ------------------------------------------------------------------------ - // Main data structures - // ------------------------------------------------------------------------ - - private TreeViewer fViewer; - private TmfProjectRoot fProjectRoot; - - private IWorkspace fWorkspace; - private IResourceChangeListener fResourceChangeListener; - private IPreferenceChangeListener fPreferenceChangeListener; - - // ------------------------------------------------------------------------ - // Static methods - // ------------------------------------------------------------------------ - - static public IFolder getActiveProjectTracesFolder() { - IEclipsePreferences node = new InstanceScope() - .getNode(TmfUiPlugin.PLUGIN_ID); - String activeProjectName = node.get( - TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, - TmfUiPreferenceInitializer.ACTIVE_PROJECT_DEFAULT); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject[] projects = root.getProjects(); - for (IProject project : projects) { - if (project.isAccessible() - && project.getName().equals(activeProjectName)) { - return project.getFolder(TmfProjectNode.TRACE_FOLDER_NAME); - } - } - return null; - } - - static public IFile createLink(URI uri) throws CoreException { - IFolder folder = getActiveProjectTracesFolder(); - if (folder == null || !folder.exists()) { - throw new CoreException(new Status(Status.ERROR, TmfUiPlugin.PLUGIN_ID, "No active project set")); //$NON-NLS-1$ - } - String path = uri.getPath(); - // TODO: support duplicate file names - IFile file = folder.getFile(path.substring(path - .lastIndexOf(Path.SEPARATOR))); - if (!file.exists()) { - file.createLink(uri, IResource.NONE, null); - } - return file; - } - - // ------------------------------------------------------------------------ - // View refresher - // ------------------------------------------------------------------------ - - // Perform updates on the UI thread - private Runnable fViewRefresher = new Runnable() { - @Override - public void run() { - if ((fViewer != null) && (!fViewer.getTree().isDisposed())) { - Object[] elements = fViewer.getExpandedElements(); - fViewer.refresh(); - fViewer.setExpandedElements(elements); - } - } - }; - - public TmfProjectRoot getRoot() { - return fProjectRoot; - } - - // ------------------------------------------------------------------------ - // Constructor - // ------------------------------------------------------------------------ - - public ProjectView() { - super("Projects"); //$NON-NLS-1$ - - fWorkspace = ResourcesPlugin.getWorkspace(); - try { - fWorkspace.getRoot().refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException e) { - e.printStackTrace(); - } - - fProjectRoot = new TmfProjectRoot(this); - } - - public void refresh() { - Tree tree = fViewer.getTree(); - if (tree != null && !tree.isDisposed()) - tree.getDisplay().asyncExec(fViewRefresher); - } - - public void setSelection(ITmfProjectTreeNode node) { - fViewer.setSelection(new StructuredSelection(node), true); - } - - @Override - public void init(IViewSite site) throws PartInitException { - super.init(site); - fResourceChangeListener = new IResourceChangeListener() { - @Override - public void resourceChanged(IResourceChangeEvent event) { - if (event.getType() == IResourceChangeEvent.POST_CHANGE) { - fProjectRoot.refreshChildren(); - refresh(); - } - } - }; - fWorkspace.addResourceChangeListener(fResourceChangeListener); - fPreferenceChangeListener = new IPreferenceChangeListener() { - @Override - public void preferenceChange(PreferenceChangeEvent event) { - refresh(); - } - }; - IEclipsePreferences node = new InstanceScope().getNode(TmfUiPlugin.PLUGIN_ID); - node.addPreferenceChangeListener(fPreferenceChangeListener); - } - - @Override - public void dispose() { - fWorkspace.removeResourceChangeListener(fResourceChangeListener); - } - - @Override - public void createPartControl(Composite parent) { - - fViewer = new TreeViewer(parent, SWT.SINGLE); - fViewer.setContentProvider(new TmfProjectContentProvider()); - fViewer.setSorter(new ViewerSorter()); - fViewer.setLabelProvider(new TmfProjectLabelProvider()); - fViewer.setInput(fProjectRoot); - - int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance() }; - fViewer.addDropSupport(ops, transfers, new ViewerDropAdapter(fViewer) { - @Override - public boolean validateDrop(Object target, int operation, TransferData transferType) { - if (! (target instanceof ITmfProjectTreeNode)) { - return false; - } - overrideOperation(DND.DROP_LINK); - return true; - } - @Override - public boolean performDrop(Object data) { - Object target = getCurrentTarget(); - ITmfProjectTreeNode node = (TmfProjectTreeNode) target; - while (node != null && !(node instanceof TmfProjectNode)) { - node = node.getParent(); - } - IFolder targetFolder = ((TmfProjectNode) node).getTracesFolder().getFolder(); - if (data instanceof String[]) { - // FileTransfer - for (String path : (String[]) data) { - File sourceFile = new File(path); - if (sourceFile.isFile()) { - IFile file = targetFolder.getFile(path.substring(path.lastIndexOf(File.separator))); - try { - file.createLink(sourceFile.toURI(), IResource.NONE, null); - ITmfTrace trace = ParserProviderManager.getTrace(file); - if (trace != null) { - trace.dispose(); - } - } catch (CoreException e) { - e.printStackTrace(); - } - } - } - } else if (data instanceof IResource[]) { - // ResourceTransfer - for (IResource resource : (IResource[]) data) { - if (resource instanceof IFile) { - IFile file = targetFolder.getFile(resource.getName()); - try { - file.createLink(resource.getLocation(), IResource.NONE, null); - String parser = resource.getPersistentProperty(ParserProviderManager.PARSER_PROPERTY); - file.setPersistentProperty(ParserProviderManager.PARSER_PROPERTY, parser); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - } - } - return true; - } - }); - - getSite().setSelectionProvider(fViewer); - hookMouse(); - - createContextMenu(); - } - - // ------------------------------------------------------------------------ - // ViewPart - // ------------------------------------------------------------------------ - - @Override - @SuppressWarnings("nls") - public String toString() { - return "[ProjectView]"; - } - - // ------------------------------------------------------------------------ - // hookMouse - // ------------------------------------------------------------------------ - - private void hookMouse() { - fViewer.getTree().addMouseListener(new MouseAdapter() { - @Override - public void mouseDoubleClick(MouseEvent event) { - TreeItem treeItem = fViewer.getTree().getItem(new Point(event.x, event.y)); - if (treeItem == null) return; - Object element = treeItem.getData(); - if (element instanceof TmfExperimentNode) { - TmfExperimentNode experiment = (TmfExperimentNode) element; - selectExperiment(experiment); - } else if (element instanceof TmfProjectNode) { - TmfProjectNode project = (TmfProjectNode) element; - if (project.isOpen() && project.isTmfProject()) { - IEclipsePreferences node = new InstanceScope().getNode(TmfUiPlugin.PLUGIN_ID); - node.put(TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, ((TmfProjectNode) element).getName()); - try { - node.flush(); - } catch (BackingStoreException e) { - e.printStackTrace(); - } - } - } else if (element instanceof TmfTraceNode) { - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); - IHandlerService handlerService = (IHandlerService) win.getService(IHandlerService.class); - try { - handlerService.executeCommand("org.eclipse.linuxtools.tmf.ui.command.project.trace.open", null); //$NON-NLS-1$ - } catch (ExecutionException e) { - e.printStackTrace(); - } catch (NotDefinedException e) { - e.printStackTrace(); - } catch (NotEnabledException e) { - } catch (NotHandledException e) { - e.printStackTrace(); - } - } - } - }); - } - - public void selectExperiment(TmfExperimentNode experiment) { - String expId = experiment.getName(); -// if (fSelectedExperiment != null) -// fSelectedExperiment.deregister(); - try { - TmfTraceNode[] traceEntries = experiment.getTraces(); - int nbTraces = traceEntries.length; - List traces = new ArrayList(); - int cacheSize = Integer.MAX_VALUE; - for (int i = 0; i < nbTraces; i++) { - IResource resource = traceEntries[i].getResource(); - resource = experiment.getProject().getTracesFolder().getTraceForLocation(resource.getLocation()).getResource(); - ITmfTrace expTrace = ParserProviderManager.getTrace(resource); - if (expTrace != null) { - traces.add(expTrace); - cacheSize = Math.min(cacheSize, expTrace.getCacheSize()); - try { - // create a new independent copy of the trace for the editor - ITmfTrace trace = ParserProviderManager.getTrace(resource); - IEditorInput editorInput = new TmfEditorInput(resource, trace); - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage(); - - String editorId = ParserProviderManager.getEditorId(resource); - if (resource instanceof IFile) { - IDE.setDefaultEditor((IFile) resource, editorId); - } - IEditorPart editor = activePage.findEditor(editorInput); - if (editor != null && editor instanceof IReusableEditor) { - activePage.reuseEditor((IReusableEditor)editor, editorInput); - activePage.activate(editor); - } else { - editor = activePage.openEditor(editorInput, editorId); - } - - } catch (PartInitException e) { - e.printStackTrace(); - } - } - } - TmfExperiment selectedExperiment = new TmfExperiment(TmfEvent.class, expId, traces.toArray(new ITmfTrace[0]), cacheSize); - broadcast(new TmfExperimentSelectedSignal(this, selectedExperiment)); - } catch (Exception e) { - e.printStackTrace(); - } - } - - // ------------------------------------------------------------------------ - // createContextMenu - // ------------------------------------------------------------------------ - - // Populated from the plug-in - private void createContextMenu() { - MenuManager menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$ - menuManager.setRemoveAllWhenShown(true); - Menu menu = menuManager.createContextMenu(fViewer.getControl()); - fViewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuManager, fViewer); - } - -} \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizard.java deleted file mode 100644 index 55a33cadaa..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizard.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.dialogs; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -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.tmf.ui.internal.Messages; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.ui.IImportWizard; -import org.eclipse.ui.IWorkbench; - -/** - * AddTraceWizard - *

    - * TODO: Implement me. Please. - */ -public class AddTraceWizard extends Wizard implements IImportWizard { - - private TmfProjectNode fProject; - private TmfExperimentNode fExperiment; - private AddTraceWizardPage fMainPage; - - /** - * @param project - */ - public AddTraceWizard(TmfProjectNode project, TmfExperimentNode experiment) { - fProject = project; - fExperiment = experiment; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) - */ - @Override - public void init(IWorkbench workbench, IStructuredSelection selection) { - setWindowTitle(Messages.AddTraceWizard_WindowTitle); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ - @Override - public void addPages() { - super.addPages(); - fMainPage = new AddTraceWizardPage(fProject, "Some string"); //$NON-NLS-1$ - addPage(fMainPage); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#performFinish() - */ - @Override - public boolean performFinish() { - - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IFolder experimentFolder = fExperiment.getFolder(); - - TmfTraceNode[] traces = fMainPage.getSelection(); - for (TmfTraceNode trace : traces) { - try { - IResource resource = trace.getResource(); - IPath location = resource.getLocation(); - if (resource instanceof IFolder) { - IFolder folder = experimentFolder.getFolder(trace.getName()); - if (workspace.validateLinkLocation(folder, location).isOK()) { - folder.createLink(location, IResource.REPLACE, null); - } - else { - System.out.println("Invalid Trace Location"); //$NON-NLS-1$ - } - } else { - IFile file = experimentFolder.getFile(trace.getName()); - if (workspace.validateLinkLocation(file, location).isOK()) { - file.createLink(location, IResource.REPLACE, null); - } - else { - System.out.println("Invalid Trace Location"); //$NON-NLS-1$ - } - } - } catch (CoreException e) { - e.printStackTrace(); - } - } - - return true; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizardPage.java deleted file mode 100644 index 7966427f36..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/AddTraceWizardPage.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.dialogs; - -import java.util.Vector; - -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.linuxtools.tmf.ui.internal.Messages; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; - -/** - * AddTraceWizardPage - *

    - * TODO: Implement me. Please. - */ -public class AddTraceWizardPage extends WizardPage { - - private TmfProjectNode fProject; - private CheckboxTableViewer fCheckboxTableViewer; - - protected AddTraceWizardPage(TmfProjectNode project, String pageName) { - super(pageName); - setTitle(Messages.AddTraceWizardPage_WindowTitle); - setDescription(Messages.AddTraceWizardPage_Description); - fProject = project; - } - - @Override - public void createControl(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - container.setLayout(new FormLayout()); - setControl(container); - - fCheckboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER); - fCheckboxTableViewer.setContentProvider(new DialogTraceContentProvider()); - fCheckboxTableViewer.setLabelProvider(new DialogTraceLabelProvider()); - - final Table table = fCheckboxTableViewer.getTable(); - final FormData formData = new FormData(); - formData.bottom = new FormAttachment(100, 0); - formData.right = new FormAttachment(100, 0); - formData.top = new FormAttachment(0, 0); - formData.left = new FormAttachment(0, 0); - table.setLayoutData(formData); - table.setHeaderVisible(true); - - final TableColumn tableColumn = new TableColumn(table, SWT.NONE); - tableColumn.setWidth(200); - tableColumn.setText(Messages.AddTraceWizardPage_TraceColumnHeader); - - fCheckboxTableViewer.setInput(fProject.getTracesFolder()); - } - - public TmfTraceNode[] getSelection() { - Vector traces = new Vector(); - Object[] selection = fCheckboxTableViewer.getCheckedElements(); - for (Object sel : selection) { - if (sel instanceof TmfTraceNode) - traces.add((TmfTraceNode) sel); - } - TmfTraceNode[] result = new TmfTraceNode[traces.size()]; - traces.toArray(result); - return result; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceContentProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceContentProvider.java deleted file mode 100644 index 5bff8e6e3d..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceContentProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.dialogs; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceFolderNode; - -/** - * TmfTracesContentProvider - *

    - * TODO: Implement me. Please. - */ -public class DialogTraceContentProvider implements IStructuredContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - @Override - public Object[] getElements(Object inputElement) { - if (inputElement instanceof TmfTraceFolderNode) { - TmfTraceFolderNode folder = (TmfTraceFolderNode) inputElement; - return folder.getTraces(); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - @Override - 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) - */ - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // TODO Auto-generated method stub - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceLabelProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceLabelProvider.java deleted file mode 100644 index ec23afe1f4..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/DialogTraceLabelProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.dialogs; - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.swt.graphics.Image; - -/** - * TmfTracesLabelProvider - *

    - * TODO: Implement me. Please. - */ -public class DialogTraceLabelProvider extends LabelProvider implements ITableLabelProvider { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - @Override - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - @Override - public String getColumnText(Object element, int columnIndex) { - if (element instanceof TmfTraceNode) { - TmfTraceNode entry = (TmfTraceNode) element; - switch (columnIndex) { - case 0: - return entry.getName(); - default: - return null; - } - } - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/IDEWorkbenchMessages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/IDEWorkbenchMessages.java deleted file mode 100644 index a1df47caed..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/IDEWorkbenchMessages.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.eclipse.linuxtools.tmf.ui.views.project.dialogs; - -import org.eclipse.osgi.util.NLS; - -public class IDEWorkbenchMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.views.project.dialogs.messages"; //$NON-NLS-1$ - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, IDEWorkbenchMessages.class); - } - - private IDEWorkbenchMessages() { - } - - public static String NewExperimentDialog_ExperimentName; -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizard.java deleted file mode 100644 index ac5bab2bb4..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizard.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.dialogs; - -import java.util.List; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.IImportWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages; - -/** - * ImportTraceWizard - *

    - * - * TODO: Implement me. Please. - */ -@SuppressWarnings("restriction") -public class ImportTraceWizard extends Wizard implements IImportWizard { - - private IWorkbench fWorkbench; - private IStructuredSelection fSelection; - private ImportTraceWizardPage fMainPage; - - /** - * - */ - public ImportTraceWizard() { - IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings(); - IDialogSettings section = workbenchSettings.getSection("TmfTraceImportWizard"); //$NON-NLS-1$ - if (section == null) { - section = workbenchSettings.addNewSection("TmfTraceImportWizard"); //$NON-NLS-1$ - } - setDialogSettings(section); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ - @Override - public void addPages() { - super.addPages(); - fMainPage = new ImportTraceWizardPage(fWorkbench, fSelection); - addPage(fMainPage); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) - */ - @Override - @SuppressWarnings("rawtypes") - public void init(IWorkbench workbench, IStructuredSelection selection) { - fWorkbench = workbench; - fSelection = selection; - - List selectedResources = IDE.computeSelectedResources(selection); - if (!selectedResources.isEmpty()) { - fSelection = new StructuredSelection(selectedResources); - } - - setWindowTitle(DataTransferMessages.DataTransfer_importTitle); - setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png")); //$NON-NLS-1$ - setNeedsProgressMonitor(true); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#performFinish() - */ - @Override - public boolean performFinish() { - return fMainPage.finish(); - } - -} \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizardPage.java deleted file mode 100644 index b7bda04a42..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/ImportTraceWizardPage.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.dialogs; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImportPage1; - -/** - * ImportTraceWizardPage - *

    - * TODO: Implement me. Please. - */ -@SuppressWarnings("restriction") -public class ImportTraceWizardPage extends WizardFileSystemResourceImportPage1 { - - public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) { - super(workbench, selection); - TmfProjectNode folder = (TmfProjectNode) selection.getFirstElement(); - String path = folder.getTracesFolder().getFolder().getFullPath().toOSString(); - setContainerFieldValue(path); - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewExperimentDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewExperimentDialog.java deleted file mode 100644 index 7a8b3f33f8..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/dialogs/NewExperimentDialog.java +++ /dev/null @@ -1,335 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.dialogs; - -import java.lang.reflect.InvocationTargetException; -import java.net.URI; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; -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.tmf.ui.views.project.model.TmfExperimentFolderNode; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.dialogs.SelectionStatusDialog; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup; - -/** - * NewExperimentDialog - * - * This is stripped down version of NewFolderDialog. - */ -@SuppressWarnings("restriction") -public class NewExperimentDialog extends SelectionStatusDialog { - - private Text folderNameField; - private IContainer container; - private boolean firstLinkCheck = true; - private CreateLinkedResourceGroup linkedResourceGroup; - - /** - * Creates a NewFolderDialog - * - * @param parentShell parent of the new dialog - * @param container parent of the new folder - */ - public NewExperimentDialog(Shell parentShell, TmfExperimentFolderNode experimentFolder) { - super(parentShell); - this.container = experimentFolder.getFolder(); - setTitle(""); //$NON-NLS-1$ - setStatusLineAboveButtons(true); - } - - /** - * Creates the folder using the name and link target entered by the user. - * Sets the dialog result to the created folder. - */ - @Override - protected void computeResult() { - } - - /** - * @see org.eclipse.jface.window.Window#create() - */ - @Override - public void create() { - super.create(); - getButton(IDialogConstants.OK_ID).setEnabled(false); - } - - /** - * Creates the widget for advanced options. - * - * @param parent the parent composite - */ - protected void createLinkResourceGroup(Composite parent) { - linkedResourceGroup = new CreateLinkedResourceGroup(IResource.FOLDER, - new Listener() { - @Override - public void handleEvent(Event e) { - validateLinkedResource(); - firstLinkCheck = false; - } - }, new CreateLinkedResourceGroup.IStringValue() { - @Override - public void setValue(String string) { - folderNameField.setText(string); - } - - @Override - public String getValue() { - return folderNameField.getText(); - } - - @Override - public IResource getResource() { - // TODO Auto-generated method stub - return null; - } - }); - } - - /* (non-Javadoc) - * Method declared on Dialog. - */ - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - createFolderNameGroup(composite); - createLinkResourceGroup(composite); - return composite; - } - - /** - * Creates the folder name specification controls. - * - * @param parent the parent composite - */ - private void createFolderNameGroup(Composite parent) { - Font font = parent.getFont(); - Composite folderGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - folderGroup.setLayout(layout); - folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // new folder label - Label folderLabel = new Label(folderGroup, SWT.NONE); - folderLabel.setFont(font); - folderLabel.setText(org.eclipse.linuxtools.tmf.ui.views.project.dialogs.IDEWorkbenchMessages.NewExperimentDialog_ExperimentName + ": "); //$NON-NLS-1$ - - // new folder name entry field - folderNameField = new Text(folderGroup, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - folderNameField.setLayoutData(data); - folderNameField.setFont(font); - folderNameField.addListener(SWT.Modify, new Listener() { - @Override - public void handleEvent(Event event) { - validateLinkedResource(); - } - }); - } - - /** - * Creates a folder resource handle for the folder with the given name. - * The folder handle is created relative to the container specified during - * object creation. - * - * @param folderName the name of the folder resource to create a handle for - * @return the new folder resource handle - */ - private IFolder createFolderHandle(String folderName) { - IWorkspaceRoot workspaceRoot = container.getWorkspace().getRoot(); - IPath folderPath = container.getFullPath().append(folderName); - IFolder folderHandle = workspaceRoot.getFolder(folderPath); - - return folderHandle; - } - - /** - * Creates a new folder with the given name and optionally linking to - * the specified link target. - * - * @param folderName name of the new folder - * @param linkTarget name of the link target folder. may be null. - * @return IFolder the new folder - */ - private IFolder createNewFolder(String folderName, final URI linkTarget) { - final IFolder folderHandle = createFolderHandle(folderName); - - WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { - @Override - public void execute(IProgressMonitor monitor) throws CoreException { - try { - monitor.beginTask("", 2000); //$NON-NLS-1$ - if (monitor.isCanceled()) { - throw new OperationCanceledException(); - } - if (linkTarget == null) { - folderHandle.create(false, true, monitor); - } else { - folderHandle.createLink(linkTarget, IResource.ALLOW_MISSING_LOCAL, monitor); - } - if (monitor.isCanceled()) { - throw new OperationCanceledException(); - } - } finally { - monitor.done(); - } - } - }; - try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); - } catch (InterruptedException exception) { - return null; - } catch (InvocationTargetException exception) { - if (exception.getTargetException() instanceof CoreException) { - ErrorDialog.openError(getShell(), "", null, // no special message //$NON-NLS-1$ - ((CoreException) exception.getTargetException()).getStatus()); - } else { - // CoreExceptions are handled above, but unexpected runtime exceptions and errors may still occur. - IDEWorkbenchPlugin.log(getClass(), "", exception.getTargetException()); //$NON-NLS-1$ - MessageDialog.openError(getShell(), "", //$NON-NLS-1$ - NLS.bind("", exception.getTargetException().getMessage())); //$NON-NLS-1$ - } - return null; - } - return folderHandle; - } - - /** - * Update the dialog's status line to reflect the given status. It is safe to call - * this method before the dialog has been opened. - */ - @Override - protected void updateStatus(IStatus status) { - if (firstLinkCheck && status != null) { - Status newStatus = new Status(IStatus.OK, status.getPlugin(), - status.getCode(), status.getMessage(), status.getException()); - super.updateStatus(newStatus); - } else { - super.updateStatus(status); - } - } - - /** - * Update the dialog's status line to reflect the given status. It is safe to call - * this method before the dialog has been opened. - * @param severity - * @param message - */ - private void updateStatus(int severity, String message) { - updateStatus(new Status(severity, IDEWorkbenchPlugin.IDE_WORKBENCH, severity, message, null)); - } - - /** - * Checks whether the folder name and link location are valid. - * Disable the OK button if the folder name and link location are valid. - * a message that indicates the problem otherwise. - */ - private void validateLinkedResource() { - boolean valid = validateFolderName(); - - if (valid) { - IFolder linkHandle = createFolderHandle(folderNameField.getText()); - IStatus status = linkedResourceGroup.validateLinkLocation(linkHandle); - - if (status.getSeverity() != IStatus.ERROR) { - getOkButton().setEnabled(true); - } else { - getOkButton().setEnabled(false); - } - - if (status.isOK() == false) { - updateStatus(status); - } - } else { - getOkButton().setEnabled(false); - } - } - - /** - * Checks if the folder name is valid. - * - * @return null if the new folder name is valid. - * a message that indicates the problem otherwise. - */ - private boolean validateFolderName() { - String name = folderNameField.getText(); - IWorkspace workspace = container.getWorkspace(); - IStatus nameStatus = workspace.validateName(name, IResource.FOLDER); - - if ("".equals(name)) { //$NON-NLS-1$ - updateStatus(IStatus.ERROR, "Experiment name is empty"); //$NON-NLS-1$ - return false; - } - if (nameStatus.isOK() == false) { - updateStatus(nameStatus); - return false; - } - IPath path = new Path(name); - if (container.getFolder(path).exists() - || container.getFile(path).exists()) { - updateStatus(IStatus.ERROR, NLS.bind("Experiment already exists", name)); //$NON-NLS-1$ - return false; - } - updateStatus(IStatus.OK, ""); //$NON-NLS-1$ - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed() - */ - @Override - protected void okPressed() { - URI linkTarget = linkedResourceGroup.getLinkTargetURI(); - IFolder folder = createNewFolder(folderNameField.getText(), linkTarget); - if (folder == null) { - return; - } - - setSelectionResult(new IFolder[] { folder }); - - super.okPressed(); - } -} \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java deleted file mode 100644 index 4f290619d4..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * CloseProjectHandler - *

    - * TODO: Implement me. Please. - */ -public class CloseProjectHandler extends AbstractHandler { - - private TmfProjectNode fProject = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we are in the Project View - IWorkbenchPage page = window.getActivePage(); - if (page == null || !(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a project is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fProject = (element instanceof TmfProjectNode) ? (TmfProjectNode) element : null; - } - return (fProject != null && fProject.isOpen()); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - if (fProject != null) { - fProject.closeProject(); - fProject.refresh(); - } - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java deleted file mode 100644 index 81fd78fc6f..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.ITmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * DeleteExperimentHandler - *

    - * TODO: Implement me. Please. - */ -public class DeleteExperimentHandler extends AbstractHandler { - - private TmfExperimentNode fExperiment = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if a trace is selected - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a trace is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fExperiment = (element instanceof TmfExperimentNode) ? (TmfExperimentNode) element : null; - } - - return (fExperiment != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - IFolder folder = fExperiment.getFolder(); - ITmfProjectTreeNode parent = fExperiment.getParent(); - try { - parent.removeChild(fExperiment); - parent.refresh(); - folder.delete(true, true, null); - } catch (CoreException e) { - e.printStackTrace(); - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java deleted file mode 100644 index 0279a5dd8a..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.ITmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * DeleteProjectHandler - *

    - * TODO: Implement me. Please. - */ -public class DeleteProjectHandler extends AbstractHandler { - - private TmfProjectNode fProject = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we are in the Project View - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a project is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fProject = (element instanceof TmfProjectNode) ? (TmfProjectNode) element : null; - } - return (fProject != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - IProject project = fProject.getProject(); - ITmfProjectTreeNode parent = fProject.getParent(); - try { - parent.removeChild(fProject); - parent.refresh(); - project.delete(true, true, null); - } catch (CoreException e) { - e.printStackTrace(); - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java deleted file mode 100644 index 3a3f96fbf4..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.ITmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentFolderNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * DeleteTraceHandler - *

    - * TODO: Implement me. Please. - */ -public class DeleteTraceHandler extends AbstractHandler { - - private TmfTraceNode fTrace = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if a trace is selected - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a trace is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fTrace = (element instanceof TmfTraceNode) ? (TmfTraceNode) element : null; - } - - return (fTrace != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - IResource resource = fTrace.getResource(); - ITmfProjectTreeNode parent = fTrace.getParent(); - try { - if (!(parent instanceof TmfExperimentNode)) { - // Delete the trace from every experiment where it appears - TmfExperimentFolderNode experimentFolder = fTrace.getProject().getExperimentsFolder(); - for (ITmfProjectTreeNode experiment : experimentFolder.getChildren()) { - for (int i = 0; i < experiment.getChildren().size(); i++) { - TmfTraceNode trace = (TmfTraceNode) experiment.getChildren().get(i); - if (trace.getResource().getLocation().equals(resource.getLocation())) { - experiment.removeChild(trace); - experiment.refresh(); - trace.getResource().delete(true, null); - } - } - } - } - parent.removeChild(fTrace); - parent.refresh(); - resource.delete(true, null); - } catch (CoreException e) { - e.printStackTrace(); - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java deleted file mode 100644 index 416e247979..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.dialogs.ImportTraceWizard; -import org.eclipse.linuxtools.tmf.ui.views.project.model.ITmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * ImportTraceHandler - *

    - * TODO: Implement me. Please. - */ -public class ImportTraceHandler extends AbstractHandler { - - private TmfProjectNode fProject = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we are in the Project View - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a project is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - if (element instanceof ITmfProjectTreeNode) { - ITmfProjectTreeNode node = (ITmfProjectTreeNode) element; - while (node != null && !(node instanceof TmfProjectNode)) { - node = node.getParent(); - } - fProject = (node instanceof TmfProjectNode) ? (TmfProjectNode) node : null; - } - } - - return (fProject != null && fProject.isOpen() && fProject.isTmfProject()); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Set the selection to the project - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - ProjectView view = (ProjectView) page.getActivePart(); - view.setSelection(fProject); - - // Fire the Import Trace Wizard - IWorkbench workbench = PlatformUI.getWorkbench(); - Shell shell = workbench.getActiveWorkbenchWindow().getShell(); - - ImportTraceWizard wizard = new ImportTraceWizard(); - wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(fProject)); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - - if (dialog.getReturnCode() == Window.OK && fProject != null) { - fProject.refreshChildren(); - fProject.refresh(); - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java deleted file mode 100644 index d40aaaac84..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFolder; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.dialogs.NewExperimentDialog; -import org.eclipse.linuxtools.tmf.ui.views.project.model.ITmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentFolderNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * NewExperimentHandler - *

    - * TODO: Implement me. Please. - */ -public class NewExperimentHandler extends AbstractHandler { - - private TmfProjectNode fProject = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we are in the Project View - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a project is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - if (element instanceof ITmfProjectTreeNode) { - ITmfProjectTreeNode node = (ITmfProjectTreeNode) element; - while (node != null && !(node instanceof TmfProjectNode)) { - node = node.getParent(); - } - fProject = (node instanceof TmfProjectNode) ? (TmfProjectNode) node : null; - } - } - - return (fProject != null && fProject.isOpen() && fProject.isTmfProject()); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Open the experiment creation dialog - TmfExperimentFolderNode experimentFolder = fProject.getExperimentsFolder(); - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - NewExperimentDialog dialog = new NewExperimentDialog(shell, experimentFolder); - dialog.open(); - - if (dialog.getReturnCode() == Window.OK) { - Object[] experiments = dialog.getResult(); - if (experiments[0] instanceof IFolder) { - experimentFolder.addExperiment((IFolder) experiments[0]); - } - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java deleted file mode 100644 index 76ea56351c..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.TmfUiPreferenceInitializer; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.dialogs.NewProjectWizard; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectRoot; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.osgi.service.prefs.BackingStoreException; - -/** - * NewProjectHandler - *

    - * TODO: Implement me. Please. - */ -public class NewProjectHandler extends AbstractHandler { - - private TmfProjectRoot fProjectRoot = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we are in the Project View - IWorkbenchPart part = window.getActivePage().getActivePart(); - if (!(part instanceof ProjectView)) - return false; - - fProjectRoot = ((ProjectView) part).getRoot(); - - return (fProjectRoot != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Fire the New Project Wizard - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - NewProjectWizard wizard = new NewProjectWizard(); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - - // Update the project model - if (dialog.getReturnCode() == Window.OK) { - IProject project = wizard.getProject(); - if (project != null && fProjectRoot != null) { - IEclipsePreferences node = new InstanceScope().getNode(TmfUiPlugin.PLUGIN_ID); - node.put(TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, project.getName()); - try { - node.flush(); - } catch (BackingStoreException e) { - e.printStackTrace(); - } - fProjectRoot.refreshChildren(); - fProjectRoot.refresh(); - } - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java deleted file mode 100644 index b72b186fe2..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * OpenExperimentHandler - *

    - * TODO: Implement me. Please. - */ -public class OpenExperimentHandler extends AbstractHandler { - - private TmfExperimentNode fExperiment = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if a trace is selected - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a trace is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fExperiment = (element instanceof TmfExperimentNode) ? (TmfExperimentNode) element : null; - } - - return (fExperiment != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Set the selection to the project - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - ProjectView projectView = (ProjectView) page.getActivePart(); - - if (projectView != null) { - projectView.selectExperiment(fExperiment); - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java deleted file mode 100644 index a98fdb1f86..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * OpenProjectHandler - *

    - * TODO: Implement me. Please. - */ -public class OpenProjectHandler extends AbstractHandler { - - private TmfProjectNode fProject = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we are in the Project View - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a project is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fProject = (element instanceof TmfProjectNode) ? (TmfProjectNode) element : null; - } - return (fProject != null && !fProject.isOpen()); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - if (fProject != null) { - fProject.openProject(); - fProject.refresh(); - } - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java deleted file mode 100644 index 238c052e0c..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.editors.TmfEditorInput; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; - -/** - * OpenTraceHandler - *

    - * TODO: Implement me. Please. - */ -public class OpenTraceHandler extends AbstractHandler { - - private TmfTraceNode fTrace = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if a trace is selected - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check if a trace is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fTrace = (element instanceof TmfTraceNode) ? (TmfTraceNode) element : null; - } - - return (fTrace != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - IResource resource = fTrace.getResource(); - if (fTrace.getParent() instanceof TmfExperimentNode) { - resource = fTrace.getProject().getTracesFolder().getTraceForLocation(resource.getLocation()).getResource(); - } - - ITmfTrace trace = ParserProviderManager.getTrace(resource); - if (trace == null) { - return null; - } - - try { - IEditorInput editorInput = new TmfEditorInput(resource, trace); - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage(); - - String editorId = ParserProviderManager.getEditorId(resource); - if (resource instanceof IFile) { - IDE.setDefaultEditor((IFile) resource, editorId); - } - IEditorPart editor = activePage.findEditor(editorInput); - if (editor != null && editor instanceof IReusableEditor) { - activePage.reuseEditor((IReusableEditor)editor, editorInput); - activePage.activate(editor); - } else { - editor = activePage.openEditor(editorInput, editorId); - } - - } catch (PartInitException e) { - e.printStackTrace(); - } - -// ITmfTrace[] traces = new ITmfTrace[]{trace}; -// TmfExperiment experiment = new TmfExperiment(TmfEvent.class, resource.getName(), traces, trace.getCacheSize()); -// experiment.indexExperiment(false); -// TmfSignalManager.dispatchSignal(new TmfExperimentSelectedSignal(this, experiment)); - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java deleted file mode 100644 index 3fc51ced6e..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.ITmfProjectTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectRoot; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * RefreshHandler - *

    - * TODO: Implement me. Please. - */ -public class RefreshHandler extends AbstractHandler { - - private TmfProjectRoot fProjectRoot = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we can find the project model root node - ISelection selection = window.getActivePage().getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - if (element instanceof ITmfProjectTreeNode) { - ITmfProjectTreeNode node = (ITmfProjectTreeNode) element; - while (node != null && !(node instanceof TmfProjectRoot)) { - node = node.getParent(); - } - fProjectRoot = (node instanceof TmfProjectRoot) ? (TmfProjectRoot) node : null; - } - } - - return (fProjectRoot != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - try { - root.refreshLocal(IResource.DEPTH_INFINITE, null); - fProjectRoot.refreshChildren(); - } catch (CoreException e) { - throw new ExecutionException("CoreException", e); //$NON-NLS-1$ - } - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java deleted file mode 100644 index 5d2f79a1d9..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.ui.PlatformUI; - -/** - * RenameExperimentHandler - *

    - * TODO: Implement me. Please. - */ -public class RenameExperimentHandler extends AbstractHandler { - - private TmfExperimentNode fExperiment = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - return (fExperiment != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); - mb.setText("Rename Experiment"); //$NON-NLS-1$ - mb.setMessage("Not implemented yet"); //$NON-NLS-1$ - mb.open(); - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java deleted file mode 100644 index 17ee1f375e..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.ui.PlatformUI; - -/** - * RenameProjectHandler - *

    - * TODO: Implement me. Please. - */ -public class RenameProjectHandler extends AbstractHandler { - - private TmfProjectNode fProject = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - -// // Check if we are closing down -// IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); -// if (window == null) -// return false; -// -// // Check if we are in the Project View -// IWorkbenchPage page = window.getActivePage(); -// if (!(page.getActivePart() instanceof ProjectView)) -// return false; -// -// // Check if a project is selected -// ISelection selection = page.getSelection(ProjectView.ID); -// if (selection instanceof StructuredSelection) { -// Object element = ((StructuredSelection) selection).getFirstElement(); -// fProjectNode = (element instanceof TmfProjectNode) ? (TmfProjectNode) element : null; -// } - - return (fProject != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); - mb.setText("Rename Project"); //$NON-NLS-1$ - mb.setMessage("Not implemented yet"); //$NON-NLS-1$ - mb.open(); - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java deleted file mode 100644 index 79ee3b1219..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.ui.PlatformUI; - -/** - * RenameTraceHandler - *

    - * TODO: Implement me. Please. - */ -public class RenameTraceHandler extends AbstractHandler { - - private TmfTraceNode fTrace = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - return (fTrace != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); - mb.setText("Rename Trace"); //$NON-NLS-1$ - mb.setMessage("Not implemented yet"); //$NON-NLS-1$ - mb.open(); - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserContributionItem.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserContributionItem.java deleted file mode 100644 index 2bd508c849..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserContributionItem.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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: - * Patrick Tasse - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.project.handlers; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.CompoundContributionItem; -import org.eclipse.ui.menus.CommandContributionItem; -import org.eclipse.ui.menus.CommandContributionItemParameter; - - -public class SelectParserContributionItem extends CompoundContributionItem { - - private static final ImageDescriptor SELECTED_ICON = ImageDescriptor.createFromImage(TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/bullet.gif")); //$NON-NLS-1$ - - @Override - protected IContributionItem[] getContributionItems() { - Map params; - LinkedList list = new LinkedList(); - - ParserProviderManager.getParserMap(); - - String parser = null; - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - IWorkbenchPage page = window.getActivePage(); - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - if (! (element instanceof TmfTraceNode)) { - return new IContributionItem[0]; - } - TmfTraceNode trace = (TmfTraceNode) element; - IResource resource = trace.getResource(); - if (trace.getParent() instanceof TmfExperimentNode) { - resource = trace.getProject().getTracesFolder().getTraceForLocation(resource.getLocation()).getResource(); - } - try { - parser = resource.getPersistentProperty(ParserProviderManager.PARSER_PROPERTY); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - for(Entry> providerEntry : ParserProviderManager.getParserMap().entrySet()) { - MenuManager subMenu = new MenuManager(providerEntry.getKey()); - for(Entry entry : providerEntry.getValue().entrySet()) { - params = new HashMap(); - params.put("org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.selectparser.parser", entry.getValue()); //$NON-NLS-1$ - - ImageDescriptor icon = null; - if (entry.getValue().equals(parser)) { - icon = SELECTED_ICON; - } - - CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), - "my.parameterid", //$NON-NLS-1$ - "org.eclipse.linuxtools.tmf.ui.command.project.trace.selectparser", //$NON-NLS-1$ - params, - icon, // icon - null, // disabled icon - null, // hover icon - entry.getKey().replaceAll("&", "&&"), // label //$NON-NLS-1$//$NON-NLS-2$ - null, // mnemonic - null, // tooltip - CommandContributionItem.STYLE_PUSH, - null, // help context id - true // visibleEnable - ); - - subMenu.add(new CommandContributionItem(param)); - } - list.add(subMenu); - } - - return (IContributionItem[]) list.toArray(new IContributionItem[list.size()]); - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java deleted file mode 100644 index b3a4c25b59..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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: - * Patrick Tasse - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.tmf.event.TmfEvent; -import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; -import org.eclipse.linuxtools.tmf.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; -import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceParserUpdatedSignal; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * OpenTraceHandler - *

    - */ -public class SelectParserHandler extends AbstractHandler { - - private TmfTraceNode fTrace = null; - private ProjectView fProjectView = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if a trace is selected - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - fProjectView = (ProjectView) page.getActivePart(); - - // Check if a trace is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fTrace = (element instanceof TmfTraceNode) ? (TmfTraceNode) element : null; - } - - return (fTrace != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - @SuppressWarnings("unchecked") - public Object execute(ExecutionEvent event) throws ExecutionException { - IResource resource = fTrace.getResource(); - if (fTrace.getParent() instanceof TmfExperimentNode) { - resource = fTrace.getProject().getTracesFolder().getTraceForLocation(resource.getLocation()).getResource(); - } - String parser = event.getParameter("org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.selectparser.parser"); //$NON-NLS-1$ - try { - resource.setPersistentProperty(ParserProviderManager.PARSER_PROPERTY, parser); - fProjectView.broadcast(new TmfTraceParserUpdatedSignal(fProjectView, resource)); - fTrace.getProject().refresh(); - - TmfExperiment currentExperiment = (TmfExperiment) TmfExperiment.getCurrentExperiment(); - if (currentExperiment != null) { - for (int i = 0; i < currentExperiment.getTraces().length; i++) { - ITmfTrace trace = currentExperiment.getTraces()[i]; - if (resource.getLocation().toOSString().equals(trace.getPath())) { - ITmfTrace newTrace = ParserProviderManager.getTrace(resource); - if (newTrace != null) { - currentExperiment.getTraces()[i] = newTrace; - fProjectView.broadcast(new TmfExperimentSelectedSignal(new Object(), currentExperiment)); - } - } - } - } - } catch (CoreException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java deleted file mode 100644 index afb1ed8907..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.dialogs.AddTraceWizard; -import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * SelectTracesHandler - *

    - * TODO: Implement me. Please. - */ -public class SelectTracesHandler extends AbstractHandler { - - private TmfExperimentNode fExperiment = null; - - // ------------------------------------------------------------------------ - // Validation - // ------------------------------------------------------------------------ - - @Override - public boolean isEnabled() { - - // Check if we are closing down - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return false; - - // Check if we are in the Project View - IWorkbenchPage page = window.getActivePage(); - if (!(page.getActivePart() instanceof ProjectView)) - return false; - - // Check that an experiment is selected - ISelection selection = page.getSelection(ProjectView.ID); - if (selection instanceof StructuredSelection) { - Object element = ((StructuredSelection) selection).getFirstElement(); - fExperiment = (element instanceof TmfExperimentNode) ? (TmfExperimentNode) element : null; - } - - return (fExperiment != null); - } - - // ------------------------------------------------------------------------ - // Execution - // ------------------------------------------------------------------------ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Open the trace addition wizard - IWorkbench workbench = PlatformUI.getWorkbench(); - Shell shell = workbench.getActiveWorkbenchWindow().getShell(); - - AddTraceWizard wizard = new AddTraceWizard(fExperiment.getProject(), fExperiment); - wizard.init(PlatformUI.getWorkbench(), null); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - - return null; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/ITmfProjectTreeNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/ITmfProjectTreeNode.java deleted file mode 100644 index e890a577c5..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/ITmfProjectTreeNode.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.util.List; - -/** - * ITmfProjectTreeNode - *

    - * TODO: Implement me. Please. - * TODO: Make ITmfProjectTreeNode extends IAdaptable - */ -public interface ITmfProjectTreeNode { - - public String getName(); - - public ITmfProjectTreeNode getParent(); - - public boolean hasChildren(); - - public List getChildren(); - - public void removeChild(ITmfProjectTreeNode child); - - public void removeChildren(); - - public void refreshChildren(); - - public void refresh(); - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentFolderNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentFolderNode.java deleted file mode 100644 index 460fd6b92b..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentFolderNode.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.lang.reflect.Array; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; - -/** - * TmfExperimentFolderNode - *

    - * TODO: Implement me. Please. - */ -public class TmfExperimentFolderNode extends TmfProjectTreeNode { - - private final IFolder fExperimentFolder; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - public TmfExperimentFolderNode(IFolder folder) { - this(null, folder); - } - - public TmfExperimentFolderNode(ITmfProjectTreeNode parent, IFolder folder) { - super(parent); - fExperimentFolder = folder; - } - - // ------------------------------------------------------------------------ - // TmfProjectTreeNode - // ------------------------------------------------------------------------ - - @Override - public String getName() { - return fExperimentFolder.getName(); - } - - @Override - public void refreshChildren() { - try { - IResource[] resources = fExperimentFolder.members(); - for (IResource resource : resources) { - if (resource instanceof IFolder) { - TmfExperimentNode node = find(resource.getName()); - if (node == null) { - node = new TmfExperimentNode(this, (IFolder) resource); - fChildren.add(node); - } - } - } - for (ITmfProjectTreeNode node : fChildren) { - if (exists(node.getName(), resources)) { - node.refreshChildren(); - } - else { - fChildren.remove(node); - } - } - } catch (CoreException e) { - } - } - - private TmfExperimentNode find(String name) { - for (ITmfProjectTreeNode node : fChildren) { - if (node instanceof TmfExperimentNode && node.getName().equals(name)) { - return (TmfExperimentNode) node; - } - } - return null; - } - - private boolean exists(String name, IResource[] resources) { - for (IResource resource : resources) { - if (resource.getName().equals(name)) - return true; - } - return false; - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * @return - */ - public TmfProjectNode getProject() { - return (TmfProjectNode) getParent(); - } - - /** - * @return - */ - public IFolder getFolder() { - return fExperimentFolder; - } - - /** - * @return - */ - public TmfExperimentNode[] getExperiments() { - TmfExperimentNode[] result = (TmfExperimentNode[]) Array.newInstance(TmfExperimentNode.class, fChildren.size()); - return fChildren.toArray(result); - } - - // ------------------------------------------------------------------------ - // Modifiers - // ------------------------------------------------------------------------ - -// No longer needed: handled by the IResourceChangeListener in the View - public void addExperiment(IFolder experiment) { -// TmfExperimentNode node = new TmfExperimentNode(this, experiment); -// fChildren.add(node); -// refresh(); - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentNode.java deleted file mode 100644 index 089ba73040..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfExperimentNode.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.lang.reflect.Array; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; - -/** - * TmfExperimentNode - *

    - * TODO: Implement me. Please. - */ -public class TmfExperimentNode extends TmfProjectTreeNode { - - private final IFolder fExperiment; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - public TmfExperimentNode(IFolder resource) { - this(null, resource); - } - - public TmfExperimentNode(ITmfProjectTreeNode parent, IFolder folder) { - super(parent); - fExperiment = folder; - } - - // ------------------------------------------------------------------------ - // TmfProjectTreeNode - // ------------------------------------------------------------------------ - - @Override - public String getName() { - return fExperiment.getName(); - } - - @Override - public void refreshChildren() { - try { - IResource[] resources = fExperiment.members(0); - for (IResource resource : resources) { - TmfTraceNode node = find(resource.getName()); - if (node == null) { - node = new TmfTraceNode(this, resource); - fChildren.add(node); - } - } - for (ITmfProjectTreeNode node : fChildren) { - if (!exists(node.getName(), resources)) { - fChildren.remove(node); - } - } - } catch (CoreException e) { - } - } - - private TmfTraceNode find(String name) { - for (ITmfProjectTreeNode node : fChildren) { - if (node instanceof TmfTraceNode && node.getName().equals(name)) { - return (TmfTraceNode) node; - } - } - return null; - } - - private boolean exists(String name, IResource[] resources) { - for (IResource resource : resources) { - if (resource.getName().equals(name)) - return true; - } - return false; - } - - // ------------------------------------------------------------------------ - // Modifiers - // ------------------------------------------------------------------------ - -// No longer needed: handled by the IResourceChangeListener in the View - public void addTrace(IResource trace) { -// TmfTraceNode node = new TmfTraceNode(this, trace); -// fChildren.add(node); -// refresh(); - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * @return - */ - public IFolder getFolder() { - return fExperiment; - } - - /** - * @return - */ - public TmfTraceNode[] getTraces() { - TmfTraceNode[] result = (TmfTraceNode[]) Array.newInstance(TmfTraceNode.class, fChildren.size()); - return fChildren.toArray(result); - } - - /** - * @return - */ - public TmfProjectNode getProject() { - return (TmfProjectNode) getParent().getParent(); - } - -} \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectContentProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectContentProvider.java deleted file mode 100644 index 54fbf6f230..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectContentProvider.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * TmfProjectContentProvider - *

    - * TODO: Implement me. Please. - */ - public class TmfProjectContentProvider implements ITreeContentProvider { - - @Override - public Object[] getChildren(Object parentElement) { - return ((ITmfProjectTreeNode) parentElement).getChildren().toArray(); - } - - @Override - public Object getParent(Object element) { - return ((ITmfProjectTreeNode) element).getParent(); - } - - @Override - public boolean hasChildren(Object element) { - return ((ITmfProjectTreeNode) element).hasChildren(); - } - - @Override - public Object[] getElements(Object inputElement) { - if (inputElement instanceof TmfProjectRoot) { - return ((TmfProjectRoot) inputElement).getChildren().toArray(); - } - return null; - } - - @Override - public void dispose() { - // TODO Auto-generated method stub - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // TODO Auto-generated method stub - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectLabelProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectLabelProvider.java deleted file mode 100644 index d927e69767..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectLabelProvider.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.net.URL; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; -import org.eclipse.linuxtools.tmf.ui.TmfUiPreferenceInitializer; -import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * TmfProjectLabelProvider - *

    - * TODO: Implement me. Please. - * TODO: Find proper icons for traces and experiments - */ -public class TmfProjectLabelProvider implements ILabelProvider { - - private final String fTraceIconFile = "icons/eview16/events_view.gif"; //$NON-NLS-1$ -// private final String fExperimentIconFile = "icons/garland16.png"; //$NON-NLS-1$ - - private final Image fOpenedProjectIcon; - private final Image fClosedProjectIcon; - private final Image fFolderIcon; - private final Image fTraceIcon; - private final Image fUnknownTraceIcon; - private final Image fExperimentIcon; - - /** - * - */ - public TmfProjectLabelProvider() { - - fOpenedProjectIcon = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT); - fClosedProjectIcon = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED); - fFolderIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); - - fTraceIcon = loadIcon(fTraceIconFile); - fUnknownTraceIcon = TmfUiPlugin.getDefault().getImageFromPath("icons/elcl16/unknown_parser.gif"); //$NON-NLS-1$ - fExperimentIcon = fFolderIcon; // loadIcon(fExperimentIconFile); - } - - private Image loadIcon(String url) { - TmfUiPlugin plugin = TmfUiPlugin.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) - */ - @Override - public Image getImage(Object element) { - - if (element instanceof TmfProjectNode) { - TmfProjectNode project = (TmfProjectNode) element; - if (project.isOpen()) { - IEclipsePreferences node = new InstanceScope().getNode(TmfUiPlugin.PLUGIN_ID); - if (node.get(TmfUiPreferenceInitializer.ACTIVE_PROJECT_PREFERENCE, TmfUiPreferenceInitializer.ACTIVE_PROJECT_DEFAULT) - .equals(project.getName())) { - return fTraceIcon; //PATA placeholder image should be a highlighted open project - } else { - return fOpenedProjectIcon; - } - } else { - return fClosedProjectIcon; - } - } - - if (element instanceof TmfTraceFolderNode) { - return fFolderIcon; - } - - if (element instanceof TmfTraceNode) { - try { - TmfTraceNode trace = (TmfTraceNode) element; - IResource resource = trace.getResource(); - if (trace.getParent() instanceof TmfExperimentNode) { - TmfExperimentNode experiment = (TmfExperimentNode)trace.getParent(); - TmfTraceFolderNode traceFolder = experiment.getProject().getTracesFolder(); - resource = traceFolder.getFolder().findMember(resource.getName()); - } - - if (resource != null && resource.getPersistentProperty(ParserProviderManager.PARSER_PROPERTY) != null) { - return fTraceIcon; - } - } catch (CoreException e) { - e.printStackTrace(); - } - return fUnknownTraceIcon; - } - - if (element instanceof TmfExperimentFolderNode) { - return fFolderIcon; - } - - if (element instanceof TmfExperimentNode) { - return fExperimentIcon; - } - - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - @Override - public String getText(Object element) { - ITmfProjectTreeNode node = (ITmfProjectTreeNode) element; - String label = node.getName(); - if (node instanceof TmfTraceFolderNode || - node instanceof TmfExperimentFolderNode || - node instanceof TmfExperimentNode) - { - label += " [" + node.getChildren().size() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ - } - return label; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - @Override - public void addListener(ILabelProviderListener listener) { - // TODO Auto-generated method stub - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - @Override - public void dispose() { - // TODO Auto-generated method stub - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) - */ - @Override - 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) - */ - @Override - public void removeListener(ILabelProviderListener listener) { - // TODO Auto-generated method stub - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectNode.java deleted file mode 100644 index 6192523087..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectNode.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.linuxtools.tmf.ui.views.project.TmfProjectNature; - -/** - * TmfProjectNode - *

    - * TODO: Implement me. Please. - */ -public class TmfProjectNode extends TmfProjectTreeNode { - - public static final String TRACE_FOLDER_NAME = "Traces"; //$NON-NLS-1$ - public static final String EXPER_FOLDER_NAME = "Experiments"; //$NON-NLS-1$ - - private final IProject fProject; - private boolean fIsTmfProject; - private boolean fIsOpen; - private TmfTraceFolderNode fTracesFolder; - private TmfExperimentFolderNode fExperimentsFolder; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - public TmfProjectNode(IProject project) { - this(null, project); - } - - public TmfProjectNode(ITmfProjectTreeNode parent, IProject project) { - super(parent); - fProject = project; - updateState(); - } - - // ------------------------------------------------------------------------ - // TmfProjectTreeNode - // ------------------------------------------------------------------------ - - @Override - public String getName() { - return fProject.getName(); - } - - @Override - public void refreshChildren() { - - if (!(fIsOpen && fIsTmfProject)) - return; - - try { - IResource[] resources = fProject.members(); - for (IResource resource : resources) { - if (resource.getType() == IResource.FOLDER) { - String name = resource.getName(); - if (name.equals(TRACE_FOLDER_NAME) && !isIncluded(true, name, fChildren)) { - fTracesFolder = new TmfTraceFolderNode(this, (IFolder) resource); - fChildren.add(fTracesFolder); - } else - if (name.equals(EXPER_FOLDER_NAME) && !isIncluded(false, name, fChildren)) { - fExperimentsFolder = new TmfExperimentFolderNode(this, (IFolder) resource); - fChildren.add(fExperimentsFolder); - } - } - } - List toRemove = new ArrayList(); - for (ITmfProjectTreeNode node : fChildren) { - if (exists(node.getName(), resources)) { - node.refreshChildren(); - } - else { - toRemove.add(node); - } - } - for (ITmfProjectTreeNode node : toRemove) { - fChildren.remove(node); - } - - } catch (CoreException e) { - } - } - - private boolean isIncluded(boolean isTraces, String name, List list) { - boolean found = false; - for (ITmfProjectTreeNode node : list) { - if (node instanceof TmfTraceFolderNode && isTraces) { - found |= node.getName().equals(name); - } else - if (node instanceof TmfExperimentFolderNode && !isTraces) { - found |= node.getName().equals(name); - } - } - return found; - } - - private boolean exists(String name, IResource[] resources) { - for (IResource resource : resources) { - if (resource.getName().equals(name)) - return true; - } - return false; - } - - // ------------------------------------------------------------------------ - // Modifiers - // ------------------------------------------------------------------------ - - public void openProject() { - try { - fProject.open(null); - updateState(); - refreshChildren(); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - public void closeProject() { - try { - fProject.close(null); - updateState(); - removeChildren(); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - private boolean isTmfProject(IProject project) { - boolean result = false; - if (project != null && project.isAccessible()) { - try { - result = project.hasNature(TmfProjectNature.ID); - } catch (CoreException e) { - } - } - return result; - } - - public void updateState() { - fIsOpen = (fProject != null) ? fProject.isAccessible() : false; - if (!fIsOpen) { - removeChildren(); - } - fIsTmfProject = isTmfProject(fProject); - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * @return - */ - public boolean isTmfProject() { - return fIsTmfProject; - } - - /** - * @return - */ - public boolean isOpen() { - return fIsOpen; - } - - /** - * @return - */ - public IProject getProject() { - return fProject; - } - - /** - * @return - */ - public TmfTraceFolderNode getTracesFolder() { - return fTracesFolder; - } - - /** - * @return - */ - public TmfExperimentFolderNode getExperimentsFolder() { - return fExperimentsFolder; - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectRoot.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectRoot.java deleted file mode 100644 index cdeae34ad3..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectRoot.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView; -import org.eclipse.linuxtools.tmf.ui.views.project.TmfProjectNature; - -/** - * TmfProjectRoot - *

    - * TODO: Implement me. Please. - */ -public class TmfProjectRoot extends TmfProjectTreeNode { - - private final ProjectView fView; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - public TmfProjectRoot(ProjectView view) { - super(null); - fView = view; - refreshChildren(); - } - - @Override - public void refresh() { - fView.refresh(); - } - - // ------------------------------------------------------------------------ - // TmfProjectTreeNode - // ------------------------------------------------------------------------ - - @Override - public String getName() { - return null; - } - - @Override - public void refreshChildren() { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject[] projects = root.getProjects(); - for (IProject project : projects) { - if (!project.isOpen() || isTmfProject(project)) { - TmfProjectNode node = find(project.getName()); - if (node == null) { - node = new TmfProjectNode(this, project); - fChildren.add(node); - } else { - node.updateState(); - } - } - } - List toRemove = new ArrayList(); - for (ITmfProjectTreeNode node : fChildren) { - if (exists(node.getName(), projects)) { - node.refreshChildren(); - } else { - toRemove.add(node); - } - } - for (ITmfProjectTreeNode node : toRemove) { - fChildren.remove(node); - } - } - - private TmfProjectNode find(String name) { - for (ITmfProjectTreeNode node : fChildren) { - if (node instanceof TmfProjectNode && node.getName().equals(name)) { - return (TmfProjectNode) node; - } - } - return null; - } - - private boolean exists(String name, IProject[] projects) { - for (IProject project : projects) { - if (project.getName().equals(name) && (!project.isOpen() || isTmfProject(project))) - return true; - } - return false; - } - - private boolean isTmfProject(IProject project) { - if (project.isOpen()) { - IProjectNature nature; - try { - nature = project.getNature(TmfProjectNature.ID); - if (nature instanceof TmfProjectNature) { - return true; - } - } catch (CoreException e) { - e.printStackTrace(); - } - } - return false; - } -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectTreeNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectTreeNode.java deleted file mode 100644 index c6367e2448..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfProjectTreeNode.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.util.ArrayList; -import java.util.List; - -/** - * TmfProjectTreeNode - *

    - * TODO: Implement me. Please. - */ -public abstract class TmfProjectTreeNode implements ITmfProjectTreeNode { - - protected ITmfProjectTreeNode fParent = null; - protected List fChildren = null; - - // ------------------------------------------------------------------------ - // Constructor - // ------------------------------------------------------------------------ - - public TmfProjectTreeNode(ITmfProjectTreeNode parent) { - fParent = parent; - fChildren = new ArrayList(); - } - - @Override - public String toString() { - return getName(); - } - - // ------------------------------------------------------------------------ - // ITmfProjectTreeNode - // ------------------------------------------------------------------------ - - @Override - public ITmfProjectTreeNode getParent() { - return fParent; - } - - @Override - public boolean hasChildren() { - return fChildren.size() > 0; - } - - @Override - public List getChildren() { - return fChildren; - } - - @Override - public abstract void refreshChildren(); - - @Override - public void refresh() { - fParent.refresh(); - } - - @Override - public void removeChild(ITmfProjectTreeNode child) { - for (ITmfProjectTreeNode node : fChildren) { - if (node == child) { - node.removeChildren(); - // We can do it since we are returning right away - fChildren.remove(node); - return; - } - } - } - - @Override - public void removeChildren() { - for (ITmfProjectTreeNode node : fChildren) { - node.removeChildren(); - } - fChildren.clear(); - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceFolderNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceFolderNode.java deleted file mode 100644 index ec193f3215..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceFolderNode.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import java.lang.reflect.Array; -import java.util.Iterator; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; - -/** - * TmfTraceFolderNode - *

    - * TODO: Implement me. Please. - */ -public class TmfTraceFolderNode extends TmfProjectTreeNode { - - private final IFolder fTraceFolder; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - public TmfTraceFolderNode(IFolder folder) { - this(null, folder); - } - - public TmfTraceFolderNode(ITmfProjectTreeNode parent, IFolder folder) { - super(parent); - fTraceFolder = folder; - } - - // ------------------------------------------------------------------------ - // TmfProjectTreeNode - // ------------------------------------------------------------------------ - - @Override - public String getName() { - return fTraceFolder.getName(); - } - - @Override - public void refreshChildren() { - try { - IResource[] resources = fTraceFolder.members(); - for (IResource resource : resources) { - TmfTraceNode node = find(resource.getName()); - if (node == null) { - node = new TmfTraceNode(this, resource); - fChildren.add(node); - } - } - Iterator iterator = fChildren.iterator(); - while (iterator.hasNext()) { - ITmfProjectTreeNode node = iterator.next(); - if (!exists(node.getName(), resources)) { - iterator.remove(); - } - } - } catch (CoreException e) { - } - } - - private TmfTraceNode find(String name) { - for (ITmfProjectTreeNode node : fChildren) { - if (node instanceof TmfTraceNode && node.getName().equals(name)) { - return (TmfTraceNode) node; - } - } - return null; - } - - private boolean exists(String name, IResource[] resources) { - for (IResource resource : resources) { - if (resource.getName().equals(name)) - return true; - } - return false; - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * @return - */ - public TmfProjectNode getProject() { - return (TmfProjectNode) getParent(); - } - - /** - * @return - */ - public IFolder getFolder() { - return fTraceFolder; - } - - /** - * @return - */ - public TmfTraceNode[] getTraces() { - TmfTraceNode[] result = (TmfTraceNode[]) Array.newInstance(TmfTraceNode.class, fChildren.size()); - return fChildren.toArray(result); - } - - /** - * @return - */ - public TmfTraceNode getTraceForLocation(IPath location) { - for (ITmfProjectTreeNode node : fChildren) { - TmfTraceNode trace = (TmfTraceNode) node; - if (trace.getResource().getLocation().equals(location)) { - return trace; - } - } - return null; - } - - // ------------------------------------------------------------------------ - // Modifiers - // ------------------------------------------------------------------------ - -// No longer needed: handled by the IResourceChangeListener in the View - public void addTrace(IFolder trace) { -// TmfTraceNode node = new TmfTraceNode(this, trace); -// fChildren.add(node); -// refresh(); - } - -} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceNode.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceNode.java deleted file mode 100644 index 2ce68d4360..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/model/TmfTraceNode.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * 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.tmf.ui.views.project.model; - -import org.eclipse.core.resources.IResource; - -/** - * TmfTraceNode - *

    - * TODO: Implement me. Please. - */ -public class TmfTraceNode extends TmfProjectTreeNode { - - private final IResource fTrace; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - public TmfTraceNode(IResource trace) { - this(null, trace); - } - - public TmfTraceNode(ITmfProjectTreeNode parent, IResource trace) { - super(parent); - fTrace = trace; - } - - // ------------------------------------------------------------------------ - // TmfProjectTreeNode - // ------------------------------------------------------------------------ - - @Override - public String getName() { - return fTrace.getName(); - } - - @Override - public void refreshChildren() { - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * @return - */ - public TmfProjectNode getProject() { - ITmfProjectTreeNode node = this; - while (node != null) { - node = node.getParent(); - if (node instanceof TmfProjectNode) { - return (TmfProjectNode) node; - } - } - return null; - } - - /** - * @return - */ - public IResource getResource() { - return fTrace; - } - -} diff --git a/org.eclipse.linuxtools.tmf/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf/META-INF/MANIFEST.MF index eee744a326..a433b30b1e 100644 --- a/org.eclipse.linuxtools.tmf/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name -Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core +Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core;singleton:=true Bundle-Version: 0.3.2.qualifier Bundle-Activator: org.eclipse.linuxtools.tmf.TmfCorePlugin Bundle-Vendor: %Bundle-Vendor @@ -24,3 +24,4 @@ Export-Package: org.eclipse.linuxtools.tmf, org.eclipse.linuxtools.tmf.uml2sd, org.eclipse.linuxtools.tmf.util Bundle-Localization: plugin +Import-Package: org.eclipse.core.filesystem.provider diff --git a/org.eclipse.linuxtools.tmf/build.properties b/org.eclipse.linuxtools.tmf/build.properties index a87fc4bfd1..00e586480b 100644 --- a/org.eclipse.linuxtools.tmf/build.properties +++ b/org.eclipse.linuxtools.tmf/build.properties @@ -1,6 +1,8 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ + plugin.xml,\ plugin.properties,\ - about.html,\ + about.html,\ . + \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf/plugin.properties b/org.eclipse.linuxtools.tmf/plugin.properties index 5d5b4c5ebe..d1662a825a 100644 --- a/org.eclipse.linuxtools.tmf/plugin.properties +++ b/org.eclipse.linuxtools.tmf/plugin.properties @@ -1,3 +1,3 @@ #Properties file for org.eclipse.linuxtools.tmf Bundle-Vendor = Eclipse Linux Tools -Bundle-Name = TMF Core \ No newline at end of file +Bundle-Name = TMF Core diff --git a/org.eclipse.linuxtools.tmf/plugin.xml b/org.eclipse.linuxtools.tmf/plugin.xml new file mode 100644 index 0000000000..f4c52fd5d4 --- /dev/null +++ b/org.eclipse.linuxtools.tmf/plugin.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/org.eclipse.linuxtools.tmf/schema/org.eclipse.linuxtools.tmf.tracetype.exsd b/org.eclipse.linuxtools.tmf/schema/org.eclipse.linuxtools.tmf.tracetype.exsd new file mode 100644 index 0000000000..36d8429196 --- /dev/null +++ b/org.eclipse.linuxtools.tmf/schema/org.eclipse.linuxtools.tmf.tracetype.exsd @@ -0,0 +1,211 @@ + + + + + + + + + This extension point is used to contribute new trace types to the generic components of the TMF framework. + + + + + + + + + + + + + + + + + + a fully qualified identifier of the target extension point + + + + + + + an optional identifier of the extension instance + + + + + + + an optional name of the extension instance + + + + + + + + + + + + + + + a unique name that will be used to identify this category + + + + + + + a translatable name that will be used in the UI for this category + + + + + + + + + + + + + + + + The unique ID that identifies this trace type. + + + + + + + The type name as it is displayed to the end user. + + + + + + + an optional attribute that is composed of the category ID. The referenced category must be declared in a corresponding category element. + + + + + + + + + + The fully qualified name of a class that implements the <samp>ITmfTrace</samp> interface. + + + + + + + + + + The fully qualified name of a class that extends <samp>TmfEvent</samp> . + + + + + + + + + + The icon associated to the trace type. + + + + + + + + + + + + + The default editor to use for this trace type. +If omitted, the trace will open in the Events view. + + + + + + + The id of the editor to use for this trace type. +If empty, the trace will open in the Events view. + + + + + + + + + + The events table to use for this trace type. +If omitted, the default events table will be used. + + + + + + + The fully qualified name of a class that extends <samp>TmfEventsTable</samp> . +If empty, the default events table will be used. + + + + + + + + + + + + + + + 0.9 + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java index 3f2eb12d28..9c8393220e 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson + * Copyright (c) 2009, 2010, 2011 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -29,6 +29,7 @@ public class TmfCorePlugin extends Plugin { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf"; //$NON-NLS-1$ + public static final String TMF_TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.tracetype"; //$NON-NLS-1$ // The shared instance private static TmfCorePlugin fPlugin; @@ -37,9 +38,6 @@ public class TmfCorePlugin extends Plugin { // Constructors // ------------------------------------------------------------------------ - /** - * The constructor - */ public TmfCorePlugin() { setDefault(this); } @@ -48,22 +46,16 @@ public class TmfCorePlugin extends Plugin { // Accessors // ------------------------------------------------------------------------ - /** - * @return the shared instance - */ public static TmfCorePlugin getDefault() { return fPlugin; } - /** - * @param plugin the shared instance - */ private static void setDefault(TmfCorePlugin plugin) { fPlugin = plugin; } // ------------------------------------------------------------------------ - // Operations + // Plugin // ------------------------------------------------------------------------ @Override diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/TmfProjectNature.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfProjectNature.java similarity index 67% rename from org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/TmfProjectNature.java rename to org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfProjectNature.java index 190ee95353..d219c1af2c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/TmfProjectNature.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfProjectNature.java @@ -10,7 +10,7 @@ * Francois Chouinard - Initial API and implementation *******************************************************************************/ -package org.eclipse.linuxtools.tmf.ui.views.project; +package org.eclipse.linuxtools.tmf; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectNature; @@ -19,7 +19,7 @@ import org.eclipse.core.runtime.CoreException; /** * TmfProjectNature *

    - * This is really a marker for the Tmf projects. + * This is really a marker for the tracing projects. */ public class TmfProjectNature implements IProjectNature { @@ -27,35 +27,19 @@ public class TmfProjectNature implements IProjectNature { private IProject fProject; - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#configure() - */ @Override public void configure() throws CoreException { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#deconfigure() - */ @Override public void deconfigure() throws CoreException { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#getProject() - */ @Override public IProject getProject() { return fProject; } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) - */ @Override public void setProject(IProject project) { fProject = project; diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java index 3b6f7618d4..bf86f2f28f 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java @@ -15,173 +15,176 @@ import org.eclipse.linuxtools.tmf.signal.TmfSignal; @SuppressWarnings("nls") public class Tracer { - private static String pluginID = TmfCorePlugin.PLUGIN_ID; - - static Boolean ERROR = Boolean.FALSE; - static Boolean WARNING = Boolean.FALSE; - static Boolean INFO = Boolean.FALSE; - - static Boolean COMPONENT = Boolean.FALSE; - static Boolean REQUEST = Boolean.FALSE; - static Boolean SIGNAL = Boolean.FALSE; - static Boolean EVENT = Boolean.FALSE; - - private static String LOGNAME = "trace.log"; - private static BufferedWriter fTraceLog = null; - - private static BufferedWriter openLogFile(String filename) { - BufferedWriter outfile = null; - try { - outfile = new BufferedWriter(new FileWriter(filename)); - } catch (IOException e) { - e.printStackTrace(); - } - return outfile; - } - - public static void init() { - - String traceKey; - boolean isTracing = false; - - traceKey = Platform.getDebugOption(pluginID + "/error"); - if (traceKey != null) { - ERROR = (Boolean.valueOf(traceKey)).booleanValue(); - isTracing |= ERROR; - } - - traceKey = Platform.getDebugOption(pluginID + "/warning"); - if (traceKey != null) { - WARNING = (Boolean.valueOf(traceKey)).booleanValue(); - isTracing |= WARNING; - } - - traceKey = Platform.getDebugOption(pluginID + "/info"); - if (traceKey != null) { - INFO = (Boolean.valueOf(traceKey)).booleanValue(); - isTracing |= INFO; - } - - traceKey = Platform.getDebugOption(pluginID + "/component"); - if (traceKey != null) { - COMPONENT = (Boolean.valueOf(traceKey)).booleanValue(); - isTracing |= COMPONENT; - } - - traceKey = Platform.getDebugOption(pluginID + "/request"); - if (traceKey != null) { - REQUEST = (Boolean.valueOf(traceKey)).booleanValue(); - isTracing |= REQUEST; - } - - traceKey = Platform.getDebugOption(pluginID + "/signal"); - if (traceKey != null) { - SIGNAL = (Boolean.valueOf(traceKey)).booleanValue(); - isTracing |= SIGNAL; - } - - traceKey = Platform.getDebugOption(pluginID + "/event"); - if (traceKey != null) { - EVENT = (Boolean.valueOf(traceKey)).booleanValue(); - isTracing |= EVENT; - } - - // Create trace log file if needed - if (isTracing) { - fTraceLog = openLogFile(LOGNAME); - } - } - - public static void stop() { - if (fTraceLog == null) - return; - - try { - fTraceLog.close(); - fTraceLog = null; - } catch (IOException e) { - e.printStackTrace(); - } - } - - // Predicates - public static boolean isErrorTraced() { - return ERROR; - } - - public static boolean isComponentTraced() { - return COMPONENT; - } - - public static boolean isRequestTraced() { - return REQUEST; - } - - public static boolean isSignalTraced() { - return SIGNAL; - } - - public static boolean isEventTraced() { - return EVENT; - } - - // Tracers - public static void trace(String msg) { - long currentTime = System.currentTimeMillis(); - StringBuilder message = new StringBuilder("["); - message.append(currentTime / 1000); - message.append("."); - message.append(String.format("%1$03d", currentTime % 1000)); - message.append("] "); - message.append(msg); + private static String pluginID = TmfCorePlugin.PLUGIN_ID; + + static Boolean ERROR = Boolean.FALSE; + static Boolean WARNING = Boolean.FALSE; + static Boolean INFO = Boolean.FALSE; + + static Boolean COMPONENT = Boolean.FALSE; + static Boolean REQUEST = Boolean.FALSE; + static Boolean SIGNAL = Boolean.FALSE; + static Boolean EVENT = Boolean.FALSE; + + private static String LOGNAME = "trace.log"; + private static BufferedWriter fTraceLog = null; + + private static BufferedWriter openLogFile(String filename) { + BufferedWriter outfile = null; + try { + outfile = new BufferedWriter(new FileWriter(filename)); + } catch (IOException e) { + e.printStackTrace(); + } + return outfile; + } + + public static void init() { + + String traceKey; + boolean isTracing = false; + + traceKey = Platform.getDebugOption(pluginID + "/error"); + if (traceKey != null) { + ERROR = (Boolean.valueOf(traceKey)).booleanValue(); + isTracing |= ERROR; + } + + traceKey = Platform.getDebugOption(pluginID + "/warning"); + if (traceKey != null) { + WARNING = (Boolean.valueOf(traceKey)).booleanValue(); + isTracing |= WARNING; + } + + traceKey = Platform.getDebugOption(pluginID + "/info"); + if (traceKey != null) { + INFO = (Boolean.valueOf(traceKey)).booleanValue(); + isTracing |= INFO; + } + + traceKey = Platform.getDebugOption(pluginID + "/component"); + if (traceKey != null) { + COMPONENT = (Boolean.valueOf(traceKey)).booleanValue(); + isTracing |= COMPONENT; + } + + traceKey = Platform.getDebugOption(pluginID + "/request"); + if (traceKey != null) { + REQUEST = (Boolean.valueOf(traceKey)).booleanValue(); + isTracing |= REQUEST; + } + + traceKey = Platform.getDebugOption(pluginID + "/signal"); + if (traceKey != null) { + SIGNAL = (Boolean.valueOf(traceKey)).booleanValue(); + isTracing |= SIGNAL; + } + + traceKey = Platform.getDebugOption(pluginID + "/event"); + if (traceKey != null) { + EVENT = (Boolean.valueOf(traceKey)).booleanValue(); + isTracing |= EVENT; + } + + // Create trace log file if needed + if (isTracing) { + fTraceLog = openLogFile(LOGNAME); + } + } + + public static void stop() { + if (fTraceLog == null) + return; + + try { + fTraceLog.close(); + fTraceLog = null; + } catch (IOException e) { + e.printStackTrace(); + } + } + + // Predicates + public static boolean isErrorTraced() { + return ERROR; + } + + public static boolean isComponentTraced() { + return COMPONENT; + } + + public static boolean isRequestTraced() { + return REQUEST; + } + + public static boolean isSignalTraced() { + return SIGNAL; + } + + public static boolean isEventTraced() { + return EVENT; + } + + // Tracers + public static void trace(String msg) { + long currentTime = System.currentTimeMillis(); + StringBuilder message = new StringBuilder("["); + message.append(currentTime / 1000); + message.append("."); + message.append(String.format("%1$03d", currentTime % 1000)); + message.append("] "); + message.append(msg); // System.out.println(message); - if (fTraceLog != null) { - try { - fTraceLog.write(message.toString()); - fTraceLog.newLine(); - fTraceLog.flush(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public static void traceComponent(ITmfComponent component, String msg) { - String message = ("[CMP] Thread=" + Thread.currentThread().getId() + " Cmp=" + component.getName() + " " + msg); - trace(message); - } - - public static void traceRequest(ITmfDataRequest request, String msg) { - String message = ("[REQ] Req=" + request.getRequestId() + - (request.getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? " (BG)" : " (FG)") + - " Thread=" + Thread.currentThread().getId() + - " Type=" + request.getClass().getName() + - " Index=" + request.getIndex() + - " NbReq=" + request.getNbRequested() + - (request instanceof ITmfEventRequest ? " Range=" + ((ITmfEventRequest)request).getRange() : "") + - " DataType=" + request.getDataType().getSimpleName() + " " + msg); - trace(message); - } - - public static void traceSignal(TmfSignal signal, String msg) { - String message = ("[SIG] Type=" + signal.getClass().getSimpleName() + " Target=" + msg); - trace(message); - } - - public static void traceEvent(ITmfDataProvider provider, ITmfDataRequest request, TmfData data) { - String message = ("[EVT] Provider=" + provider.toString() + ", Req=" + request.getRequestId() + ", Event=" + data.toString()); - trace(message); - } - - public static void traceError(String msg) { - String message = ("[ERR] Thread=" + Thread.currentThread().getId() + " " + msg); - trace(message); - } - - public static void traceInfo(String msg) { - String message = ("[INF] Thread=" + Thread.currentThread().getId() + " " + msg); - trace(message); - } + if (fTraceLog != null) { + try { + fTraceLog.write(message.toString()); + fTraceLog.newLine(); + fTraceLog.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static void traceComponent(ITmfComponent component, String msg) { + String message = ("[CMP] Thread=" + Thread.currentThread().getId() + " Cmp=" + component.getName() + " " + msg); + trace(message); + } + + public static void traceRequest(ITmfDataRequest request, String msg) { + String message = ("[REQ] Req=" + request.getRequestId() + + (request.getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? " (BG)" : " (FG)") + " Thread=" + + Thread.currentThread().getId() + " Type=" + simpleType(request.getClass().getName()) + " Index=" + + request.getIndex() + " NbReq=" + request.getNbRequested() + + (request instanceof ITmfEventRequest ? " Range=" + ((ITmfEventRequest) request).getRange() : "") + + " DataType=" + request.getDataType().getSimpleName() + " " + msg); + trace(message); + } + + private static String simpleType(String type) { + return type.substring(type.lastIndexOf('.') + 1); + } + + public static void traceSignal(TmfSignal signal, String msg) { + String message = ("[SIG] Type=" + signal.getClass().getSimpleName() + " Target=" + msg); + trace(message); + } + + public static void traceEvent(ITmfDataProvider provider, ITmfDataRequest request, TmfData data) { + String message = ("[EVT] Provider=" + provider.toString() + ", Req=" + request.getRequestId() + ", Event=" + data + .toString()); + trace(message); + } + + public static void traceError(String msg) { + String message = ("[ERR] Thread=" + Thread.currentThread().getId() + " " + msg); + trace(message); + } + + public static void traceInfo(String msg) { + String message = ("[INF] Thread=" + Thread.currentThread().getId() + " " + msg); + trace(message); + } } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java index a3626e77be..f9aae1acf8 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java @@ -30,21 +30,23 @@ public abstract class TmfComponent implements ITmfComponent { // Constructor // ------------------------------------------------------------------------ - public TmfComponent() { + public TmfComponent() { this(""); //$NON-NLS-1$ - } - + } + + public void init(String name) { + fName = name; + TmfSignalManager.register(this); + } + public TmfComponent(String name) { fName = name; -// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "created"); TmfSignalManager.register(this); } public TmfComponent(TmfComponent oldComponent) { - this.fName = oldComponent.fName; - - // Should we register? Probably not but I'm not quite sure what this does - //register(); + fName = oldComponent.fName; + TmfSignalManager.register(this); } /* (non-Javadoc) diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java index 02b814b4d9..30d1202c18 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java @@ -34,11 +34,11 @@ import org.eclipse.linuxtools.tmf.trace.ITmfContext; *

    * The TmfProvider is a provider for a data of type . *

    - * This abstract class implements the housekeeking methods to register/ - * deregister the event provider and to handle generically the event requests. + * This abstract class implements the housekeeking methods to register/ deregister the event provider and to handle + * generically the event requests. *

    - * The concrete class can either re-implement processRequest() entirely or just - * implement the hooks (initializeContext() and getNext()). + * The concrete class can either re-implement processRequest() entirely or just implement the hooks (initializeContext() + * and getNext()). *

    * TODO: Add support for providing multiple data types. */ @@ -48,23 +48,20 @@ public abstract class TmfDataProvider extends TmfComponent im // Constants // ------------------------------------------------------------------------ -// private static final ITmfDataRequest.ExecutionType SHORT = ITmfDataRequest.ExecutionType.SHORT; -// private static final ITmfDataRequest.ExecutionType LONG = ITmfDataRequest.ExecutionType.LONG; - // ------------------------------------------------------------------------ - // + // Attributes // ------------------------------------------------------------------------ - final protected Class fType; - final protected boolean fLogData; - final protected boolean fLogError; + protected Class fType; + protected boolean fLogData; + protected boolean fLogError; public static final int DEFAULT_BLOCK_SIZE = 50000; public static final int DEFAULT_QUEUE_SIZE = 1000; - protected final int fQueueSize; - protected final BlockingQueue fDataQueue; - protected final TmfRequestExecutor fExecutor; + protected int fQueueSize; + protected BlockingQueue fDataQueue; + protected TmfRequestExecutor fExecutor; private int fSignalDepth = 0; private final Object fLock = new Object(); @@ -75,6 +72,27 @@ public abstract class TmfDataProvider extends TmfComponent im // Constructors // ------------------------------------------------------------------------ + public TmfDataProvider() { + fQueueSize = DEFAULT_QUEUE_SIZE; + fDataQueue = new LinkedBlockingQueue(fQueueSize); + fExecutor = new TmfRequestExecutor(); + } + + public void init(String name, Class dataType) { + super.init(name); + fType = dataType; + fQueueSize = DEFAULT_QUEUE_SIZE; + fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue(fQueueSize) : new SynchronousQueue(); + + fExecutor = new TmfRequestExecutor(); + fSignalDepth = 0; + + fLogData = Tracer.isEventTraced(); + fLogError = Tracer.isErrorTraced(); + + TmfProviderManager.register(fType, this); + } + public TmfDataProvider(String name, Class type) { this(name, type, DEFAULT_QUEUE_SIZE); } @@ -92,7 +110,7 @@ public abstract class TmfDataProvider extends TmfComponent im fLogError = Tracer.isErrorTraced(); TmfProviderManager.register(fType, this); -// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "started"); + // if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "started"); } public TmfDataProvider(TmfDataProvider other) { @@ -113,7 +131,7 @@ public abstract class TmfDataProvider extends TmfComponent im TmfProviderManager.deregister(fType, this); fExecutor.stop(); super.dispose(); -// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "stopped"); + // if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "stopped"); } public int getQueueSize() { @@ -160,9 +178,8 @@ public abstract class TmfDataProvider extends TmfComponent im } /** - * Increments/decrements the pending requests counters and fires the request - * if necessary (counter == 0). Used for coalescing requests accross - * multiple TmfDataProvider. + * Increments/decrements the pending requests counters and fires the request if necessary (counter == 0). Used for + * coalescing requests accross multiple TmfDataProvider. * * @param isIncrement */ @@ -194,8 +211,8 @@ public abstract class TmfDataProvider extends TmfComponent im protected void newCoalescedDataRequest(ITmfDataRequest request) { synchronized (fLock) { - TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(fType, request.getIndex(), request.getNbRequested(), - request.getBlockSize(), request.getExecType()); + TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(fType, request.getIndex(), + request.getNbRequested(), request.getBlockSize(), request.getExecType()); coalescedRequest.addRequest(request); if (Tracer.isRequestTraced()) { Tracer.traceRequest(request, "coalesced with " + coalescedRequest.getRequestId()); //$NON-NLS-1$ @@ -317,8 +334,8 @@ public abstract class TmfDataProvider extends TmfComponent im while (!isFinished[0]) { - TmfDataRequest subRequest = new TmfDataRequest(request.getDataType(), request.getIndex() + nbRead[0], CHUNK_SIZE[0], - blockSize, ExecutionType.BACKGROUND) { + TmfDataRequest subRequest = new TmfDataRequest(request.getDataType(), request.getIndex() + + nbRead[0], CHUNK_SIZE[0], blockSize, ExecutionType.BACKGROUND) { @Override public void handleData(T data) { super.handleData(data); @@ -335,7 +352,7 @@ public abstract class TmfDataProvider extends TmfComponent im if (this.isCancelled()) { request.cancel(); } else if (this.isFailed()) { - request.fail(); + request.fail(); } else { request.done(); } @@ -364,12 +381,10 @@ public abstract class TmfDataProvider extends TmfComponent im } /** - * Initialize the provider based on the request. The context is provider - * specific and will be updated by getNext(). + * Initialize the provider based on the request. The context is provider specific and will be updated by getNext(). * * @param request - * @return an application specific context; null if request can't be - * serviced + * @return an application specific context; null if request can't be serviced */ public abstract ITmfContext armRequest(ITmfDataRequest request); diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java index 79a799ec0e..ef0b8b3888 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java @@ -28,46 +28,50 @@ import org.eclipse.linuxtools.tmf.request.TmfEventRequest; */ public abstract class TmfEventProvider extends TmfDataProvider { - public TmfEventProvider(String name, Class type) { - super(name, type); - } - - public TmfEventProvider(String name, Class type, int queueSize) { - super(name, type, queueSize); - } - - public TmfEventProvider(TmfEventProvider oldProvider) { - super(oldProvider); - } - - @Override - public boolean isCompleted(ITmfDataRequest request, T data, int nbRead) { - boolean requestCompleted = super.isCompleted(request, data, nbRead); - if (!requestCompleted && request instanceof ITmfEventRequest && !data.isNullRef()) { - TmfTimestamp endTime = ((ITmfEventRequest) request).getRange().getEndTime(); - return data.getTimestamp().compareTo(endTime, false) > 0; - } - return requestCompleted; - } - - @Override - protected synchronized void newCoalescedDataRequest(ITmfDataRequest request) { - if (request instanceof ITmfEventRequest) { - ITmfEventRequest eventRequest = (ITmfEventRequest) request; - TmfCoalescedEventRequest coalescedRequest = - new TmfCoalescedEventRequest( - fType, eventRequest.getRange(), eventRequest.getIndex(), eventRequest.getNbRequested(), eventRequest.getBlockSize(), - eventRequest.getExecType()); - coalescedRequest.addRequest(eventRequest); - if (Tracer.isRequestTraced()) { - Tracer.traceRequest(request, "coalesced with " + coalescedRequest.getRequestId()); //$NON-NLS-1$ - } - fPendingCoalescedRequests.add(coalescedRequest); - } - else { - super.newCoalescedDataRequest(request); - } - } + public TmfEventProvider() { + } + + public void init(String name, Class eventType) { + super.init(name, eventType); + } + + public TmfEventProvider(String name, Class type) { + super(name, type); + } + + public TmfEventProvider(String name, Class type, int queueSize) { + super(name, type, queueSize); + } + + public TmfEventProvider(TmfEventProvider oldProvider) { + super(oldProvider); + } + + @Override + public boolean isCompleted(ITmfDataRequest request, T data, int nbRead) { + boolean requestCompleted = super.isCompleted(request, data, nbRead); + if (!requestCompleted && request instanceof ITmfEventRequest && !data.isNullRef()) { + TmfTimestamp endTime = ((ITmfEventRequest) request).getRange().getEndTime(); + return data.getTimestamp().compareTo(endTime, false) > 0; + } + return requestCompleted; + } + + @Override + protected synchronized void newCoalescedDataRequest(ITmfDataRequest request) { + if (request instanceof ITmfEventRequest) { + ITmfEventRequest eventRequest = (ITmfEventRequest) request; + TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(fType, eventRequest.getRange(), + eventRequest.getNbRequested(), eventRequest.getBlockSize(), eventRequest.getExecType()); + coalescedRequest.addRequest(eventRequest); + if (Tracer.isRequestTraced()) { + Tracer.traceRequest(request, "coalesced with " + coalescedRequest.getRequestId()); //$NON-NLS-1$ + } + fPendingCoalescedRequests.add(coalescedRequest); + } else { + super.newCoalescedDataRequest(request); + } + } @Override protected void queueBackgroundRequest(final ITmfDataRequest request, final int blockSize, final boolean indexing) { diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java index 597a4d94d2..8f8ebc1d39 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java @@ -37,8 +37,8 @@ public class TmfEvent extends TmfData implements Cloneable { // Constants // ------------------------------------------------------------------------ - public static final TmfEvent NullEvent = new TmfEvent(); - + public static final TmfEvent NullEvent = new TmfEvent(); + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ @@ -51,9 +51,9 @@ public class TmfEvent extends TmfData implements Cloneable { protected TmfEventType fType; protected TmfEventReference fReference; - // Content requires a reference to the parent event so it is initialized - // using setContent() - protected TmfEventContent fContent; + // Content requires a reference to the parent event so it is initialized + // using setContent() + protected TmfEventContent fContent; // ------------------------------------------------------------------------ // Constructors @@ -121,15 +121,15 @@ public class TmfEvent extends TmfData implements Cloneable { fReference = new TmfEventReference(other.fReference); } - private TmfEvent() { - } + public TmfEvent() { + } - @Override - public boolean isNullRef() { - return this == NullEvent; - } + @Override + public boolean isNullRef() { + return this == NullEvent; + } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ // Accessors // ------------------------------------------------------------------------ @@ -147,94 +147,92 @@ public class TmfEvent extends TmfData implements Cloneable { return fEventRank; } - /** - * @return the effective event timestamp - */ - public TmfTimestamp getTimestamp() { - return fEffectiveTimestamp; - } + /** + * @return the effective event timestamp + */ + public TmfTimestamp getTimestamp() { + return fEffectiveTimestamp; + } - /** - * @return the original event timestamp - */ - public TmfTimestamp getOriginalTimestamp() { - return fOriginalTimestamp; - } + /** + * @return the original event timestamp + */ + public TmfTimestamp getOriginalTimestamp() { + return fOriginalTimestamp; + } - /** - * @return the event source - */ - public TmfEventSource getSource() { - return fSource; - } + /** + * @return the event source + */ + public TmfEventSource getSource() { + return fSource; + } - /** - * @return the event type - */ - public TmfEventType getType() { - return fType; - } + /** + * @return the event type + */ + public TmfEventType getType() { + return fType; + } - /** - * @return the event content - */ - public TmfEventContent getContent() { - return fContent; - } + /** + * @return the event content + */ + public TmfEventContent getContent() { + return fContent; + } - /** - * @return the event reference - */ - public TmfEventReference getReference() { - return fReference; - } + /** + * @return the event reference + */ + public TmfEventReference getReference() { + return fReference; + } - /** - * @param content the new event content - */ - public void setContent(TmfEventContent content) { - fContent = content; - } + /** + * @param content + * the new event content + */ + public void setContent(TmfEventContent content) { + fContent = content; + } - /** - * @return the event raw text - */ - public String getRawText() { - if (fContent != null && fContent.getContent() != null) { - return fContent.getContent().toString(); - } - return ""; //$NON-NLS-1$ - } + /** + * @return the event raw text + */ + public String getRawText() { + if (fContent != null && fContent.getContent() != null) { + return fContent.getContent().toString(); + } + return ""; //$NON-NLS-1$ + } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ // Object // ------------------------------------------------------------------------ - @Override + @Override public int hashCode() { - int result = 17; - result = 37 * result + fSource.hashCode(); - result = 37 * result + fType.hashCode(); - result = 37 * result + fEffectiveTimestamp.hashCode(); + int result = 17; + result = 37 * result + fSource.hashCode(); + result = 37 * result + fType.hashCode(); + result = 37 * result + fEffectiveTimestamp.hashCode(); return result; } @Override public boolean equals(Object other) { if (!(other instanceof TmfEvent)) - return false; + return false; TmfEvent o = (TmfEvent) other; - return fEffectiveTimestamp.equals(o.fEffectiveTimestamp) && - fSource.equals(o.fSource) && - fType.equals(o.fType) && - fContent.equals(o.fContent); + return fEffectiveTimestamp.equals(o.fEffectiveTimestamp) && fSource.equals(o.fSource) && fType.equals(o.fType) && fContent.equals(o.fContent); } - @Override + @Override @SuppressWarnings("nls") - public String toString() { - return "[TmfEvent(" + fEffectiveTimestamp + "," + fSource + "," + fType + "," + fContent + ")]"; - } + public String toString() { + return "[TmfEvent(" + fEffectiveTimestamp + "," + fSource + "," + fType + "," + fContent + ")]"; + } @Override public TmfEvent clone() { @@ -254,7 +252,7 @@ public class TmfEvent extends TmfData implements Cloneable { e.printStackTrace(); } - return clone; - } + return clone; + } } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java index 7e171df482..726da00031 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java @@ -12,9 +12,11 @@ package org.eclipse.linuxtools.tmf.experiment; +import java.io.FileNotFoundException; import java.util.Collections; import java.util.Vector; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -28,6 +30,7 @@ import org.eclipse.linuxtools.tmf.request.ITmfEventRequest; import org.eclipse.linuxtools.tmf.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.signal.TmfExperimentDisposedSignal; +import org.eclipse.linuxtools.tmf.signal.TmfExperimentRangeUpdatedSignal; import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; @@ -42,11 +45,10 @@ import org.eclipse.linuxtools.tmf.trace.TmfContext; /** * TmfExperiment *

    - * TmfExperiment presents a time-ordered, unified view of a set of TmfTraces - * that are part of a tracing experiment. + * TmfExperiment presents a time-ordered, unified view of a set of TmfTraces that are part of a tracing experiment. *

    */ -public class TmfExperiment extends TmfEventProvider implements ITmfTrace { +public class TmfExperiment extends TmfEventProvider implements ITmfTrace { // ------------------------------------------------------------------------ // Attributes @@ -56,7 +58,7 @@ public class TmfExperiment extends TmfEventProvider imple protected static TmfExperiment fCurrentExperiment = null; // The set of traces that constitute the experiment - protected ITmfTrace[] fTraces; + protected ITmfTrace[] fTraces; // The total number of events protected long fNbEvents; @@ -77,6 +79,27 @@ public class TmfExperiment extends TmfEventProvider imple // Constructors // ------------------------------------------------------------------------ + @Override + public boolean validate(IProject project, String path) { + return true; + } + + @Override + public void initTrace(String path, Class eventType) throws FileNotFoundException { + } + + @Override + public void initTrace(String path, Class eventType, boolean indexTrace) throws FileNotFoundException { + } + + @Override + public void initTrace(String path, Class eventType, int cacheSize) throws FileNotFoundException { + } + + @Override + public void initTrace(String path, Class eventType, int cacheSize, boolean indexTrace) throws FileNotFoundException { + } + /** * @param type * @param id @@ -84,11 +107,11 @@ public class TmfExperiment extends TmfEventProvider imple * @param epoch * @param indexPageSize */ - public TmfExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize) { + public TmfExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize) { this(type, id, traces, TmfTimestamp.Zero, indexPageSize, false); } - public TmfExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize, boolean preIndexExperiment) { + public TmfExperiment(Class type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize, boolean preIndexExperiment) { super(id, type); fTraces = traces; @@ -112,7 +135,7 @@ public class TmfExperiment extends TmfEventProvider imple * @param id * @param traces */ - public TmfExperiment(Class type, String id, ITmfTrace[] traces) { + public TmfExperiment(Class type, String id, ITmfTrace[] traces) { this(type, id, traces, TmfTimestamp.Zero, DEFAULT_INDEX_PAGE_SIZE); } @@ -122,7 +145,7 @@ public class TmfExperiment extends TmfEventProvider imple * @param traces * @param indexPageSize */ - public TmfExperiment(Class type, String id, ITmfTrace[] traces, int indexPageSize) { + public TmfExperiment(Class type, String id, ITmfTrace[] traces, int indexPageSize) { this(type, id, traces, TmfTimestamp.Zero, indexPageSize); } @@ -131,6 +154,7 @@ public class TmfExperiment extends TmfEventProvider imple * * @param other */ + @SuppressWarnings("unchecked") public TmfExperiment(TmfExperiment other) { super(other.getName() + "(clone)", other.fType); //$NON-NLS-1$ @@ -139,7 +163,7 @@ public class TmfExperiment extends TmfEventProvider imple fTraces = new ITmfTrace[other.fTraces.length]; for (int trace = 0; trace < other.fTraces.length; trace++) { - fTraces[trace] = other.fTraces[trace].createTraceCopy(); + fTraces[trace] = other.fTraces[trace].copy(); } fNbEvents = other.fNbEvents; @@ -147,7 +171,7 @@ public class TmfExperiment extends TmfEventProvider imple } @Override - public TmfExperiment createTraceCopy() { + public TmfExperiment copy() { TmfExperiment experiment = new TmfExperiment(this); TmfSignalManager.deregister(experiment); return experiment; @@ -157,6 +181,7 @@ public class TmfExperiment extends TmfEventProvider imple * Clears the experiment */ @Override + @SuppressWarnings("rawtypes") public synchronized void dispose() { TmfExperimentDisposedSignal signal = new TmfExperimentDisposedSignal(this, this); @@ -178,11 +203,6 @@ public class TmfExperiment extends TmfEventProvider imple // ITmfTrace // ------------------------------------------------------------------------ - @Override - public String getPath() { - return null; - } - @Override public long getNbEvents() { return fNbEvents; @@ -228,13 +248,13 @@ public class TmfExperiment extends TmfEventProvider imple return fEpoch; } - public ITmfTrace[] getTraces() { + public ITmfTrace[] getTraces() { return fTraces; } /** - * Returns the rank of the first event with the requested timestamp. If - * none, returns the index of the next event (if any). + * Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event + * (if any). * * @param timestamp * @return @@ -246,8 +266,7 @@ public class TmfExperiment extends TmfEventProvider imple } /** - * Returns the timestamp of the event at the requested index. If none, - * returns null. + * Returns the timestamp of the event at the requested index. If none, returns null. * * @param index * @return @@ -269,7 +288,7 @@ public class TmfExperiment extends TmfEventProvider imple TmfTimestamp startTime = fTimeRange != TmfTimeRange.Null ? fTimeRange.getStartTime() : TmfTimestamp.BigCrunch; TmfTimestamp endTime = fTimeRange != TmfTimeRange.Null ? fTimeRange.getEndTime() : TmfTimestamp.BigBang; - for (ITmfTrace trace : fTraces) { + for (ITmfTrace trace : fTraces) { TmfTimestamp traceStartTime = trace.getStartTime(); if (traceStartTime.compareTo(startTime, true) < 0) startTime = traceStartTime; @@ -286,7 +305,8 @@ public class TmfExperiment extends TmfEventProvider imple @Override public ITmfContext armRequest(ITmfDataRequest request) { // Tracer.trace("Ctx: Arming request - start"); - TmfTimestamp timestamp = (request instanceof ITmfEventRequest) ? ((ITmfEventRequest) request).getRange().getStartTime() : null; + TmfTimestamp timestamp = (request instanceof ITmfEventRequest) ? ((ITmfEventRequest) request).getRange().getStartTime() + : null; if (TmfTimestamp.BigBang.equals(timestamp) || request.getIndex() > 0) { timestamp = null; // use request index @@ -337,8 +357,8 @@ public class TmfExperiment extends TmfEventProvider imple } // Instantiate the location - TmfExperimentLocation expLocation = (location == null) ? new TmfExperimentLocation(new TmfLocationArray(new ITmfLocation[fTraces.length]), - new long[fTraces.length]) : (TmfExperimentLocation) location.clone(); + TmfExperimentLocation expLocation = (location == null) ? new TmfExperimentLocation(new TmfLocationArray( + new ITmfLocation[fTraces.length]), new long[fTraces.length]) : (TmfExperimentLocation) location.clone(); // Create and populate the context's traces contexts TmfExperimentContext context = new TmfExperimentContext(fTraces, new TmfContext[fTraces.length]); @@ -375,9 +395,7 @@ public class TmfExperiment extends TmfEventProvider imple /* * (non-Javadoc) * - * @see - * org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools - * .tmf.event.TmfTimestamp) + * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools .tmf.event.TmfTimestamp) */ @Override public synchronized TmfExperimentContext seekEvent(TmfTimestamp timestamp) { @@ -495,8 +513,7 @@ public class TmfExperiment extends TmfEventProvider imple } /** - * Scan the next events from all traces and return the next one in - * chronological order. + * Scan the next events from all traces and return the next one in chronological order. * * @param context * @return @@ -606,7 +623,8 @@ public class TmfExperiment extends TmfEventProvider imple if (fCheckpoints.size() == position) { ITmfLocation location = context.getLocation().clone(); fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location)); -// System.out.println(this + "[" + (fCheckpoints.size() - 1) + "] " + timestamp + ", " + location.toString()); +// System.out.println(this + "[" + (fCheckpoints.size() - 1) + "] " + timestamp + ", " +// + location.toString()); } } } @@ -614,9 +632,7 @@ public class TmfExperiment extends TmfEventProvider imple /* * (non-Javadoc) * - * @see - * org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools - * .tmf.trace.TmfContext) + * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext) */ @Override public TmfEvent parseEvent(TmfContext context) { @@ -680,13 +696,11 @@ public class TmfExperiment extends TmfEventProvider imple // ------------------------------------------------------------------------ /* - * The experiment holds the globally ordered events of its set of traces. It - * is expected to provide access to each individual event by index i.e. it - * must be possible to request the Nth event of the experiment. + * The experiment holds the globally ordered events of its set of traces. It is expected to provide access to each + * individual event by index i.e. it must be possible to request the Nth event of the experiment. * - * The purpose of the index is to keep the information needed to rapidly - * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE - * event). + * The purpose of the index is to keep the information needed to rapidly restore the traces contexts at regular + * intervals (every INDEX_PAGE_SIZE event). */ // The index page size @@ -743,12 +757,12 @@ public class TmfExperiment extends TmfEventProvider imple job.schedule(); // fEventLog = openLogFile("TraceEvent.log"); -// System.out.println(System.currentTimeMillis() + ": Experiment indexing started"); +// System.out.println(System.currentTimeMillis() + ": Experiment indexing started"); - ITmfEventRequest request = new TmfEventRequest(TmfEvent.class, timeRange, index, TmfDataRequest.ALL_DATA, fIndexPageSize, - ITmfDataRequest.ExecutionType.BACKGROUND) { // PATA FOREGROUND + ITmfEventRequest request = new TmfEventRequest(TmfEvent.class, timeRange, index, TmfDataRequest.ALL_DATA, + fIndexPageSize, ITmfDataRequest.ExecutionType.BACKGROUND) { // PATA FOREGROUND -// long indexingStart = System.nanoTime(); +// long indexingStart = System.nanoTime(); TmfTimestamp startTime = (fTimeRange == TmfTimeRange.Null) ? null : fTimeRange.getStartTime(); TmfTimestamp lastTime = (fTimeRange == TmfTimeRange.Null) ? null : fTimeRange.getEndTime(); @@ -775,17 +789,19 @@ public class TmfExperiment extends TmfEventProvider imple @Override public void handleSuccess() { -// long indexingEnd = System.nanoTime(); +// long indexingEnd = System.nanoTime(); if (getRange() != TmfTimeRange.Eternity) { lastTime = getRange().getEndTime(); } updateExperiment(); -// System.out.println(System.currentTimeMillis() + ": Experiment indexing completed"); +// System.out.println(System.currentTimeMillis() + ": Experiment indexing completed"); -// long average = (indexingEnd - indexingStart) / fNbEvents; -// System.out.println(getName() + ": start=" + startTime + ", end=" + lastTime + ", elapsed=" + (indexingEnd * 1.0 - indexingStart) / 1000000000); -// System.out.println(getName() + ": nbEvents=" + fNbEvents + " (" + (average / 1000) + "." + (average % 1000) + " us/evt)"); +// long average = (indexingEnd - indexingStart) / fNbEvents; +// System.out.println(getName() + ": start=" + startTime + ", end=" + lastTime + ", elapsed=" +// + (indexingEnd * 1.0 - indexingStart) / 1000000000); +// System.out.println(getName() + ": nbEvents=" + fNbEvents + " (" + (average / 1000) + "." +// + (average % 1000) + " us/evt)"); super.handleSuccess(); } @@ -827,6 +843,7 @@ public class TmfExperiment extends TmfEventProvider imple protected void notifyListeners() { broadcast(new TmfExperimentUpdatedSignal(this, this)); // , null)); + broadcast(new TmfExperimentRangeUpdatedSignal(this, this, fTimeRange)); // , null)); } // ------------------------------------------------------------------------ @@ -850,7 +867,7 @@ public class TmfExperiment extends TmfEventProvider imple @TmfSignalHandler public void traceUpdated(TmfTraceUpdatedSignal signal) { - for (ITmfTrace trace : fTraces) { + for (ITmfTrace trace : fTraces) { if (trace == signal.getTrace()) { synchronized (fCheckpoints) { if (fIndexing) { @@ -876,4 +893,10 @@ public class TmfExperiment extends TmfEventProvider imple } } + @Override + public String getPath() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/parser/ITmfEventParser.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/parser/ITmfEventParser.java index fc6e699f90..bf5f34d341 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/parser/ITmfEventParser.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/parser/ITmfEventParser.java @@ -29,5 +29,5 @@ public interface ITmfEventParser { * @return * @throws IOException */ - public TmfEvent parseNextEvent(ITmfTrace stream, TmfContext context) throws IOException; -} \ No newline at end of file + public TmfEvent parseNextEvent(ITmfTrace stream, TmfContext context) throws IOException; +} diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java index cb84d76460..d26fdb3d35 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java @@ -20,52 +20,52 @@ import org.eclipse.linuxtools.tmf.event.TmfData; /** * TmfDataRequest *

    - * TmfDataRequests are used to obtain blocks of contiguous data from a data - * provider. Open ranges can be used, especially for continuous streaming. + * TmfDataRequests are used to obtain blocks of contiguous data from a data provider. Open ranges can be used, + * especially for continuous streaming. *

    - * The request is processed asynchronously by a TmfProvider and, as blocks - * of data become available, handleData() is invoked synchronously for each - * block. Upon return, the data instances go out of scope and become eligible - * for gc. It is is thus the responsibility of the requester to either clone - * or keep a reference to the data it wishes to track specifically. + * The request is processed asynchronously by a TmfProvider and, as blocks of data become available, handleData() is + * invoked synchronously for each block. Upon return, the data instances go out of scope and become eligible for gc. It + * is is thus the responsibility of the requester to either clone or keep a reference to the data it wishes to track + * specifically. *

    - * This data block approach is used to avoid busting the heap for very - * large trace files. The block size is configurable. + * This data block approach is used to avoid busting the heap for very large trace files. The block size is + * configurable. *

    - * The TmfProvider indicates that the request is completed by calling done(). - * The request can be canceled at any time with cancel(). + * The TmfProvider indicates that the request is completed by calling done(). The request can be canceled at any time + * with cancel(). *

    * Typical usage: - *

    TmfTimeWindow range = new TmfTimewindow(...);
    - *TmfDataRequest<DataType[]> request = new TmfDataRequest<DataType[]>(DataType.class, 0, NB_EVENTS, BLOCK_SIZE) {
    - *    public void handleData() {
    - *         DataType[] data = request.getData();
    - *         for (DataType e : data) {
    - *             // do something
    - *         }
    - *    }
    - *    public void handleSuccess() {
    - *         // do something
    - *         }
    - *    }
    - *    public void handleFailure() {
    - *         // do something
    - *         }
    - *    }
    - *    public void handleCancel() {
    - *         // do something
    - *         }
    - *    }
    - *};
    - *fProcessor.process(request, true);
    - *
    - * - * TODO: Consider decoupling from "time range", "rank", etc and for the more - * generic notion of "criteria". This would allow to extend for "time range", etc - * instead of providing specialized constructors. This also means removing the - * criteria info from the data structure (with the possible exception of fNbRequested). - * The nice thing about it is that it would prepare us well for the coming generation - * of analysis tools. + * + *
    + * TmfTimeWindow range = new TmfTimewindow(...);
    + * TmfDataRequest<DataType[]> request = new TmfDataRequest<DataType[]>(DataType.class, 0, NB_EVENTS, BLOCK_SIZE) {
    + *     public void handleData() {
    + *          DataType[] data = request.getData();
    + *          for (DataType e : data) {
    + *              // do something
    + *          }
    + *     }
    + *     public void handleSuccess() {
    + *          // do something
    + *          }
    + *     }
    + *     public void handleFailure() {
    + *          // do something
    + *          }
    + *     }
    + *     public void handleCancel() {
    + *          // do something
    + *          }
    + *     }
    + * };
    + * fProcessor.process(request, true);
    + * 
    + * 
    + * + * TODO: Consider decoupling from "time range", "rank", etc and for the more generic notion of "criteria". This would + * allow to extend for "time range", etc instead of providing specialized constructors. This also means removing the + * criteria info from the data structure (with the possible exception of fNbRequested). The nice thing about it is that + * it would prepare us well for the coming generation of analysis tools. * * TODO: Implement request failures (codes, etc...) */ @@ -80,27 +80,27 @@ public abstract class TmfDataRequest implements ITmfDataReque // The request count for all the events public static final int ALL_DATA = Integer.MAX_VALUE; - + private static int fRequestNumber = 0; - + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ - private final Class fDataType; + private final Class fDataType; private final ExecutionType fExecType; - private final int fRequestId; // A unique request ID - private int fIndex; // The index (rank) of the requested event - private final int fNbRequested; // The number of requested events (ALL_DATA for all) - private final int fBlockSize; // The block size (for BG requests) - private int fNbRead; // The number of reads so far + private final int fRequestId; // A unique request ID + private int fIndex; // The index (rank) of the requested event + private final int fNbRequested; // The number of requested events (ALL_DATA for all) + private final int fBlockSize; // The block size (for BG requests) + private int fNbRead; // The number of reads so far - private CountDownLatch startedLatch = new CountDownLatch(1); + private CountDownLatch startedLatch = new CountDownLatch(1); private CountDownLatch completedLatch = new CountDownLatch(1); - private boolean fRequestRunning = false; + private boolean fRequestRunning = false; private boolean fRequestCompleted = false; - private boolean fRequestFailed = false; - private boolean fRequestCanceled = false; + private boolean fRequestFailed = false; + private boolean fRequestCanceled = false; // ------------------------------------------------------------------------ // Constructors @@ -110,13 +110,14 @@ public abstract class TmfDataRequest implements ITmfDataReque * Resets the request counter (used for testing) */ public static void reset() { - fRequestNumber = 0; + fRequestNumber = 0; } /** * Default constructor - * - * @param dataType the requested data type + * + * @param dataType + * the requested data type */ public TmfDataRequest(Class dataType) { this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); @@ -127,8 +128,10 @@ public abstract class TmfDataRequest implements ITmfDataReque } /** - * @param dataType the requested data type - * @param nbRequested the number of data items requested + * @param dataType + * the requested data type + * @param nbRequested + * the number of data items requested */ public TmfDataRequest(Class dataType, int index) { this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); @@ -139,9 +142,12 @@ public abstract class TmfDataRequest implements ITmfDataReque } /** - * @param dataType the requested data type - * @param index the index (rank) of the first event requested - * @param blockSize the number of data items per block + * @param dataType + * the requested data type + * @param index + * the index (rank) of the first event requested + * @param blockSize + * the number of data items per block */ public TmfDataRequest(Class dataType, int index, int nbRequested) { this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); @@ -152,67 +158,72 @@ public abstract class TmfDataRequest implements ITmfDataReque } /** - * @param dataType the requested data type - * @param index the index (rank) of the first event requested - * @param nbRequested the number of data items requested - * @param blockSize the number of data items per block + * @param dataType + * the requested data type + * @param index + * the index (rank) of the first event requested + * @param nbRequested + * the number of data items requested + * @param blockSize + * the number of data items per block */ public TmfDataRequest(Class dataType, int index, int nbRequested, int blockSize) { this(dataType, index, nbRequested, blockSize, ExecutionType.FOREGROUND); } public TmfDataRequest(Class dataType, int index, int nbRequested, int blockSize, ExecutionType execType) { - fRequestId = fRequestNumber++; - fDataType = dataType; - fIndex = index; - fNbRequested = nbRequested; - fBlockSize = blockSize; - fExecType = execType; - fNbRead = 0; - if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "created"); //$NON-NLS-1$ + fRequestId = fRequestNumber++; + fDataType = dataType; + fIndex = index; + fNbRequested = nbRequested; + fBlockSize = blockSize; + fExecType = execType; + fNbRead = 0; + if (Tracer.isRequestTraced()) + Tracer.traceRequest(this, "created"); //$NON-NLS-1$ } /** * Copy constructor */ @SuppressWarnings("unused") - private TmfDataRequest(TmfDataRequest other) { - this(null, 0, ALL_DATA, DEFAULT_BLOCK_SIZE); + private TmfDataRequest(TmfDataRequest other) { + this(null, 0, ALL_DATA, DEFAULT_BLOCK_SIZE); } // ------------------------------------------------------------------------ // Accessors // ------------------------------------------------------------------------ - /** - * @return the request ID - */ - @Override - public int getRequestId() { - return fRequestId; - } - - /** - * @return the index of the first event requested - */ - @Override - public int getIndex() { - return fIndex; - } - - /** - * @return the index of the first event requested - */ - @Override - public ExecutionType getExecType() { - return fExecType; - } + /** + * @return the request ID + */ + @Override + public int getRequestId() { + return fRequestId; + } + + /** + * @return the index of the first event requested + */ + @Override + public int getIndex() { + return fIndex; + } + + /** + * @return the index of the first event requested + */ + @Override + public ExecutionType getExecType() { + return fExecType; + } /** * @return the number of requested events (ALL_DATA = all) */ @Override - public int getNbRequested() { + public int getNbRequested() { return fNbRequested; } @@ -220,7 +231,7 @@ public abstract class TmfDataRequest implements ITmfDataReque * @return the block size (for BG requests) */ @Override - public int getBlockSize() { + public int getBlockSize() { return fBlockSize; } @@ -228,7 +239,7 @@ public abstract class TmfDataRequest implements ITmfDataReque * @return the number of events read so far */ @Override - public synchronized int getNbRead() { + public synchronized int getNbRead() { return fNbRead; } @@ -268,7 +279,7 @@ public abstract class TmfDataRequest implements ITmfDataReque * @return the requested data type */ @Override - public Class getDataType() { + public Class getDataType() { return fDataType; } @@ -278,9 +289,11 @@ public abstract class TmfDataRequest implements ITmfDataReque /** * this method is called by the event provider to set the index corresponding to the time range start time - * @param index the start time index + * + * @param index + * the start time index */ - protected void setIndex(int index) { + protected void setIndex(int index) { fIndex = index; } @@ -288,110 +301,105 @@ public abstract class TmfDataRequest implements ITmfDataReque // Operators // ------------------------------------------------------------------------ - /** - * Sets the data object to specified value. To be called by the - * asynchronous method implementor. + /** + * Sets the data object to specified value. To be called by the asynchronous method implementor. * - * @param data Data value to set. + * @param data + * Data value to set. */ /** - * Handle a block of incoming data. This method is called every time - * a block of data becomes available. + * Handle a block of incoming data. This method is called every time a block of data becomes available. + * + * - Data items are received in the order they appear in the stream. - Called by the request processor, in its + * execution thread, every time a block of data becomes available. - Request processor performs a synchronous call + * to handlePartialResult() i.e. its execution threads holds until handlePartialData() returns. - Original data + * items are disposed of on return i.e. keep a reference (or a copy) if some persistence is needed between + * invocations. - When there is no more data, done() is called. * - * - Data items are received in the order they appear in the stream. - * - Called by the request processor, in its execution thread, every time a - * block of data becomes available. - * - Request processor performs a synchronous call to handlePartialResult() - * i.e. its execution threads holds until handlePartialData() returns. - * - Original data items are disposed of on return i.e. keep a reference - * (or a copy) if some persistence is needed between invocations. - * - When there is no more data, done() is called. - * - * @param events - an events + * @param events + * - an events */ @Override - public void handleData(T data) { + public void handleData(T data) { if (data != null) { - fNbRead++; + fNbRead++; } } @Override - public void handleStarted() { - if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "started"); //$NON-NLS-1$ + public void handleStarted() { + if (Tracer.isRequestTraced()) + Tracer.traceRequest(this, "started"); //$NON-NLS-1$ } /** - * Handle the completion of the request. It is called when there is no more - * data available either because: - * - the request completed normally - * - the request failed - * - the request was canceled + * Handle the completion of the request. It is called when there is no more data available either because: - the + * request completed normally - the request failed - the request was canceled * - * As a convenience, handleXXXX methods are provided. They are meant to be - * overridden by the application if it needs to handle these conditions. + * As a convenience, handleXXXX methods are provided. They are meant to be overridden by the application if it needs + * to handle these conditions. */ @Override - public void handleCompleted() { - if (fRequestFailed) { - handleFailure(); - } - else if (fRequestCanceled) { - handleCancel(); - } - else { - handleSuccess(); - } - if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "completed"); //$NON-NLS-1$ + public void handleCompleted() { + if (fRequestFailed) { + handleFailure(); + } else if (fRequestCanceled) { + handleCancel(); + } else { + handleSuccess(); + } + if (Tracer.isRequestTraced()) + Tracer.traceRequest(this, "completed (" + fNbRead + " events read)"); //$NON-NLS-1$ } @Override - public void handleSuccess() { - if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "succeeded"); //$NON-NLS-1$ + public void handleSuccess() { + if (Tracer.isRequestTraced()) + Tracer.traceRequest(this, "succeeded"); //$NON-NLS-1$ } @Override - public void handleFailure() { - if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "failed"); //$NON-NLS-1$ + public void handleFailure() { + if (Tracer.isRequestTraced()) + Tracer.traceRequest(this, "failed"); //$NON-NLS-1$ } @Override - public void handleCancel() { - if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "cancelled"); //$NON-NLS-1$ + public void handleCancel() { + if (Tracer.isRequestTraced()) + Tracer.traceRequest(this, "cancelled"); //$NON-NLS-1$ } /** - * To suspend the client thread until the request starts (or is - * canceled). + * To suspend the client thread until the request starts (or is canceled). * - * @throws InterruptedException + * @throws InterruptedException */ public void waitForStart() throws InterruptedException { - while (!fRequestRunning) { - startedLatch.await(); - } + while (!fRequestRunning) { + startedLatch.await(); + } } /** - * To suspend the client thread until the request completes (or is - * canceled). + * To suspend the client thread until the request completes (or is canceled). * - * @throws InterruptedException + * @throws InterruptedException */ @Override - public void waitForCompletion() throws InterruptedException { - while (!fRequestCompleted) { - completedLatch.await(); - } + public void waitForCompletion() throws InterruptedException { + while (!fRequestCompleted) { + completedLatch.await(); + } } /** * Called by the request processor upon starting to service the request. */ @Override - public void start() { - synchronized(this) { + public void start() { + synchronized (this) { fRequestRunning = true; } handleStarted(); @@ -402,17 +410,17 @@ public abstract class TmfDataRequest implements ITmfDataReque * Called by the request processor upon completion. */ @Override - public void done() { - synchronized(this) { - if (!fRequestCompleted) { - fRequestRunning = false; + public void done() { + synchronized (this) { + if (!fRequestCompleted) { + fRequestRunning = false; fRequestCompleted = true; } else { return; } } - handleCompleted(); - completedLatch.countDown(); + handleCompleted(); + completedLatch.countDown(); } /** @@ -420,7 +428,7 @@ public abstract class TmfDataRequest implements ITmfDataReque */ @Override public void fail() { - synchronized(this) { + synchronized (this) { fRequestFailed = true; } done(); @@ -431,10 +439,10 @@ public abstract class TmfDataRequest implements ITmfDataReque */ @Override public void cancel() { - synchronized(this) { + synchronized (this) { fRequestCanceled = true; } - done(); + done(); } // ------------------------------------------------------------------------ @@ -444,24 +452,23 @@ public abstract class TmfDataRequest implements ITmfDataReque @Override // All requests have a unique id public int hashCode() { - return getRequestId(); + return getRequestId(); } @Override public boolean equals(Object other) { - if (other instanceof TmfDataRequest) { - TmfDataRequest request = (TmfDataRequest) other; - return (request.fDataType == fDataType) && - (request.fIndex == fIndex) && - (request.fNbRequested == fNbRequested); - } - return false; + if (other instanceof TmfDataRequest) { + TmfDataRequest request = (TmfDataRequest) other; + return (request.fDataType == fDataType) && (request.fIndex == fIndex) + && (request.fNbRequested == fNbRequested); + } + return false; } @Override @SuppressWarnings("nls") public String toString() { - return "[TmfDataRequest(" + fRequestId + "," + fDataType.getSimpleName() + - "," + fIndex + "," + fNbRequested + "," + getBlockSize() + ")]"; + return "[TmfDataRequest(" + fRequestId + "," + fDataType.getSimpleName() + "," + fIndex + "," + fNbRequested + + "," + getBlockSize() + ")]"; } } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfTraceUpdatedSignal.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfTraceUpdatedSignal.java index 866dc3d68e..db26c04eb3 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfTraceUpdatedSignal.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfTraceUpdatedSignal.java @@ -22,16 +22,16 @@ import org.eclipse.linuxtools.tmf.trace.ITmfTrace; */ public class TmfTraceUpdatedSignal extends TmfSignal { - private final ITmfTrace fTrace; + private final ITmfTrace fTrace; private final TmfTimeRange fTimeRange; - public TmfTraceUpdatedSignal(Object source, ITmfTrace trace, TmfTimeRange range) { + public TmfTraceUpdatedSignal(Object source, ITmfTrace trace, TmfTimeRange range) { super(source); fTrace = trace; fTimeRange = range; } - public ITmfTrace getTrace() { + public ITmfTrace getTrace() { return fTrace; } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java index 5a3de536de..4af6fd4811 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Ericsson + * Copyright (c) 2009, 2011 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,6 +12,9 @@ package org.eclipse.linuxtools.tmf.trace; +import java.io.FileNotFoundException; + +import org.eclipse.core.resources.IProject; import org.eclipse.linuxtools.tmf.component.ITmfComponent; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; @@ -21,50 +24,66 @@ import org.eclipse.linuxtools.tmf.event.TmfTimestamp; * ITmfTrace *

    */ -public interface ITmfTrace extends ITmfComponent { - - public ITmfTrace createTraceCopy(); - - /** - * @return the trace path - */ - public String getPath(); - - /** - * @return the trace name - */ - @Override - public String getName(); +public interface ITmfTrace extends ITmfComponent { + + // initTrace variants + public void initTrace(String path, Class eventType) throws FileNotFoundException; + + public void initTrace(String path, Class eventType, int cacheSize) throws FileNotFoundException; + + public void initTrace(String path, Class eventType, boolean indexTrace) throws FileNotFoundException; + + public void initTrace(String path, Class eventType, int cacheSize, boolean indexTrace) throws FileNotFoundException; + + // Trace type validation + public boolean validate(IProject project, String path); + + public ITmfTrace copy(); /** - * @return the cache size + * @return the trace path + */ + public String getPath(); + + /** + * @return the trace name + */ + @Override + public String getName(); + + /** + * @return the cache size */ public int getCacheSize(); - /** - * @return the number of events in the trace - */ - public long getNbEvents(); - - /** - * Trace time range accessors - */ - public TmfTimeRange getTimeRange(); + /** + * @return the number of events in the trace + */ + public long getNbEvents(); + + /** + * Trace time range accesses + */ + public TmfTimeRange getTimeRange(); + public TmfTimestamp getStartTime(); + public TmfTimestamp getEndTime(); - /** - * Positions the trace at the first event with the specified - * timestamp or index (i.e. the nth event in the trace). + /** + * Positions the trace at the first event with the specified timestamp or index (i.e. the nth event in the trace). * * Returns a context which can later be used to read the event. * - * @param data.timestamp - * @param data.index + * @param location + * @param timestamp + * @param rank * @return a context object for subsequent reads */ public TmfContext seekLocation(ITmfLocation location); + public TmfContext seekEvent(TmfTimestamp timestamp); + public TmfContext seekEvent(long rank); /** @@ -72,41 +91,42 @@ public interface ITmfTrace extends ITmfComponent { * * Returns a context which can later be used to read the event. * - * @param ratio a floating-point number between 0.0 (beginning) and 1.0 (end) + * @param ratio + * a floating-point number between 0.0 (beginning) and 1.0 (end) * @return a context object for subsequent reads */ public TmfContext seekLocation(double ratio); - + /** * Returns the ratio corresponding to the specified location. * - * @param location a trace location + * @param location + * a trace location * @return a floating-point number between 0.0 (beginning) and 1.0 (end) */ public double getLocationRatio(ITmfLocation location); - + public ITmfLocation getCurrentLocation(); /** - * Returns the rank of the first event with the requested timestamp. - * If none, returns the index of the next event (if any). - * + * Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event + * (if any). + * * @param timestamp * @return */ public long getRank(TmfTimestamp timestamp); - + /** - * Return the event pointed by the supplied context (or null if - * no event left) and updates the context to the next event. + * Return the event pointed by the supplied context (or null if no event left) and updates the context to the next + * event. * * @return the next event in the stream */ public TmfEvent getNextEvent(TmfContext context); /** - * Return the event pointed by the supplied context (or null if - * no event left) and *does not* update the context. + * Return the event pointed by the supplied context (or null if no event left) and *does not* update the context. * * @return the next event in the stream */ diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java index bc58b724db..f7e71b7f62 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java @@ -17,6 +17,7 @@ import java.io.FileNotFoundException; import java.util.Collections; import java.util.Vector; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -34,31 +35,28 @@ import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal; /** * TmfTrace *

    - * Abstract implementation of ITmfTrace. It should be sufficient to extend this - * class and provide implementation for getCurrentLocation() and - * seekLocation(), as well as a proper parser, to have a working + * Abstract implementation of ITmfTrace. It should be sufficient to extend this class and provide implementation for + * getCurrentLocation() and seekLocation(), as well as a proper parser, to have a working * concrete implementation. *

    - * Note: The notion of event rank is still under heavy discussion. Although - * used by the Events View and probably useful in the general case, there - * is no easy way to implement it for LTTng (actually a strong case is being - * made that this is useless). + * Note: The notion of event rank is still under heavy discussion. Although used by the Events View and probably useful + * in the general case, there is no easy way to implement it for LTTng (actually a strong case is being made that this + * is useless). *

    - * That it is not supported by LTTng does by no mean indicate that it is not - * useful for (just about) every other tracing tool. Therefore, this class - * provides a minimal (and partial) implementation of rank. However, the current + * That it is not supported by LTTng does by no mean indicate that it is not useful for (just about) every other tracing + * tool. Therefore, this class provides a minimal (and partial) implementation of rank. However, the current * implementation should not be relied on in the general case. * * TODO: Add support for live streaming (notifications, incremental indexing, ...) */ -public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, Cloneable { +public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, Cloneable { // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ // The default number of events to cache - // TODO: Make the DEFAULT_CACHE_SIZE a preference + // TODO: Make the DEFAULT_CACHE_SIZE a preference public static final int DEFAULT_INDEX_PAGE_SIZE = 50000; // ------------------------------------------------------------------------ @@ -66,10 +64,10 @@ public abstract class TmfTrace extends TmfEventProvider i // ------------------------------------------------------------------------ // The trace path - private final String fPath; + private String fPath; // The cache page size AND checkpoints interval - protected int fIndexPageSize; + protected int fIndexPageSize = DEFAULT_INDEX_PAGE_SIZE; // The set of event stream checkpoints (for random access) protected Vector fCheckpoints = new Vector(); @@ -79,18 +77,58 @@ public abstract class TmfTrace extends TmfEventProvider i // The time span of the event stream private TmfTimestamp fStartTime = TmfTimestamp.BigCrunch; - private TmfTimestamp fEndTime = TmfTimestamp.BigBang; + private TmfTimestamp fEndTime = TmfTimestamp.BigBang; // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ + public TmfTrace() { + } + + @Override + public void initTrace(String path, Class eventType) throws FileNotFoundException { + initTrace(path, eventType, DEFAULT_INDEX_PAGE_SIZE, false); + } + + @Override + public void initTrace(String path, Class eventType, int cacheSize) throws FileNotFoundException { + initTrace(path, eventType, cacheSize, false); + } + + @Override + public void initTrace(String path, Class eventType, boolean indexTrace) throws FileNotFoundException { + initTrace(path, eventType, DEFAULT_INDEX_PAGE_SIZE, indexTrace); + } + + @Override + public void initTrace(String path, Class eventType, int cacheSize, boolean indexTrace) throws FileNotFoundException { + String simpleName = ""; //$NON-NLS-1$ + fPath = path; + if (path != null) { + int sep = path.lastIndexOf(File.separator); + simpleName = (sep >= 0) ? path.substring(sep + 1) : path; + } + super.init(simpleName, eventType); + + fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE; + + if (indexTrace) + indexTrace(false); + } + + @Override + public boolean validate(IProject project, String path) { + File file = new File(path); + return file.exists(); + } + /** * @param path * @throws FileNotFoundException */ protected TmfTrace(String name, Class type, String path) throws FileNotFoundException { - this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, true); + this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, true); } /** @@ -99,7 +137,7 @@ public abstract class TmfTrace extends TmfEventProvider i * @throws FileNotFoundException */ protected TmfTrace(String name, Class type, String path, int cacheSize) throws FileNotFoundException { - this(name, type, path, cacheSize, true); + this(name, type, path, cacheSize, true); } /** @@ -108,7 +146,7 @@ public abstract class TmfTrace extends TmfEventProvider i * @throws FileNotFoundException */ protected TmfTrace(String name, Class type, String path, boolean indexTrace) throws FileNotFoundException { - this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, indexTrace); + this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, indexTrace); } /** @@ -118,16 +156,16 @@ public abstract class TmfTrace extends TmfEventProvider i * @throws FileNotFoundException */ protected TmfTrace(String name, Class type, String path, int cacheSize, boolean indexTrace) throws FileNotFoundException { - super(name, type); - if (path != null) { - int sep = path.lastIndexOf(File.separator); - String simpleName = (sep >= 0) ? path.substring(sep + 1) : path; - setName(simpleName); - } - fPath = path; + super(name, type); + if (path != null) { + int sep = path.lastIndexOf(File.separator); + String simpleName = (sep >= 0) ? path.substring(sep + 1) : path; + setName(simpleName); + } + fPath = path; fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE; if (indexTrace) { - indexTrace(false); + indexTrace(false); } } @@ -135,13 +173,13 @@ public abstract class TmfTrace extends TmfEventProvider i * @see java.lang.Object#clone() */ @SuppressWarnings("unchecked") - @Override - public TmfTrace clone() throws CloneNotSupportedException { - TmfTrace clone = (TmfTrace) super.clone(); - clone.fCheckpoints = (Vector) fCheckpoints; - clone.fStartTime = new TmfTimestamp(fStartTime); - clone.fEndTime = new TmfTimestamp(fEndTime); - return clone; + @Override + public TmfTrace clone() throws CloneNotSupportedException { + TmfTrace clone = (TmfTrace) super.clone(); + clone.fCheckpoints = fCheckpoints; + clone.fStartTime = new TmfTimestamp(fStartTime); + clone.fEndTime = new TmfTimestamp(fEndTime); + return clone; } // ------------------------------------------------------------------------ @@ -152,7 +190,7 @@ public abstract class TmfTrace extends TmfEventProvider i * @return the trace path */ @Override - public String getPath() { + public String getPath() { return fPath; } @@ -160,7 +198,7 @@ public abstract class TmfTrace extends TmfEventProvider i * @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getNbEvents() */ @Override - public long getNbEvents() { + public long getNbEvents() { return fNbEvents; } @@ -168,7 +206,7 @@ public abstract class TmfTrace extends TmfEventProvider i * @return the size of the cache */ @Override - public int getCacheSize() { + public int getCacheSize() { return fIndexPageSize; } @@ -176,7 +214,7 @@ public abstract class TmfTrace extends TmfEventProvider i * @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getTimeRange() */ @Override - public TmfTimeRange getTimeRange() { + public TmfTimeRange getTimeRange() { return new TmfTimeRange(fStartTime, fEndTime); } @@ -184,32 +222,32 @@ public abstract class TmfTrace extends TmfEventProvider i * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getStartTime() */ @Override - public TmfTimestamp getStartTime() { - return fStartTime; + public TmfTimestamp getStartTime() { + return fStartTime; } /* (non-Javadoc) * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getEndTime() */ @Override - public TmfTimestamp getEndTime() { - return fEndTime; + public TmfTimestamp getEndTime() { + return fEndTime; } @SuppressWarnings("unchecked") - public Vector getCheckpoints() { - return (Vector) fCheckpoints.clone(); + public Vector getCheckpoints() { + return (Vector) fCheckpoints.clone(); } /** - * Returns the rank of the first event with the requested timestamp. - * If none, returns the index of the next event (if any). - * + * Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event + * (if any). + * * @param timestamp * @return */ @Override - public long getRank(TmfTimestamp timestamp) { + public long getRank(TmfTimestamp timestamp) { TmfContext context = seekEvent(timestamp); return context.getRank(); } @@ -219,67 +257,66 @@ public abstract class TmfTrace extends TmfEventProvider i // ------------------------------------------------------------------------ protected void setTimeRange(TmfTimeRange range) { - fStartTime = range.getStartTime(); - fEndTime = range.getEndTime(); + fStartTime = range.getStartTime(); + fEndTime = range.getEndTime(); } protected void setStartTime(TmfTimestamp startTime) { - fStartTime = startTime; + fStartTime = startTime; } protected void setEndTime(TmfTimestamp endTime) { - fEndTime = endTime; - } - - // ------------------------------------------------------------------------ - // TmfProvider - // ------------------------------------------------------------------------ - - @Override - public ITmfContext armRequest(ITmfDataRequest request) { - if (request instanceof ITmfEventRequest && - !TmfTimestamp.BigBang.equals(((ITmfEventRequest) request).getRange().getStartTime()) && - request.getIndex() == 0) { - ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime()); - ((ITmfEventRequest) request).setStartIndex((int) context.getRank()); - return context; - - } - return seekEvent(request.getIndex()); - } - - /** - * Return the next piece of data based on the context supplied. The context - * would typically be updated for the subsequent read. - * - * @param context - * @return - */ - @SuppressWarnings("unchecked") - @Override - public T getNext(ITmfContext context) { - if (context instanceof TmfContext) { - return (T) getNextEvent((TmfContext) context); - } - return null; - } - - // ------------------------------------------------------------------------ - // ITmfTrace - // ------------------------------------------------------------------------ + fEndTime = endTime; + } + + // ------------------------------------------------------------------------ + // TmfProvider + // ------------------------------------------------------------------------ + + @Override + public ITmfContext armRequest(ITmfDataRequest request) { + if (request instanceof ITmfEventRequest + && !TmfTimestamp.BigBang.equals(((ITmfEventRequest) request).getRange().getStartTime()) && request.getIndex() == 0) { + ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime()); + ((ITmfEventRequest) request).setStartIndex((int) context.getRank()); + return context; + + } + return seekEvent(request.getIndex()); + } + + /** + * Return the next piece of data based on the context supplied. The context would typically be updated for the + * subsequent read. + * + * @param context + * @return + */ + @SuppressWarnings("unchecked") + @Override + public T getNext(ITmfContext context) { + if (context instanceof TmfContext) { + return (T) getNextEvent((TmfContext) context); + } + return null; + } + + // ------------------------------------------------------------------------ + // ITmfTrace + // ------------------------------------------------------------------------ /* (non-Javadoc) * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.event.TmfTimestamp) */ @Override - public TmfContext seekEvent(TmfTimestamp timestamp) { + public TmfContext seekEvent(TmfTimestamp timestamp) { - if (timestamp == null) { - timestamp = TmfTimestamp.BigBang; - } + if (timestamp == null) { + timestamp = TmfTimestamp.BigBang; + } - // First, find the right checkpoint - int index = Collections.binarySearch(fCheckpoints, new TmfCheckpoint(timestamp, null)); + // First, find the right checkpoint + int index = Collections.binarySearch(fCheckpoints, new TmfCheckpoint(timestamp, null)); // In the very likely case that the checkpoint was not found, bsearch // returns its negated would-be location (not an offset...). From that @@ -291,15 +328,14 @@ public abstract class TmfTrace extends TmfEventProvider i // Position the stream at the checkpoint ITmfLocation location; synchronized (fCheckpoints) { - if (fCheckpoints.size() > 0) { - if (index >= fCheckpoints.size()) { - index = fCheckpoints.size() - 1; - } - location = fCheckpoints.elementAt(index).getLocation(); - } - else { - location = null; - } + if (fCheckpoints.size() > 0) { + if (index >= fCheckpoints.size()) { + index = fCheckpoints.size() - 1; + } + location = fCheckpoints.elementAt(index).getLocation(); + } else { + location = null; + } } TmfContext context = seekLocation(location); context.setRank(index * fIndexPageSize); @@ -308,9 +344,9 @@ public abstract class TmfTrace extends TmfEventProvider i TmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype... TmfEvent event = getNextEvent(nextEventContext); while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) { - context.setLocation(nextEventContext.getLocation().clone()); - context.updateRank(1); - event = getNextEvent(nextEventContext); + context.setLocation(nextEventContext.getLocation().clone()); + context.updateRank(1); + event = getNextEvent(nextEventContext); } return context; @@ -320,21 +356,20 @@ public abstract class TmfTrace extends TmfEventProvider i * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(int) */ @Override - public TmfContext seekEvent(long rank) { + public TmfContext seekEvent(long rank) { // Position the stream at the previous checkpoint int index = (int) rank / fIndexPageSize; ITmfLocation location; synchronized (fCheckpoints) { - if (fCheckpoints.size() == 0) { - location = null; - } - else { - if (index >= fCheckpoints.size()) { - index = fCheckpoints.size() - 1; - } - location = fCheckpoints.elementAt(index).getLocation(); - } + if (fCheckpoints.size() == 0) { + location = null; + } else { + if (index >= fCheckpoints.size()) { + index = fCheckpoints.size() - 1; + } + location = fCheckpoints.elementAt(index).getLocation(); + } } TmfContext context = seekLocation(location); @@ -344,121 +379,112 @@ public abstract class TmfTrace extends TmfEventProvider i if (pos < rank) { TmfEvent event = getNextEvent(context); while (event != null && ++pos < rank) { - event = getNextEvent(context); + event = getNextEvent(context); } } return context; } - /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getNextEvent(org.eclipse.linuxtools.tmf.trace.ITmfTrace.TraceContext) - */ - @Override - public synchronized TmfEvent getNextEvent(TmfContext context) { - // parseEvent() does not update the context - TmfEvent event = parseEvent(context); - if (event != null) { - updateIndex(context, context.getRank(), event.getTimestamp()); - context.setLocation(getCurrentLocation()); - context.updateRank(1); - processEvent(event); - } - return event; - } - - protected synchronized void updateIndex(ITmfContext context, long rank, TmfTimestamp timestamp) { - if (fStartTime.compareTo(timestamp, false) > 0) fStartTime = timestamp; - if (fEndTime.compareTo(timestamp, false) < 0) fEndTime = timestamp; - if (context.isValidRank()) { - if (fNbEvents <= rank) - fNbEvents = rank + 1; - // Build the index as we go along - if ((rank % fIndexPageSize) == 0) { - // Determine the table position - long position = rank / fIndexPageSize; - // Add new entry at proper location (if empty) - if (fCheckpoints.size() == position) { - ITmfLocation location = context.getLocation().clone(); - fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location)); -// System.out.println(getName() + "[" + (fCheckpoints.size() - 1) + "] " + timestamp + ", " + location.toString()); - } - } - } - } + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getNextEvent(org.eclipse. + * linuxtools.tmf.trace.ITmfTrace.TraceContext) + */ + @Override + public synchronized TmfEvent getNextEvent(TmfContext context) { + // parseEvent() does not update the context + TmfEvent event = parseEvent(context); + if (event != null) { + updateIndex(context, context.getRank(), event.getTimestamp()); + context.setLocation(getCurrentLocation()); + context.updateRank(1); + processEvent(event); + } + return event; + } - /** - * Hook for "special" processing by the concrete class - * (called by getNextEvent()) - * - * @param event - */ - protected void processEvent(TmfEvent event) { - // Do nothing by default - } + protected synchronized void updateIndex(ITmfContext context, long rank, TmfTimestamp timestamp) { + if (fStartTime.compareTo(timestamp, false) > 0) + fStartTime = timestamp; + if (fEndTime.compareTo(timestamp, false) < 0) + fEndTime = timestamp; + if (context.isValidRank()) { + if (fNbEvents <= rank) + fNbEvents = rank + 1; + // Build the index as we go along + if ((rank % fIndexPageSize) == 0) { + // Determine the table position + long position = rank / fIndexPageSize; + // Add new entry at proper location (if empty) + if (fCheckpoints.size() == position) { + ITmfLocation location = context.getLocation().clone(); + fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location)); + // System.out.println(getName() + "[" + (fCheckpoints.size() + // - 1) + "] " + timestamp + ", " + location.toString()); + } + } + } + } /** - * To be implemented by the concrete class + * Hook for special processing by the concrete class (called by getNextEvent()) + * + * @param event + */ + protected void processEvent(TmfEvent event) { + // Do nothing by default + } + + // ------------------------------------------------------------------------ + // toString + // ------------------------------------------------------------------------ + + /* (non-Javadoc) + * @see java.lang.Object#toString() */ @Override - public abstract TmfContext seekLocation(ITmfLocation location); - @Override - public abstract ITmfLocation getCurrentLocation(); - @Override - public abstract TmfEvent parseEvent(TmfContext context); - @Override - public abstract TmfContext seekLocation(double ratio); - @Override - public abstract double getLocationRatio(ITmfLocation location); - - // ------------------------------------------------------------------------ - // toString - // ------------------------------------------------------------------------ - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - @SuppressWarnings("nls") - public String toString() { - return "[TmfTrace (" + getName() + ")]"; - } - + @SuppressWarnings("nls") + public String toString() { + return "[TmfTrace (" + getName() + ")]"; + } + // ------------------------------------------------------------------------ // Indexing // ------------------------------------------------------------------------ - /* - * The purpose of the index is to keep the information needed to rapidly - * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE - * event). - */ + /* + * The purpose of the index is to keep the information needed to rapidly + * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE + * event). + */ @SuppressWarnings({ "unchecked" }) protected void indexTrace(boolean waitForCompletion) { - final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$ - @Override - protected IStatus run(IProgressMonitor monitor) { - while (!monitor.isCanceled()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - return Status.OK_STATUS; - } - } - monitor.done(); - return Status.OK_STATUS; - } - }; - job.schedule(); - - fCheckpoints.clear(); - ITmfEventRequest request = new TmfEventRequest(TmfEvent.class, TmfTimeRange.Eternity, - TmfDataRequest.ALL_DATA, fIndexPageSize, ITmfDataRequest.ExecutionType.BACKGROUND) { - - TmfTimestamp startTime = null; - TmfTimestamp lastTime = null; + final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$ + @Override + protected IStatus run(IProgressMonitor monitor) { + while (!monitor.isCanceled()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + return Status.OK_STATUS; + } + } + monitor.done(); + return Status.OK_STATUS; + } + }; + job.schedule(); + + fCheckpoints.clear(); + ITmfEventRequest request = new TmfEventRequest(TmfEvent.class, TmfTimeRange.Eternity, TmfDataRequest.ALL_DATA, + fIndexPageSize, ITmfDataRequest.ExecutionType.BACKGROUND) { + + TmfTimestamp startTime = null; + TmfTimestamp lastTime = null; @Override public void handleData(TmfEvent event) { @@ -482,8 +508,8 @@ public abstract class TmfTrace extends TmfEventProvider i @Override public void handleCompleted() { - job.cancel(); - super.handleCompleted(); + job.cancel(); + super.handleCompleted(); } private void updateTrace() { @@ -491,7 +517,7 @@ public abstract class TmfTrace extends TmfEventProvider i if (nbRead != 0) { fStartTime = startTime; fEndTime = lastTime; - fNbEvents = nbRead; + fNbEvents = nbRead; notifyListeners(); } } @@ -506,7 +532,7 @@ public abstract class TmfTrace extends TmfEventProvider i } } - protected void notifyListeners() { - broadcast(new TmfTraceUpdatedSignal(this, this, new TmfTimeRange(fStartTime, fEndTime))); - } + protected void notifyListeners() { + broadcast(new TmfTraceUpdatedSignal(this, this, new TmfTimeRange(fStartTime, fEndTime))); + } } diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/util/TmfSortedArrayList.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/util/TmfSortedArrayList.java new file mode 100644 index 0000000000..ceb39c5706 --- /dev/null +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/util/TmfSortedArrayList.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 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.tmf.util; + +import java.util.ArrayList; + +/** + * TmfSortedArrayList + *

    + */ + +public class TmfSortedArrayList extends ArrayList { + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unchecked") + public void insertSorted(T value) { + add(value); + Comparable cmp = (Comparable) value; + for (int pos = size() - 1; pos > 0 && cmp.compareTo(get(pos - 1)) < 0; pos--) { + T tmp = get(pos); + set(pos, get(pos - 1)); + set(pos - 1, tmp); + } + } + +} -- 2.34.1