summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-13 02:17:48 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-13 02:17:48 +0900
commit9a5aaee9ae21a2492d3da98a5116aed805834c13 (patch)
treeb8d2e7f35889963c81c5120c372c4b4ae53b1382
parentec689998db7ad70d4828ff52fc70ee0666af3bbf (diff)
downloadcodecoverage-eplugin-9a5aaee9ae21a2492d3da98a5116aed805834c13.tar.gz
codecoverage-eplugin-9a5aaee9ae21a2492d3da98a5116aed805834c13.tar.bz2
codecoverage-eplugin-9a5aaee9ae21a2492d3da98a5116aed805834c13.zip
Tizen 2.1 base
-rw-r--r--AUTHORS3
-rw-r--r--LICENSE.EPL261
-rw-r--r--NOTICE3
-rw-r--r--builder/build.properties.clean259
-rw-r--r--builder/customTargets.xml187
-rw-r--r--org.eclipse.linuxtools.binutils/.classpath7
-rw-r--r--org.eclipse.linuxtools.binutils/.project28
-rw-r--r--org.eclipse.linuxtools.binutils/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--org.eclipse.linuxtools.binutils/META-INF/MANIFEST.MF23
-rw-r--r--org.eclipse.linuxtools.binutils/about.html26
-rw-r--r--org.eclipse.linuxtools.binutils/build.properties16
-rw-r--r--org.eclipse.linuxtools.binutils/icons/c_file_obj.gifbin0 -> 354 bytes
-rw-r--r--org.eclipse.linuxtools.binutils/plugin.properties13
-rw-r--r--org.eclipse.linuxtools.binutils/plugin.xml15
-rw-r--r--org.eclipse.linuxtools.binutils/schema/org.eclipse.linuxtools.binutils.crossCompile.exsd109
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/Activator.java60
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java232
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditorInput.java155
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java557
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/DefaultBinutilsFactory.java46
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/ISTBinutilsFactory.java31
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2LineFactory.java36
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2line.java50
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STBinutilsFactoryManager.java90
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STCPPFiltFactory.java38
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNM.java110
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMFactory.java29
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMSymbolsHandler.java23
-rw-r--r--org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java591
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.classpath7
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.project28
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.core.prefs3
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/META-INF/MANIFEST.MF24
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/about.html28
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/build.properties8
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/icons/c_file_obj.gifbin0 -> 617 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.properties12
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.xml58
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/AbstractSTAnnotatedSourceEditorInput.java82
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTAnnotationColumn.java19
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionConstants.java19
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionDefinitionIds.java20
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedCSourceEditor.java449
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedSourceEditorActivator.java76
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STChangeRulerColumn.java390
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STConstructedTextEditorMessages.properties4
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STContributedRulerColumn.java798
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STJFaceTextMessages.java67
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STOverviewRuler.java1309
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerColumn.java876
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerMessages.java34
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STTextEditorMessages.java37
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/AbstractOpenSourceFileAction.java93
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenFileFullPathAction.java32
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenWksRelFilePathAction.java63
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/hyperlink/ISTAnnotationHyperlink.java17
-rw-r--r--org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/preferencespages/STAnnotatedSourceEditorPreferencePage.java59
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/.classpath7
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/.project28
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF26
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/about.html26
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/build.properties8
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/icons/Thumbs.dbbin0 -> 3584 bytes
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/icons/chart_icon.pngbin0 -> 573 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/icons/dexport.gifbin0 -> 142 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/icons/dimport.gifbin0 -> 143 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/icons/eexport.gifbin0 -> 329 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/icons/eimport.gifbin0 -> 327 bytes
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/icons/save_chart.gifbin0 -> 583 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/plugin.properties14
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/plugin.xml21
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/Activator.java88
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/ChartConstants.java85
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/UIHelper.java143
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java67
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartActionRenderer.java46
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/OpenChartAction.java77
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveChartAction.java286
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction.java133
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/BindDataEngine.java364
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSource.java70
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSourceFactory.java40
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/GroupedRowExpressionsEvaluator.java280
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dialogs/ChartDialog.java427
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java251
-rw-r--r--org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartUpdateNotifier.java41
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/IChartField.java30
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/view/ChartView.java204
-rwxr-xr-xorg.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/viewer/ChartViewer.java252
-rw-r--r--org.eclipse.linuxtools.dataviewers/.classpath11
-rw-r--r--org.eclipse.linuxtools.dataviewers/.project28
-rw-r--r--org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.core.prefs74
-rw-r--r--org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF23
-rw-r--r--org.eclipse.linuxtools.dataviewers/about.html28
-rw-r--r--org.eclipse.linuxtools.dataviewers/build.properties23
-rw-r--r--org.eclipse.linuxtools.dataviewers/doc/AbstractSTProfViewers.pptbin0 -> 52736 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/doc/DataViewersFind.html69
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/backward_nav.gifbin0 -> 327 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/bin_obj.gifbin0 -> 156 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/collapse_all.gifbin0 -> 157 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/exec_obj.gifbin0 -> 125 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/expand_all.gifbin0 -> 165 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/export.gifbin0 -> 329 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/filter_ps.gifbin0 -> 219 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/flexperf.gifbin0 -> 1380 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/forward_nav.gifbin0 -> 215 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/function_obj.gifbin0 -> 97 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/info_obj.gifbin0 -> 121 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/left-end.gifbin0 -> 106 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/left.gifbin0 -> 98 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/percentage.gifbin0 -> 599 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/pie.gifbin0 -> 582 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/printer.gifbin0 -> 1037 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/prop_edt.gifbin0 -> 571 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/right-end.gifbin0 -> 104 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/right.gifbin0 -> 98 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/sample.gifbin0 -> 983 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/search.gifbin0 -> 347 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/sort.gifbin0 -> 162 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/st.gifbin0 -> 329 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/toggle.gifbin0 -> 610 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/icons/variable_obj.gifbin0 -> 78 bytes
-rw-r--r--org.eclipse.linuxtools.dataviewers/plugin.properties12
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/STDataViewersActivator.java85
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractview/AbstractSTDataView.java506
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractPercentageDrawerField.java99
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTDataViewersField.java140
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTableViewer.java242
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTreeViewer.java252
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTViewer.java740
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/ISTDataViewersField.java154
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java778
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporterConstants.java41
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersColumnLabelProvider.java96
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersComparator.java352
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHideShowManager.java247
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHyperLinkDrawerField.java57
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersImages.java197
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.java62
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.properties37
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersSettings.java33
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STOwnerDrawLabelProvider.java90
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseAllTreeAction.java47
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseSelectionAction.java53
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCopyAction.java66
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersFiltersAction.java32
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersSortAction.java73
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandAllTreeAction.java47
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandSelectionAction.java53
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExportToCSVAction.java78
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STHideShowColAction.java59
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java675
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersHideShowColumnsDialog.java254
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java361
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.java125
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.properties120
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/ISTFindReplaceTarget.java83
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExContentProposalProvider.java375
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExMessages.java200
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceAction.java330
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceDialog.java1605
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableFindReplaceTarget.java291
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableViewerRow.java198
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeFindReplaceTarget.java296
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeViewerRow.java315
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/ISpecialDrawerListener.java17
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STColumnSizeListener.java36
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STDisposeListener.java29
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STHeaderListener.java66
-rw-r--r--org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STSelectionProvider.java63
-rwxr-xr-xorg.eclipse.linuxtools.gcov-feature/.project17
-rwxr-xr-xorg.eclipse.linuxtools.gcov-feature/build.properties8
-rwxr-xr-xorg.eclipse.linuxtools.gcov-feature/epl-v10.html256
-rwxr-xr-xorg.eclipse.linuxtools.gcov-feature/feature.properties138
-rwxr-xr-xorg.eclipse.linuxtools.gcov-feature/feature.xml59
-rw-r--r--org.eclipse.linuxtools.gcov-feature/license.html107
-rw-r--r--org.eclipse.linuxtools.gcov.test/.classpath7
-rw-r--r--org.eclipse.linuxtools.gcov.test/.project28
-rw-r--r--org.eclipse.linuxtools.gcov.test/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF9
-rw-r--r--org.eclipse.linuxtools.gcov.test/about.html33
-rw-r--r--org.eclipse.linuxtools.gcov.test/build.properties9
-rw-r--r--org.eclipse.linuxtools.gcov.test/plugin.properties12
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/AllGcovTests.java29
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovGCDARetrieverTest.java68
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovParserTest.java59
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovTestUtils.java66
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovViewTest.java111
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/STJunitUtils.java267
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/test.xml54
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/Makefile8
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/test_c/a.outbin0 -> 30722 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/fact.c19
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/fact.gcdabin0 -> 168 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/fact.gcnobin0 -> 480 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/main.c28
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/main.gcdabin0 -> 176 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/main.gcnobin0 -> 676 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/mult.c21
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/mult.gcdabin0 -> 152 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/mult.gcnobin0 -> 500 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/testProcessCovFiles.ref30
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/testView.ref8
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/testViewFolder.ref9
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_c/testViewFunction.ref5
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/Makefile8
-rwxr-xr-xorg.eclipse.linuxtools.gcov.test/test_cpp/a.outbin0 -> 34593 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/fact.cpp31
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcdabin0 -> 320 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcnobin0 -> 1268 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/fact.hpp26
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/main.cpp30
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/main.gcdabin0 -> 864 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/main.gcnobin0 -> 8992 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/mult.cpp29
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcdabin0 -> 280 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcnobin0 -> 1140 bytes
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/mult.hpp22
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/testProcessCovFiles.ref148
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/testView.ref36
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/testViewFolder.ref39
-rw-r--r--org.eclipse.linuxtools.gcov.test/test_cpp/testViewFunction.ref27
-rw-r--r--org.eclipse.linuxtools.gcov/.classpath7
-rw-r--r--org.eclipse.linuxtools.gcov/.project28
-rw-r--r--org.eclipse.linuxtools.gcov/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--org.eclipse.linuxtools.gcov/META-INF/MANIFEST.MF32
-rw-r--r--org.eclipse.linuxtools.gcov/NOTICE6
-rw-r--r--org.eclipse.linuxtools.gcov/about.html28
-rw-r--r--org.eclipse.linuxtools.gcov/build.properties8
-rw-r--r--org.eclipse.linuxtools.gcov/icons/c_file_obj.gifbin0 -> 1019 bytes
-rw-r--r--org.eclipse.linuxtools.gcov/icons/directory_obj.gifbin0 -> 162 bytes
-rw-r--r--org.eclipse.linuxtools.gcov/icons/function_obj.gifbin0 -> 617 bytes
-rw-r--r--org.eclipse.linuxtools.gcov/icons/src_file_obj.gifbin0 -> 617 bytes
-rw-r--r--org.eclipse.linuxtools.gcov/icons/toggle.gifbin0 -> 610 bytes
-rw-r--r--org.eclipse.linuxtools.gcov/plugin.properties16
-rw-r--r--org.eclipse.linuxtools.gcov/plugin.xml38
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/Activator.java71
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/OpenGCAction.java166
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/SwitchContentProviderAction.java44
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/dialog/OpenGCDialog.java303
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/AbstractTreeElement.java79
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFileTreeElement.java25
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFolderTreeElement.java24
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFunctionTreeElement.java57
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovRootTreeElement.java26
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/TreeElement.java27
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Arc.java131
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Block.java177
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CovManager.java372
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CoverageInfo.java52
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Folder.java65
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcdaRecordsParser.java272
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoFunction.java255
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoRecordsParser.java241
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Line.java50
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/SourceFile.java110
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/BEDataInputStream.java191
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/GcovStringReader.java38
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/LEDataInputStream.java208
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/MasksGenerator.java15
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java85
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFileContentProvider.java60
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFolderContentProvider.java61
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFunctionContentProvider.java52
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovView.java289
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovViewer.java119
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldCoveragePercentage.java100
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldExecutedLines.java68
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldInstrumentedLines.java77
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldName.java69
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldTotalLines.java82
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/CoverageAnnotationColumn.java79
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/OpenSourceFileAction.java136
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceEditorInput.java73
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java50
-rw-r--r--org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditorInput.java69
-rw-r--r--org.tizen.codecoverage.feature/.project17
-rw-r--r--org.tizen.codecoverage.feature/build.properties2
-rw-r--r--org.tizen.codecoverage.feature/feature.properties41
-rw-r--r--org.tizen.codecoverage.feature/feature.xml183
-rw-r--r--org.tizen.codecoverage.update/.project17
-rw-r--r--org.tizen.codecoverage/.classpath7
-rw-r--r--org.tizen.codecoverage/.project28
-rw-r--r--org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs72
-rw-r--r--org.tizen.codecoverage/32_TIZEN_SDK_icon.pngbin0 -> 5237 bytes
-rw-r--r--org.tizen.codecoverage/META-INF/MANIFEST.MF22
-rw-r--r--org.tizen.codecoverage/NOTICE2
-rw-r--r--org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties2
-rw-r--r--org.tizen.codecoverage/about.ini32
-rw-r--r--org.tizen.codecoverage/about.mappings6
-rw-r--r--org.tizen.codecoverage/about.properties12
-rw-r--r--org.tizen.codecoverage/build.properties11
-rw-r--r--org.tizen.codecoverage/icons/toolbar_icon.gifbin0 -> 610 bytes
-rw-r--r--org.tizen.codecoverage/plugin.xml31
-rw-r--r--org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java70
-rw-r--r--org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java112
-rw-r--r--org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java176
-rwxr-xr-xpackage/build.linux72
-rw-r--r--package/changelog15
-rw-r--r--package/pkginfo.manifest38
302 files changed, 28534 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..545dff2
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Kangho Kim <kh5325.kim@samsung.com>
+Gun Kim <gune.kim@samsung.com>
+HyunGoo Kang <hyungoo1.kang@samsung.com>
diff --git a/LICENSE.EPL b/LICENSE.EPL
new file mode 100644
index 0000000..3998fce
--- /dev/null
+++ b/LICENSE.EPL
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Public License - Version 1.0</title>
+<style type="text/css">
+ body {
+ size: 8.5in 11.0in;
+ margin: 0.25in 0.5in 0.25in 0.5in;
+ tab-interval: 0.5in;
+ }
+ p {
+ margin-left: auto;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ p.list {
+ margin-left: 0.5in;
+ margin-top: 0.05em;
+ margin-bottom: 0.05em;
+ }
+ </style>
+
+</head>
+
+<body lang="EN-US">
+
+<h2>Eclipse Public License - v 1.0</h2>
+
+<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+AGREEMENT.</p>
+
+<p><b>1. DEFINITIONS</b></p>
+
+<p>&quot;Contribution&quot; means:</p>
+
+<p class="list">a) in the case of the initial Contributor, the initial
+code and documentation distributed under this Agreement, and</p>
+<p class="list">b) in the case of each subsequent Contributor:</p>
+<p class="list">i) changes to the Program, and</p>
+<p class="list">ii) additions to the Program;</p>
+<p class="list">where such changes and/or additions to the Program
+originate from and are distributed by that particular Contributor. A
+Contribution 'originates' from a Contributor if it was added to the
+Program by such Contributor itself or anyone acting on such
+Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.</p>
+
+<p>&quot;Contributor&quot; means any person or entity that distributes
+the Program.</p>
+
+<p>&quot;Licensed Patents&quot; mean patent claims licensable by a
+Contributor which are necessarily infringed by the use or sale of its
+Contribution alone or when combined with the Program.</p>
+
+<p>&quot;Program&quot; means the Contributions distributed in accordance
+with this Agreement.</p>
+
+<p>&quot;Recipient&quot; means anyone who receives the Program under
+this Agreement, including all Contributors.</p>
+
+<p><b>2. GRANT OF RIGHTS</b></p>
+
+<p class="list">a) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works
+of, publicly display, publicly perform, distribute and sublicense the
+Contribution of such Contributor, if any, and such derivative works, in
+source code and object code form.</p>
+
+<p class="list">b) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell,
+offer to sell, import and otherwise transfer the Contribution of such
+Contributor, if any, in source code and object code form. This patent
+license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to be covered
+by the Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.</p>
+
+<p class="list">c) Recipient understands that although each Contributor
+grants the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to
+secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow Recipient
+to distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.</p>
+
+<p class="list">d) Each Contributor represents that to its knowledge it
+has sufficient copyright rights in its Contribution, if any, to grant
+the copyright license set forth in this Agreement.</p>
+
+<p><b>3. REQUIREMENTS</b></p>
+
+<p>A Contributor may choose to distribute the Program in object code
+form under its own license agreement, provided that:</p>
+
+<p class="list">a) it complies with the terms and conditions of this
+Agreement; and</p>
+
+<p class="list">b) its license agreement:</p>
+
+<p class="list">i) effectively disclaims on behalf of all Contributors
+all warranties and conditions, express and implied, including warranties
+or conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;</p>
+
+<p class="list">ii) effectively excludes on behalf of all Contributors
+all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;</p>
+
+<p class="list">iii) states that any provisions which differ from this
+Agreement are offered by that Contributor alone and not by any other
+party; and</p>
+
+<p class="list">iv) states that source code for the Program is available
+from such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for software
+exchange.</p>
+
+<p>When the Program is made available in source code form:</p>
+
+<p class="list">a) it must be made available under this Agreement; and</p>
+
+<p class="list">b) a copy of this Agreement must be included with each
+copy of the Program.</p>
+
+<p>Contributors may not remove or alter any copyright notices contained
+within the Program.</p>
+
+<p>Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.</p>
+
+<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
+
+<p>Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+(&quot;Commercial Contributor&quot;) hereby agrees to defend and
+indemnify every other Contributor (&quot;Indemnified Contributor&quot;)
+against any losses, damages and costs (collectively &quot;Losses&quot;)
+arising from claims, lawsuits and other legal actions brought by a third
+party against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In
+order to qualify, an Indemnified Contributor must: a) promptly notify
+the Commercial Contributor in writing of such claim, and b) allow the
+Commercial Contributor to control, and cooperate with the Commercial
+Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own
+expense.</p>
+
+<p>For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.</p>
+
+<p><b>5. NO WARRANTY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable laws,
+damage to or loss of data, programs or equipment, and unavailability or
+interruption of operations.</p>
+
+<p><b>6. DISCLAIMER OF LIABILITY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
+
+<p><b>7. GENERAL</b></p>
+
+<p>If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further action
+by the parties hereto, such provision shall be reformed to the minimum
+extent necessary to make such provision valid and enforceable.</p>
+
+<p>If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the
+date such litigation is filed.</p>
+
+<p>All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of time
+after becoming aware of such noncompliance. If all Recipient's rights
+under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.</p>
+
+<p>Everyone is permitted to copy and distribute copies of this
+Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The
+Agreement Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other than the
+Agreement Steward has the right to modify this Agreement. The Eclipse
+Foundation is the initial Agreement Steward. The Eclipse Foundation may
+assign the responsibility to serve as the Agreement Steward to a
+suitable separate entity. Each new version of the Agreement will be
+given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version
+of the Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
+rights or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.</p>
+
+<p>This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No party
+to this Agreement will bring a legal action under this Agreement more
+than one year after the cause of action arose. Each party waives its
+rights to a jury trial in any resulting litigation.</p>
+
+</body>
+
+</html> \ No newline at end of file
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..826ae80
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.EPL file for Apache License terms and conditions. \ No newline at end of file
diff --git a/builder/build.properties.clean b/builder/build.properties.clean
new file mode 100644
index 0000000..6f4998e
--- /dev/null
+++ b/builder/build.properties.clean
@@ -0,0 +1,259 @@
+###############################################################################
+# Copyright (c) 2003, 2006 IBM Corporation and others.
+# 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+#####################
+# Parameters describing how and where to execute the build.
+# Typical users need only update the following properties:
+# baseLocation - where things you are building against are installed
+# bootclasspath - The base jars to compile against (typicaly rt.jar)
+# configs - the list of {os, ws, arch} configurations to build.
+#
+# Of course any of the settings here can be overridden by spec'ing
+# them on the command line (e.g., -DbaseLocation=d:/eclipse
+
+#The type of the top level element we are building, generally "feature"
+topLevelElementType=feature
+#The id of the top level element we are building
+topLevelElementId=org.tizen.codecoverage.feature
+
+############# PRODUCT/PACKAGING CONTROL #############
+#runPackager=true
+
+#Set the name of the archive that will result from the product build.
+#archiveNamePrefix=
+
+# The prefix that will be used in the generated archive.
+archivePrefix=codecoverage
+
+# The location underwhich all of the build output will be collected.
+collectingFolder=${archivePrefix}
+
+# The list of {os, ws, arch} configurations to build. This
+# value is a '&' separated list of ',' separate triples. For example,
+# configs=win32,win32,x86 & linux,motif,x86
+# By default the value is *,*,*
+configs="Do not touch here."
+#configs=win32, win32, x86 & \
+# win32,win32,x86_64 & \
+# win32,win32,wpf & \
+# linux, gtk, ppc & \
+# linux, gtk, x86 & \
+# linux, gtk, x86_64 & \
+# linux, motif, x86 & \
+# solaris, motif, sparc & \
+# solaris, gtk, sparc & \
+# aix, motif, ppc & \
+# hpux, motif, ia64_32 & \
+# macosx, carbon, ppc & \
+# macosx, carbon, x86 & \
+# macosx, cocoa, ppc & \
+# macosx, cocoa, x86 & \
+# macosx, cocoa, x86_64
+
+# By default PDE creates one archive (result) per entry listed in the configs property.
+# Setting this value to true will cause PDE to only create one output containing all
+# artifacts for all the platforms listed in the configs property.
+# To control the output format for the group, add a "group, group, group - <format>" entry to the
+# archivesFormat.
+#groupConfigurations=true
+
+#The format of the archive. By default a zip is created using antZip.
+#The list can only contain the configuration for which the desired format is different than zip.
+#archivesFormat=win32, win32, x86 - antZip& \
+# linux, gtk, ppc - antZip &\
+# linux, gtk, x86 - antZip& \
+# linux, gtk, x86_64 - antZip& \
+# linux, motif, x86 - antZip& \
+# solaris, motif, sparc - antZip& \
+# solaris, gtk, sparc - antZip& \
+# aix, motif, ppc - antZip& \
+# hpux, motif, PA_RISC - antZip& \
+# macosx, carbon, ppc - antZip
+
+#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles.
+allowBinaryCycles=true
+
+#Sort bundles depenedencies across all features instead of just within a given feature.
+#flattenDependencies = true
+
+#Parallel compilation, requires flattenedDependencies=true
+#parallelCompilation=true
+#parallelThreadCount=
+#parallelThreadsPerProcessor=
+
+#Set to true if you want the output to be ready for an update jar (no site.xml generated)
+#outputUpdateJars = false
+
+#Set to true for Jnlp generation
+#codebase should be a URL that will be used as the root of all relative URLs in the output.
+#generateJnlp=false
+#jnlp.codebase=<codebase url>
+#jnlp.j2se=<j2se version>
+#jnlp.locale=<a locale>
+#jnlp.generateOfflineAllowed=true or false generate <offlineAllowed/> attribute in the generated features
+#jnlp.configs=${configs} #uncomment to filter the content of the generated jnlp files based on the configuration being built
+
+#Set to true if you want to sign jars
+#signJars=false
+#sign.alias=<alias>
+#sign.keystore=<keystore location>
+#sign.storepass=<keystore password>
+#sign.keypass=<key password>
+
+#Arguments to send to the zip executable
+#zipargs=
+
+#Arguments to send to the tar executable
+#tarargs=
+
+#Control the creation of a file containing the version included in each configuration - on by default
+#generateVersionsLists=false
+
+############## BUILD NAMING CONTROL ################
+# The directory into which the build elements are fetched and where
+# the build takes place.
+buildDirectory="Do not touch here"
+
+# Type of build. Used in naming the build output. Typically this value is
+# one of I, N, M, S, ...
+buildType="Do not touch here"
+
+# ID of the build. Used in naming the build output.
+buildId="Do not touch here"
+
+# Label for the build. Used in naming the build output
+buildLabel=${buildType}.${buildId}
+
+# Timestamp for the build. Used in naming the build output
+timestamp=007
+
+#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde.
+#The value will only be applied to plugin or features indicating build.properties, qualifier = context
+#forceContextQualifier=<the value for the qualifier>
+
+#Enable / disable the generation of a suffix for the features that use .qualifier.
+#The generated suffix is computed according to the content of the feature
+#generateFeatureVersionSuffix=true
+
+############# BASE CONTROL #############
+# Settings for the base Eclipse components and Java class libraries
+# against which you are building.
+# Base location for anything the build needs to compile against. For example,
+# in most RCP app or a plug-in, the baseLocation should be the location of a previously
+# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.
+
+base="Do not touch here"
+baseLocation="Do not touch here"
+
+
+#Folder containing repositories whose content is needed to compile against
+#repoBaseLocation=${base}/repos
+#Folder where the content of the repositories from ${repoBaseLocation} will be made available as a form suitable to be compiled against
+#transformedRepoLocation=${base}/transformedRepos
+
+#Os/Ws/Arch/nl of the eclipse specified by baseLocation
+baseos=linux
+basews=gtk
+basearch=x86
+
+#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built
+filteredDependencyCheck=false
+
+#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons)
+resolution.devMode=false
+
+#pluginPath is a list of locations in which to find plugins and features. This list is separated by the platform file separator (; or :)
+#a location is one of:
+#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo
+#- a directory that contains a /plugins or /features subdirectory
+#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml
+#pluginPath=
+
+skipBase=true
+eclipseURL=<url for eclipse download site>
+eclipseBuildId=<Id of Eclipse build to get>
+eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip
+
+
+############# MAP FILE CONTROL ################
+# This section defines CVS tags to use when fetching the map files from the repository.
+# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml
+
+skipMaps=true
+mapsRepo=:pserver:anonymous@example.com/path/to/repo
+mapsRoot=path/to/maps
+mapsCheckoutTag=HEAD
+
+#tagMaps=true
+mapsTagTag=v${buildId}
+
+
+############ REPOSITORY CONTROL ###############
+# This section defines properties parameterizing the repositories where plugins, fragments
+# bundles and features are being obtained from.
+
+# The tags to use when fetching elements to build.
+# By default thebuilder will use whatever is in the maps.
+# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the
+# overriding value
+# For example fetchTag=CVS=HEAD, SVN=v20050101
+# fetchTag=HEAD
+skipFetch=true
+
+
+############# P2 OPTIONS ##############
+#p2.gathering = true
+#p2.compress=true
+
+############# JAVA COMPILER OPTIONS ##############
+# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE
+#bootclasspath=${java.home}/lib/rt.jar
+
+# specific JRE locations to compile against. These values are used to compile bundles specifying a
+# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support
+#CDC-1.0/Foundation-1.0= /path/to/rt.jar
+#CDC-1.1/Foundation-1.1=
+#OSGi/Minimum-1.0=
+#OSGi/Minimum-1.1=
+#JRE-1.1=
+#J2SE-1.2=
+#J2SE-1.3=
+#J2SE-1.4=
+#J2SE-1.5=
+#JavaSE-1.6=
+#PersonalJava-1.1=
+#PersonalJava-1.2=
+#CDC-1.0/PersonalBasis-1.0=
+#CDC-1.0/PersonalJava-1.0=
+#CDC-1.1/PersonalBasis-1.1=
+#CDC-1.1/PersonalJava-1.1=
+
+# Specify the output format of the compiler log when eclipse jdt is used
+logExtension=.log
+
+# Whether or not to include debug info in the output jars
+javacDebugInfo=false
+
+# Whether or not to fail the build if there are compiler errors
+javacFailOnError=true
+
+# Enable or disable verbose mode of the compiler
+javacVerbose=true
+
+# Extra arguments for the compiler. These are specific to the java compiler being used.
+#compilerArg=
+
+# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
+javacSource=1.6
+
+# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
+javacTarget=1.6
+
+
diff --git a/builder/customTargets.xml b/builder/customTargets.xml
new file mode 100644
index 0000000..6a42e92
--- /dev/null
+++ b/builder/customTargets.xml
@@ -0,0 +1,187 @@
+<project name="Build specific targets and properties" default="noDefault">
+
+ <!-- ===================================================================== -->
+ <!-- Run a given ${target} on all elements being built -->
+ <!-- Add on <ant> task for each top level element being built. -->
+ <!-- ===================================================================== -->
+ <available property="allElementsFile" file="${builder}/allElements.xml" value="${builder}/allElements.xml"/>
+ <property name="allElementsFile" location="${eclipse.pdebuild.templates}/headless-build/allElements.xml"/>
+
+ <import file="${allElementsFile}" />
+ <target name="allElements">
+ <ant antfile="${genericTargets}" target="${target}">
+ <property name="type" value="${topLevelElementType}"/>
+ <property name="id" value="${topLevelElementId}"/>
+ </ant>
+ </target>
+
+ <target
+ name="assemble.${topLevelElementId}.linux.gtk.x86">
+ <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/>
+ </target>
+ <target
+ name="assemble.${topLevelElementId}.win32.win32.x86">
+ <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/>
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- ===================================================================== -->
+ <target name="getBaseComponents" depends="checkLocalBase" unless="skipBase">
+ <get src="${eclipseBaseURL}" dest="${buildDirectory}/../temp-base.zip" />
+ <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../temp-base.zip" />
+ </target>
+
+ <target name="checkLocalBase">
+ <available file="${base}" property="skipBase" />
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Check out map files from correct repository -->
+ <!-- Replace values for mapsCheckoutTag as desired. -->
+ <!-- ===================================================================== -->
+ <target name="getMapFiles" depends="checkLocalMaps" unless="skipMaps">
+ <property name="mapsCheckoutTag" value="HEAD" />
+ <cvs cvsRoot="${mapsRepo}" package="${mapsRoot}" dest="${buildDirectory}/maps" tag="${mapsCheckoutTag}" />
+ </target>
+
+ <target name="checkLocalMaps">
+ <available property="skipMaps" file="${buildDirectory}/maps" />
+ </target>
+
+ <target name="tagMapFiles" if="tagMaps">
+ <cvs dest="${buildDirectory}/maps/${mapsRoot}" command="tag ${mapsTagTag}" />
+ </target>
+
+ <!-- ===================================================================== -->
+
+ <target name="clean" unless="noclean">
+ <antcall target="allElements">
+ <param name="target" value="cleanElement" />
+ </antcall>
+ </target>
+
+ <target name="gatherLogs">
+ <mkdir dir="${buildDirectory}/${buildLabel}/compilelogs" />
+ <antcall target="allElements">
+ <param name="target" value="gatherLogs" />
+ </antcall>
+ <unzip dest="${buildDirectory}/${buildLabel}/compilelogs" overwrite="true">
+ <fileset dir="${buildDirectory}/features">
+ <include name="**/*.log.zip" />
+ </fileset>
+ </unzip>
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do before setup -->
+ <!-- ===================================================================== -->
+ <target name="preSetup">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after setup but before starting the build proper -->
+ <!-- ===================================================================== -->
+ <target name="postSetup">
+ <antcall target="getBaseComponents" />
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do before fetching the build elements -->
+ <!-- ===================================================================== -->
+ <target name="preFetch">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after fetching the build elements -->
+ <!-- ===================================================================== -->
+ <target name="postFetch">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do before the repositories are being processed -->
+ <!-- ===================================================================== -->
+ <target name="preProcessRepos">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after the repositories have been processed -->
+ <!-- ===================================================================== -->
+ <target name="postProcessRepos">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do before generating the build scripts. -->
+ <!-- ===================================================================== -->
+ <target name="preGenerate">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after generating the build scripts. -->
+ <!-- ===================================================================== -->
+ <target name="postGenerate">
+ <antcall target="clean" />
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do before running the build.xmls for the elements being built. -->
+ <!-- ===================================================================== -->
+ <target name="preProcess">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after running the build.xmls for the elements being built. -->
+ <!-- ===================================================================== -->
+ <target name="postProcess">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do before running assemble. -->
+ <!-- ===================================================================== -->
+ <target name="preAssemble">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after running assemble. -->
+ <!-- ===================================================================== -->
+ <target name="postAssemble">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do before running package. -->
+ <!-- ===================================================================== -->
+ <target name="prePackage">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after running package. -->
+ <!-- ===================================================================== -->
+ <target name="postPackage">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do after the build is done. -->
+ <!-- ===================================================================== -->
+ <target name="postBuild">
+ <antcall target="gatherLogs" />
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do to test the build results -->
+ <!-- ===================================================================== -->
+ <target name="test">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Steps to do to publish the build results -->
+ <!-- ===================================================================== -->
+ <target name="publish">
+ </target>
+
+ <!-- ===================================================================== -->
+ <!-- Default target -->
+ <!-- ===================================================================== -->
+ <target name="noDefault">
+ <echo message="You must specify a target when invoking this file" />
+ </target>
+
+</project>
diff --git a/org.eclipse.linuxtools.binutils/.classpath b/org.eclipse.linuxtools.binutils/.classpath
new file mode 100644
index 0000000..1ca8caa
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry excluding="**/.svn/**" kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.binutils/.project b/org.eclipse.linuxtools.binutils/.project
new file mode 100644
index 0000000..1a43e12
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.binutils</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.binutils/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.binutils/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d8d8799
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu Jan 15 16:35:12 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.linuxtools.binutils/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.binutils/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..26fbc39
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.binutils;singleton:=true
+Bundle-Version: 4.0.0.qualifier
+Bundle-Activator: org.eclipse.linuxtools.binutils.Activator
+Bundle-Vendor: %bundleProvider
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.filesystem,
+ org.eclipse.debug.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.cdt.core,
+ org.eclipse.cdt.debug.core,
+ org.eclipse.cdt.ui,
+ org.eclipse.jface.text,
+ org.eclipse.ui.workbench.texteditor
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.binutils,
+ org.eclipse.linuxtools.binutils.link2source,
+ org.eclipse.linuxtools.binutils.utils
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Localization: plugin
diff --git a/org.eclipse.linuxtools.binutils/about.html b/org.eclipse.linuxtools.binutils/about.html
new file mode 100644
index 0000000..23506a4
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/org.eclipse.linuxtools.binutils/build.properties b/org.eclipse.linuxtools.binutils/build.properties
new file mode 100644
index 0000000..75e3b73
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/build.properties
@@ -0,0 +1,16 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ about.html,\
+ plugin.properties
+src.includes = src/,\
+ plugin.xml,\
+ icons/,\
+ build.properties,\
+ bin/,\
+ META-INF/,\
+ .project,\
+ .classpath
diff --git a/org.eclipse.linuxtools.binutils/icons/c_file_obj.gif b/org.eclipse.linuxtools.binutils/icons/c_file_obj.gif
new file mode 100644
index 0000000..bd603cf
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/icons/c_file_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.binutils/plugin.properties b/org.eclipse.linuxtools.binutils/plugin.properties
new file mode 100644
index 0000000..8115a91
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/plugin.properties
@@ -0,0 +1,13 @@
+#******************************************************************************
+# Copyright (c) 2009 STMicroelectronics.
+# 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:
+# Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+#*******************************************************************************
+bundleProvider = Eclipse Linux Tools
+bundleName = Binutils Plug-in (Incubation)
+sourceNotFoundEditorName = Source Not Found \ No newline at end of file
diff --git a/org.eclipse.linuxtools.binutils/plugin.xml b/org.eclipse.linuxtools.binutils/plugin.xml
new file mode 100644
index 0000000..6d92b16
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/plugin.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="org.eclipse.linuxtools.binutils.crossCompilerBinutils" name="Cross compiler binutils" schema="schema/org.eclipse.linuxtools.binutils.crossCompile.exsd"/>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor"
+ icon="icons/c_file_obj.gif"
+ id="org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor"
+ name="%sourceNotFoundEditorName">
+ </editor>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.linuxtools.binutils/schema/org.eclipse.linuxtools.binutils.crossCompile.exsd b/org.eclipse.linuxtools.binutils/schema/org.eclipse.linuxtools.binutils.crossCompile.exsd
new file mode 100644
index 0000000..6489e99
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/schema/org.eclipse.linuxtools.binutils.crossCompile.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.linuxtools.binutils" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.linuxtools.binutils" id="org.eclipse.linuxtools.binutils.crossCompile" name="Cross-compile binutils"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="binutils"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="binutils">
+ <complexType>
+ <attribute name="CPU" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="binutilsFactory" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.binutils.utils.ISTBinutilsFactory"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/Activator.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/Activator.java
new file mode 100644
index 0000000..04c8eec
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/Activator.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.binutils";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java
new file mode 100644
index 0000000..89770a4
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditor.java
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.binutils.link2source;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
+import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * Editor that lets you select a replacement for the missing source file
+ * and modifies the source locator accordingly.
+ *
+ */
+public class STCSourceNotFoundEditor extends CommonSourceNotFoundEditor {
+
+ private final static String foundMappingsContainerName = "Found Mappings"; //$NON-NLS-1$
+
+
+ private Button locateFileButton;
+ private Button editLookupButton;
+
+ /** Constructor */
+ public STCSourceNotFoundEditor() {
+ }
+
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+ }
+
+ private IPath getMissingFile() {
+ IEditorInput i = this.getEditorInput();
+ if (i instanceof STCSourceNotFoundEditorInput) {
+ STCSourceNotFoundEditorInput input = (STCSourceNotFoundEditorInput) i;
+ return input.getSourcePath();
+ }
+ return null;
+ }
+
+ private int getLineNumber() {
+ IEditorInput i = this.getEditorInput();
+ if (i instanceof STCSourceNotFoundEditorInput) {
+ STCSourceNotFoundEditorInput input = (STCSourceNotFoundEditorInput) i;
+ return input.getLineNumber();
+ }
+ return -1;
+ }
+
+ private IProject getProject() {
+ IEditorInput i = this.getEditorInput();
+ if (i instanceof STCSourceNotFoundEditorInput) {
+ STCSourceNotFoundEditorInput input = (STCSourceNotFoundEditorInput) i;
+ return input.getProject();
+ }
+ return null;
+ }
+
+ public void setInput(IEditorInput input) {
+ super.setInput(input);
+ syncButtons();
+ }
+
+ private boolean isValidMissingFile() {
+ IPath p = getMissingFile();
+ boolean v = (p != null && p.toString().length() > 0);
+ return v;
+ }
+
+
+ private void syncButtons() {
+ boolean v = isValidMissingFile();
+ if (locateFileButton != null)
+ locateFileButton.setVisible(v);
+ if (editLookupButton != null)
+ editLookupButton.setVisible(v);
+ }
+
+ protected String getText() {
+ boolean v = isValidMissingFile();
+ if (v) {
+ return "Can't find a source file at \""
+ + getMissingFile()
+ + "\" \n";
+ } else {
+ return "No source available for \"\"";
+ }
+ }
+
+ protected void createButtons(Composite parent) {
+ {
+ GridData data;
+ locateFileButton = new Button(parent, SWT.PUSH);
+ data = new GridData();
+ data.grabExcessHorizontalSpace = false;
+ data.grabExcessVerticalSpace = false;
+ locateFileButton.setLayoutData(data);
+ locateFileButton.setText("Locate File..."); //$NON-NLS-1$
+ locateFileButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ locateFile();
+ }
+ });
+ }
+
+ {
+ GridData data;
+ editLookupButton = new Button(parent, SWT.PUSH);
+ data = new GridData();
+ data.grabExcessHorizontalSpace = false;
+ data.grabExcessVerticalSpace = false;
+ editLookupButton.setLayoutData(data);
+ editLookupButton.setText("Edit Source Lookup Path...");
+ editLookupButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ editSourceLookupPath();
+ }
+ });
+ }
+ syncButtons();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor#editSourceLookupPath()
+ */
+ @Override
+ protected void editSourceLookupPath() {
+ PreferenceDialog d = org.eclipse.ui.dialogs.PreferencesUtil.createPreferenceDialogOn(null, "org.eclipse.cdt.debug.ui.SourcePreferencePage", null, null);
+ if (d.open() == PreferenceDialog.OK) {
+ closeEditor();
+ openSourceFileAtLocation(getProject(), getMissingFile(), getLineNumber());
+ }
+ }
+
+ private void addSourceMappingToDirector(IPath missingPath, IPath newSourcePath, AbstractSourceLookupDirector director) throws CoreException {
+
+ ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(Arrays.asList(
+ director.getSourceContainers()
+ ));
+ boolean hasFoundMappings = false;
+ MappingSourceContainer foundMappings = null;
+ for (Iterator<ISourceContainer> iter = containerList.iterator(); iter.hasNext() && !hasFoundMappings;) {
+ ISourceContainer container = iter.next();
+ if (container instanceof MappingSourceContainer)
+ {
+ hasFoundMappings = container.getName().equals(foundMappingsContainerName);
+ if (hasFoundMappings)
+ foundMappings = (MappingSourceContainer) container;
+ }
+ }
+
+ if (!hasFoundMappings) {
+ foundMappings = new MappingSourceContainer(foundMappingsContainerName);
+ foundMappings.init(director);
+ containerList.add(foundMappings);
+ }
+
+ foundMappings.addMapEntry(new MapEntrySourceContainer(missingPath, newSourcePath));
+ director.setSourceContainers(containerList.toArray(new ISourceContainer[containerList.size()]));
+ }
+
+ private void addSourceMappingToCommon(IPath missingPath, IPath newSourcePath) throws CoreException {
+ AbstractSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
+ addSourceMappingToDirector(missingPath, newSourcePath, director);
+ CDebugCorePlugin.getDefault().savePluginPreferences();
+ }
+
+ protected void locateFile() {
+ FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE);
+ IPath missingPath = getMissingFile();
+ dialog.setFilterNames(new String[] {"Missing Source File"});
+ dialog.setFilterExtensions(new String[] {"*." + missingPath.getFileExtension()}); //$NON-NLS-1$
+ String res = dialog.open();
+ if (res != null) {
+ Path newPath = new Path(res);
+
+ if (newPath.lastSegment().equalsIgnoreCase(missingPath.lastSegment())) {
+
+ if (missingPath.segmentCount() > 1) {
+ int missingPathSegCount = missingPath.segmentCount() - 2;
+ int newPathSegCount = newPath.segmentCount() - 2;
+ while (missingPathSegCount >= 0 && newPathSegCount >= 0) {
+ if (!newPath.segment(newPathSegCount).equalsIgnoreCase(missingPath.segment(missingPathSegCount)))
+ break;
+ newPathSegCount--;
+ missingPathSegCount--;
+ }
+ IPath compPath = missingPath.removeLastSegments(missingPath.segmentCount() - missingPathSegCount - 1);
+ IPath newSourcePath = newPath.removeLastSegments(newPath.segmentCount() - newPathSegCount - 1);
+ try {
+ addSourceMappingToCommon(compPath, newSourcePath);
+ } catch (CoreException e) {}
+
+ }
+ openSourceFileAtLocation(getProject(), newPath, getLineNumber());
+ closeEditor();
+ }
+ }
+ }
+
+ protected void openSourceFileAtLocation(IProject project, IPath sourceLoc, int lineNumber){
+ STLink2SourceSupport.sharedInstance.openSourceFileAtLocation(project, sourceLoc, lineNumber);
+ }
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditorInput.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditorInput.java
new file mode 100644
index 0000000..38e76b8
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STCSourceNotFoundEditorInput.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.link2source;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.binutils.Activator;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+/**
+ * Editor Input used for source not found
+ *
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class STCSourceNotFoundEditorInput implements IEditorInput {
+
+ private final IProject project;
+ private final IPath sourcePath;
+ private final int lineNumber;
+
+
+ /**
+ * Constructor
+ * @param binaryPath
+ * @param sourcePath
+ * @param lineNumber
+ */
+ public STCSourceNotFoundEditorInput(IProject project, IPath sourcePath,
+ int lineNumber) {
+ this.project = project;
+ this.sourcePath = sourcePath;
+ this.lineNumber = lineNumber;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#exists()
+ */
+ public boolean exists() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor() {
+ return Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/c_file_obj.gif");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getName()
+ */
+ public String getName() {
+ return sourcePath.lastSegment() + ":" + lineNumber;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getPersistable()
+ */
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getToolTipText()
+ */
+ public String getToolTipText() {
+ return "Source not found";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+ /**
+ * @return the project
+ */
+ public IProject getProject() {
+ return project;
+ }
+
+ /**
+ * @return the sourcePath
+ */
+ public IPath getSourcePath() {
+ return sourcePath;
+ }
+
+ /**
+ * @return the lineNumber
+ */
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((project == null) ? 0 : project.hashCode());
+ result = prime * result
+ + ((sourcePath == null) ? 0 : sourcePath.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final STCSourceNotFoundEditorInput other = (STCSourceNotFoundEditorInput) obj;
+ if (project == null) {
+ if (other.project != null)
+ return false;
+ } else if (!project.equals(other.project))
+ return false;
+ if (sourcePath == null) {
+ if (other.sourcePath != null)
+ return false;
+ } else if (!sourcePath.equals(other.sourcePath))
+ return false;
+ return true;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java
new file mode 100644
index 0000000..d11e957
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/link2source/STLink2SourceSupport.java
@@ -0,0 +1,557 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.link2source;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.core.IAddressFactory;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.ISymbol;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IOutputEntry;
+import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.Addr64;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.linuxtools.binutils.Activator;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.FileStoreEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+/**
+ * This class provides a support for link-to-source
+ *
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class STLink2SourceSupport {
+
+ /** Shared instance of this class
+ * Note: perhaps it's better to put all methods static ?
+ */
+ public static final STLink2SourceSupport sharedInstance = new STLink2SourceSupport();
+
+ protected STLink2SourceSupport() {
+ }
+
+ /**
+ * Open a C Editor at the location of the given symbol
+ * @param symbol
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtSymbol(ISymbol symbol) {
+ if (symbol == null) return false;
+ return openSourceFileAtSymbol(symbol.getBinaryObject(), symbol);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binaryLoc a path to a binary file
+ * @param addr2lineOutput a location, as returned by addr2line (/path/to/file:linenumber)
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(String binaryLoc, String addr2lineOutput) throws IOException {
+ if (binaryLoc == null) return false;
+ return openSourceFileAtLocation(new Path(binaryLoc), addr2lineOutput);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binaryLoc a path to a binary file
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(String binaryLoc, String sourceLoc, String lineNumber) throws IOException {
+ if (binaryLoc == null) return false;
+ return openSourceFileAtLocation(new Path(binaryLoc), sourceLoc, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binaryLoc a path to a binary file
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(String binaryLoc, String sourceLoc, int lineNumber) throws IOException {
+ if (binaryLoc == null) return false;
+ return openSourceFileAtLocation(new Path(binaryLoc), sourceLoc, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given address
+ * @param binaryLoc a path to a binary file
+ * @param address
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtAddress(String binaryLoc, long address) throws IOException {
+ if (binaryLoc == null) return false;
+ return openSourceFileAtAddress(new Path(binaryLoc), address);
+ }
+
+ /**
+ * Open a C Editor at the given address
+ * @param binaryLoc a path to a binary file
+ * @param address
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtAddress(String binaryLoc, String address) throws IOException {
+ if (binaryLoc == null) return false;
+ return openSourceFileAtAddress(new Path(binaryLoc), address);
+
+ }
+
+
+
+
+
+ /**
+ * Open a C Editor at the given location
+ * @param binaryLoc a path to a binary file
+ * @param addr2lineOutput a location, as returned by addr2line (/path/to/file:linenumber)
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(IPath binaryLoc, String addr2lineOutput) throws IOException {
+ String filename = getFileName(addr2lineOutput);
+ int lineNumber = getLineNumber(addr2lineOutput);
+ return openSourceFileAtLocation(binaryLoc, filename, lineNumber);
+
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binaryLoc a path to a binary file
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(IPath binaryLoc, String sourceLoc, String lineNumber) throws IOException {
+ int _lineNumber = -1;
+ try {
+ _lineNumber = Integer.parseInt(lineNumber);
+ } catch (Exception _) {
+ }
+ return openSourceFileAtLocation(binaryLoc, sourceLoc, _lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binaryLoc a path to a binary file
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(IPath binaryLoc, String sourceLoc, int lineNumber) throws IOException {
+ if (sourceLoc == null) return false;
+ IPath p = new Path(sourceLoc);
+ return openSourceFileAtLocation(binaryLoc, p, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binaryLoc a path to a binary file
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(IPath binaryLoc, IPath sourceLoc, int lineNumber) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile binary = root.getFileForLocation(binaryLoc);
+ IProject project = null;
+ if (binary != null) project = binary.getProject();
+ return openFileImpl(project, sourceLoc, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param project the parent project
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(IProject project, String sourceLoc, int lineNumber) throws IOException {
+ if (sourceLoc == null) return false;
+ IPath p = new Path(sourceLoc);
+ return openFileImpl(project, p, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param project the parent project
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtLocation(IProject project, IPath sourceLoc, int lineNumber) {
+ return openFileImpl(project, sourceLoc, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given address
+ * @param binaryLoc a path to a binary file
+ * @param address
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtAddress(IPath binaryLoc, long address) throws IOException {
+ IBinaryObject bf = STSymbolManager.sharedInstance.getBinaryObject(binaryLoc);
+ if (bf != null) {
+ return openSourceFileAtAddress(bf, address);
+ }
+ return false;
+ }
+
+ /**
+ * Open a C Editor at the given address
+ * @param binaryLoc a path to a binary file
+ * @param address
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ * @throws IOException
+ */
+ public boolean openSourceFileAtAddress(IPath binaryLoc, String address) throws IOException {
+ IBinaryObject bf = STSymbolManager.sharedInstance.getBinaryObject(binaryLoc);
+ if (bf != null) {
+ return openSourceFileAtAddress(bf, address);
+ }
+ return false;
+ }
+
+
+
+
+
+ /*
+ * Method inspired from org.eclipse.cdt.utils.Addr2line.getFileName(IAddress)
+ */
+ private String getFileName(String loc) {
+ String filename = null;
+ int index1, index2;
+ if (loc != null && (index1 = loc.lastIndexOf(':')) != -1) {
+ // we do this because addr2line on win produces
+ // <cygdrive/pathtoexc/C:/pathtofile:##>
+ index2 = loc.indexOf(':');
+ if (index1 == index2) {
+ index2 = 0;
+ } else {
+ index2--;
+ }
+ filename = loc.substring(index2, index1);
+ }
+ return filename;
+ }
+
+
+ /*
+ * Method inspired from org.eclipse.cdt.utils.Addr2line.getFileName(IAddress)
+ */
+ private int getLineNumber(String loc) {
+ if (loc != null) {
+ int colon = loc.lastIndexOf(':');
+ String number = loc.substring(colon + 1);
+ if (!number.startsWith("0")) { //$NON-NLS-1$
+ try {
+ return Integer.parseInt(number);
+ } catch(Exception ex) {
+ return -1;
+ }
+ }
+ }
+ return -1;
+ }
+
+
+ /**
+ * Opens a C Editor pointing to the given symbol
+ * @param binary
+ * @param symbol
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtSymbol(IBinaryObject binary, ISymbol symbol) {
+ if (symbol == null) return false;
+ String loc = STSymbolManager.sharedInstance.getLine(symbol);
+ return openSourceFileAtLocation(binary, loc);
+ }
+
+ /**
+ * Opens a C Editor pointing to the given location
+ * @param binary
+ * @param addr2lineOutput a location, as returned by addr2line (/path/to/file:linenumber)
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtLocation(IBinaryObject binary, String addr2lineOutput) {
+ String filename = getFileName(addr2lineOutput);
+ int lineNumber = getLineNumber(addr2lineOutput);
+ return openSourceFileAtLocation(binary, filename, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binary a binary file
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtLocation(IBinaryObject binary, String sourceLoc, String lineNumber) {
+ int i = -1;
+ try {
+ i = Integer.parseInt(lineNumber);
+ } catch (Exception _) {
+ }
+ return openSourceFileAtLocation(binary, sourceLoc, i);
+ }
+
+ /**
+ * Open a C Editor at the given location
+ * @param binary a binary file
+ * @param sourceLoc the location of the source file
+ * @param lineNumber
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtLocation(IBinaryObject binary, String sourceLoc, int lineNumber) {
+ if (sourceLoc == null) return false;
+ IPath p = new Path(sourceLoc);
+ return openSourceFileAtLocation(binary.getPath(), p, lineNumber);
+ }
+
+ /**
+ * Open a C Editor at the given address
+ * @param binary a binary file
+ * @param address
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtAddress(IBinaryObject binary, IAddress address) {
+ if (binary == null) return false;
+ String loc = STSymbolManager.sharedInstance.getLine(binary, address);
+ return openSourceFileAtLocation(binary, loc);
+ }
+
+ /**
+ * Open a C Editor at the given address
+ * @param binary a binary file
+ * @param address
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtAddress(IBinaryObject binary, long address) {
+ String addr = Long.toString(address);
+ return openSourceFileAtAddress(binary, addr);
+ }
+
+ /**
+ * Open a C Editor at the given address
+ * @param binary a binary file
+ * @param address
+ * @return <code>true</code> if the link-to-source was successful, <code>false</code> otherwise
+ */
+ public boolean openSourceFileAtAddress(IBinaryObject binary, String address) {
+ if (binary == null) return false;
+ IAddressFactory factory = binary.getAddressFactory();
+ IAddress addr;
+ if (factory == null) {
+ addr = new Addr64(address);
+ } else {
+ addr = factory.createAddress(address);
+ }
+ return openSourceFileAtAddress(binary, addr);
+ }
+
+ private boolean openFileImpl(IProject project, IPath sourceLoc, int lineNumber) {
+ if (sourceLoc == null || "??".equals(sourceLoc.toString())) return false;
+ try {
+ IEditorInput editorInput = getEditorInput(sourceLoc, project);
+ IWorkbenchPage p= CUIPlugin.getActivePage();
+ if (p != null) {
+ if (editorInput == null) {
+ p.openEditor(
+ new STCSourceNotFoundEditorInput(project, sourceLoc, lineNumber),
+ "org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor",
+ true);
+ } else {
+ IEditorPart editor = p.openEditor(editorInput, CUIPlugin.EDITOR_ID, true);
+ if (lineNumber > 0 && editor instanceof ITextEditor){
+ IDocumentProvider provider= ((ITextEditor)editor).getDocumentProvider();
+ IDocument document= provider.getDocument(editor.getEditorInput());
+ try {
+ int start = document.getLineOffset(lineNumber-1);
+ ((ITextEditor)editor).selectAndReveal(start, 0);
+ IWorkbenchPage page= editor.getSite().getPage();
+ page.activate(editor);
+ return true;
+ } catch (BadLocationException x) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+ catch (Exception _) {
+ }
+ return false;
+ }
+
+ public IEditorInput getEditorInput(IPath p, IProject project) {
+ IFile f = getFileForPath(p, project);
+ if (f != null && f.exists()) {
+ return new FileEditorInput(f);
+ }
+ if (p.isAbsolute()) {
+ File file = p.toFile();
+ if (file.exists()) {
+ try {
+ IFileStore ifs = EFS.getStore(file.toURI());
+ return new FileStoreEditorInput(ifs);
+ } catch (CoreException _) {
+ Activator.getDefault().getLog().log(_.getStatus());
+ }
+ }
+ }
+ return findFileInCommonSourceLookup(p);
+ }
+
+ private IEditorInput findFileInCommonSourceLookup(IPath path)
+ {
+ try {
+ AbstractSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
+ ISourceContainer[] c = director.getSourceContainers();
+ for (ISourceContainer sourceContainer : c) {
+ Object[] o = sourceContainer.findSourceElements(path.toOSString());
+ for (Object object : o) {
+ if (object instanceof IFile) {
+ return new FileEditorInput((IFile)object);
+ } else if (object instanceof LocalFileStorage) {
+ LocalFileStorage storage = (LocalFileStorage) object;
+ IFileStore ifs = EFS.getStore(storage.getFile().toURI());
+ return new FileStoreEditorInput(ifs);
+ }
+ }
+ }
+ } catch (Exception _) {
+ // do nothing
+ }
+ return null;
+ }
+
+ private IFile getFileForPath(IPath path, IProject project) {
+ IFile f = getFileForPathImpl(path, project);
+ if (f == null) {
+ Set<IProject> allProjects = new HashSet<IProject>();
+ try {
+ getAllReferencedProjects(allProjects, project);
+ } catch (CoreException _) {
+ Activator.getDefault().getLog().log(_.getStatus());
+ }
+ if (allProjects != null) {
+ for (IProject project2 : allProjects) {
+ f = getFileForPathImpl(path, project2);
+ if (f != null) break;
+ }
+ }
+ }
+ return f;
+ }
+
+
+ private IFile getFileForPathImpl(IPath path, IProject project) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ if (path.isAbsolute()) {
+ IFile c = root.getFileForLocation(path);
+ return c;
+ }
+ if (project != null && project.exists()) {
+ ICProject cproject = CoreModel.getDefault().create(project);
+ if (cproject != null) {
+ try {
+ ISourceRoot[] roots = cproject.getAllSourceRoots();
+ for (ISourceRoot sourceRoot : roots) {
+ IResource r = sourceRoot.getResource();
+ if (r instanceof IContainer) {
+ IContainer parent = (IContainer) r;
+ IResource res = parent.findMember(path);
+ if (res != null && res.exists() && res instanceof IFile) {
+ IFile file = (IFile) res;
+ return file;
+ }
+ }
+ }
+
+ IOutputEntry entries[] = cproject.getOutputEntries();
+ for (IOutputEntry pathEntry : entries) {
+ IPath p = pathEntry.getPath();
+ IResource r = root.findMember(p);
+ if (r instanceof IContainer) {
+ IContainer parent = (IContainer) r;
+ IResource res = parent.findMember(path);
+ if (res != null && res.exists() && res instanceof IFile) {
+ IFile file = (IFile) res;
+ return file;
+ }
+ }
+ }
+
+ } catch (CModelException _) {
+ Activator.getDefault().getLog().log(_.getStatus());
+ }
+ }
+ }
+ return null;
+ }
+
+ private void getAllReferencedProjects(Set<IProject> all, IProject project) throws CoreException {
+ if (project != null) {
+ IProject[] refs = project.getReferencedProjects();
+ for (int i = 0; i < refs.length; i++) {
+ if (!all.contains(refs[i]) && refs[i].exists() && refs[i].isOpen()) {
+ all.add(refs[i]);
+ getAllReferencedProjects(all, refs[i]);
+ }
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/DefaultBinutilsFactory.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/DefaultBinutilsFactory.java
new file mode 100644
index 0000000..488ffaf
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/DefaultBinutilsFactory.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.utils.Addr2line;
+import org.eclipse.cdt.utils.CPPFilt;
+
+/**
+ * Default binutils factory
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class DefaultBinutilsFactory implements ISTBinutilsFactory {
+
+ @Override
+ public Addr2line getAddr2line(String path) throws IOException {
+ return new Addr2line(path);
+ }
+
+ @Override
+ public CPPFilt getCPPFilt() throws IOException {
+ return new CPPFilt();
+ }
+
+ @Override
+ public STNM getNM(String path, STNMSymbolsHandler handler) throws IOException {
+ return new STNM("nm", null, path, handler);
+ }
+
+ /**
+ * No availability test for default binutils.
+ */
+ @Override
+ public boolean testAvailability() {
+ return true;
+ }
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/ISTBinutilsFactory.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/ISTBinutilsFactory.java
new file mode 100644
index 0000000..c805cd4
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/ISTBinutilsFactory.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.utils.Addr2line;
+import org.eclipse.cdt.utils.CPPFilt;
+
+/**
+ * binutils factory (especially used for cross-compile tools)
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public interface ISTBinutilsFactory {
+
+ Addr2line getAddr2line(String path) throws IOException;
+
+ CPPFilt getCPPFilt() throws IOException;
+
+ STNM getNM(String path, STNMSymbolsHandler handler) throws IOException;
+
+ boolean testAvailability();
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2LineFactory.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2LineFactory.java
new file mode 100644
index 0000000..16d8353
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2LineFactory.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.utils.Addr2line;
+
+
+/**
+ * addr2line factory for all toolsets.
+ *
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class STAddr2LineFactory {
+
+ /**
+ * @param cpuType
+ * @param programPath
+ * @return an instance of addr2line for the given program
+ * @throws IOException
+ */
+ public static Addr2line getAddr2line(String cpuType, String programPath) throws IOException {
+ ISTBinutilsFactory factory = STBinutilsFactoryManager.sharedInstance.getBinutilsFactory(cpuType);
+ return factory.getAddr2line(programPath);
+ }
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2line.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2line.java
new file mode 100644
index 0000000..a72b17f
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STAddr2line.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.utils.Addr2line;
+
+/**
+ * Addr2line implementation, compatible with "hostname:file:linenumber"
+ * format of addr2line output.
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ *
+ */
+public class STAddr2line extends Addr2line {
+
+ /**
+ * Constructor
+ * @param cmd the command to run
+ * @param file the binary file
+ * @throws IOException
+ */
+ public STAddr2line(String cmd, String file) throws IOException {
+ super(cmd, file);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.utils.Addr2line#getLine(org.eclipse.cdt.core.IAddress)
+ */
+ @Override
+ public String getLine(IAddress address) throws IOException {
+ String s = super.getLine(address);
+ int index1 = s.lastIndexOf(':');
+ int index2 = s.indexOf(':');
+ if (index1 != index2 && index2 != 2) {
+ s = s.substring(index2+1);
+ }
+ return s;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STBinutilsFactoryManager.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STBinutilsFactoryManager.java
new file mode 100644
index 0000000..a2064d9
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STBinutilsFactoryManager.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.linuxtools.binutils.Activator;
+
+
+/**
+ * This class is on charge of managing "org.eclipse.linuxtools.binutils.crossCompilerBinutils" extension point.
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ *
+ */
+public class STBinutilsFactoryManager {
+
+ public static final STBinutilsFactoryManager sharedInstance = new STBinutilsFactoryManager();
+
+ /**
+ * Map of CPU/ISTBinutilsFactory
+ */
+ private final Map<String, ISTBinutilsFactory> map = new HashMap<String, ISTBinutilsFactory>();
+
+ /**
+ * Default factory
+ */
+ private DefaultBinutilsFactory defaultFactory;
+
+ /**
+ * Private constructor: this class is implemented as a Singleton
+ */
+ private STBinutilsFactoryManager() {
+ }
+
+ /**
+ * Try to find an extension point matching the given cpu;
+ * Then test availability of the tools.
+ * If no match, return default binutils factory
+ */
+ private ISTBinutilsFactory getBinutilsFactoryImpl(String cpu) {
+ try {
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IExtensionPoint ep = reg.getExtensionPoint("org.eclipse.linuxtools.binutils.crossCompilerBinutils");
+ IExtension[] exts = ep.getExtensions();
+ for (IExtension extension : exts) {
+ IConfigurationElement[] elems = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : elems) {
+ String s = configurationElement.getAttribute("CPU");
+ if (cpu.equals(s)) {
+ ISTBinutilsFactory factory = (ISTBinutilsFactory) configurationElement.createExecutableExtension("binutilsFactory");
+ if (factory.testAvailability()) return factory;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ Activator.getDefault().getLog().log(e.getStatus());
+ }
+ if (defaultFactory == null) defaultFactory = new DefaultBinutilsFactory();
+ return defaultFactory;
+ }
+
+ /**
+ * Get a ISTBinutilsFactory matching the given cpu id
+ * Returns the default one if no match.
+ */
+ public ISTBinutilsFactory getBinutilsFactory(String cpu) {
+ ISTBinutilsFactory factory = map.get(cpu);
+ if (factory == null) {
+ factory = getBinutilsFactoryImpl(cpu);
+ map.put(cpu, factory);
+ }
+ return factory;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STCPPFiltFactory.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STCPPFiltFactory.java
new file mode 100644
index 0000000..56940a6
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STCPPFiltFactory.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.utils.CPPFilt;
+
+/**
+ * c++filt factory for all toolsets.
+ *
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class STCPPFiltFactory {
+
+
+ /**
+ * @param cpuType
+ * @return an instance of cppfile for the given cpu type
+ * @throws IOException
+ */
+ public static CPPFilt getCPPFilt(String cpuType) throws IOException {
+ ISTBinutilsFactory factory = STBinutilsFactoryManager.sharedInstance.getBinutilsFactory(cpuType);
+ return factory.getCPPFilt();
+ }
+
+
+
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNM.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNM.java
new file mode 100644
index 0000000..e106c18
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNM.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+
+/**
+ * This class launches NM and parses output
+ */
+public class STNM {
+
+ private static Pattern undef_pattern = null;
+ private static Pattern normal_pattern = null;
+
+ private final STNMSymbolsHandler handler;
+
+ /**
+ * Constructor
+ * @param command the nm to call
+ * @param params nm params
+ * @param file file to parse
+ * @throws IOException
+ */
+ public STNM(String command, String[] params, String file, STNMSymbolsHandler handler) throws IOException {
+ this.handler = handler;
+ if (handler != null) init(command, params, file);
+ }
+
+ private void init(String command, String[] params, String file) throws IOException {
+ String[] args = null;
+ if (params == null || params.length == 0) {
+ args = new String[] {command, file}; //$NON-NLS-1$
+ } else {
+ args = new String[params.length + 2];
+ args[0] = command;
+ args[params.length+1] = file;
+ System.arraycopy(params, 0, args, 1, params.length);
+ }
+ Process process = ProcessFactory.getFactory().exec(args);
+ parseOutput(process.getInputStream());
+ process.destroy();
+ }
+
+
+ private void parseOutput(InputStream stream) throws IOException {
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(stream));
+ String line;
+
+ // See matcher.java for regular expression string data definitions.
+
+ if (undef_pattern == null) {
+ undef_pattern = Pattern.compile("^\\s+U\\s+(\\S+)"); //$NON-NLS-1$
+ }
+
+ if (normal_pattern == null) {
+ normal_pattern = Pattern.compile("^(\\S+)\\s+([AaTtBbDd])\\s+(\\S+)"); //$NON-NLS-1$
+ }
+ while ((line = reader.readLine()) != null) {
+ Matcher undef_matcher = undef_pattern.matcher(line);
+ Matcher normal_matcher = normal_pattern.matcher(line);
+ try {
+ if (undef_matcher.matches()) {
+ handler.foundUndefSymbol(undef_matcher.group(1));
+ } else if (normal_matcher.matches()) {
+ char type = normal_matcher.group(2).charAt(0);
+ String name = normal_matcher.group(3);
+ String address =normal_matcher.group(1);
+
+ switch (type) {
+ case 'T':
+ case 't':
+ handler.foundTextSymbol(name, address);
+ break;
+ case 'B':
+ case 'b':
+ handler.foundBssSymbol(name, address);
+ break;
+ case 'D':
+ case 'd':
+ handler.foundDataSymbol(name, address);
+ break;
+ }
+ }
+ } catch (NumberFormatException e) {
+ // ignore.
+ } catch (IndexOutOfBoundsException e) {
+ // ignore
+ }
+ }
+
+ }
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMFactory.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMFactory.java
new file mode 100644
index 0000000..0819484
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMFactory.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+import java.io.IOException;
+
+public class STNMFactory {
+
+ /**
+ * @param cpuType
+ * @param programPath
+ * @return an instance of nm for the given program
+ * @throws IOException
+ */
+ public static STNM getNM(String cpuType, String programPath, STNMSymbolsHandler handler) throws IOException {
+ ISTBinutilsFactory factory = STBinutilsFactoryManager.sharedInstance.getBinutilsFactory(cpuType);
+ return factory.getNM(programPath, handler);
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMSymbolsHandler.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMSymbolsHandler.java
new file mode 100644
index 0000000..6ecb081
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STNMSymbolsHandler.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+public interface STNMSymbolsHandler {
+
+ public void foundUndefSymbol(String symbol);
+
+ public void foundTextSymbol(String symbol, String address);
+
+ public void foundBssSymbol(String symbol, String address);
+
+ public void foundDataSymbol(String symbol, String address);
+
+}
diff --git a/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java
new file mode 100644
index 0000000..2eb3f67
--- /dev/null
+++ b/org.eclipse.linuxtools.binutils/src/org/eclipse/linuxtools/binutils/utils/STSymbolManager.java
@@ -0,0 +1,591 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.binutils.utils;
+
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.core.IBinaryParser;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.ISymbol;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.utils.Addr2line;
+import org.eclipse.cdt.utils.CPPFilt;
+import org.eclipse.core.resources.IFile;
+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.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.binutils.Activator;
+
+
+/**
+ * This class Is a utility on top of c++filt and addr2line.
+ *
+ * It allows an easy conversion between address and source location,
+ * and between mangled and demangled symbols.
+ *
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class STSymbolManager {
+
+ /**
+ * Auto dispose timeout:
+ * If some tools has been unused since more that this time (in ms),
+ * they are disposed.
+ */
+ private final static long AUTO_DISPOSE_TIMEOUT = 30000;
+
+ /**
+ * Singleton instance
+ */
+ public final static STSymbolManager sharedInstance = new STSymbolManager();
+
+ private final class AutoDisposeAddr2line {
+ private Addr2line addr2line;
+ private long startTime;
+ }
+
+ private final class AutoDisposeCPPFilt {
+ private CPPFilt cppfilt;
+ private long startTime;
+ }
+
+ /** Map of all living instance of addr2line */
+ private final HashMap<IBinaryObject, AutoDisposeAddr2line> addr2lines = new HashMap<IBinaryObject, AutoDisposeAddr2line>();
+ /** Map of all living instance of cppfilt */
+ private final HashMap<String, AutoDisposeCPPFilt> cppfilts = new HashMap<String, AutoDisposeCPPFilt>();
+
+ /**
+ * Constructor
+ */
+ private STSymbolManager() {
+ Runnable worker = new Runnable() {
+ public void run() {
+ try {
+ do {
+ try {
+ Thread.sleep(AUTO_DISPOSE_TIMEOUT);
+ } catch (InterruptedException e) {
+ break;
+ }
+ cleanup();
+ } while (true);
+ } catch (Exception _) {
+ Status s = new Status(Status.ERROR, Activator.PLUGIN_ID, _.getMessage(), _);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+ };
+ new Thread(worker, "ST System Analysis Symbol Manager").start(); //$NON-NLS-1$
+ // TODO: perhaps this thread has to be lazy-created ?
+ // and perhaps this thread has to destroy itself when it is no longer used ?
+ }
+
+ /**
+ * each {@link #AUTO_DISPOSE_TIMEOUT} ms, the unused addr2line and c++filt programs
+ * are disposed.
+ */
+ private synchronized void cleanup() {
+ long currentTime = System.currentTimeMillis();
+ Iterator<Entry<IBinaryObject, AutoDisposeAddr2line> > iter = addr2lines.entrySet().iterator();
+ while (iter.hasNext()) {
+ Entry<IBinaryObject, AutoDisposeAddr2line> entry = iter.next();
+ AutoDisposeAddr2line ada2l = entry.getValue();
+ long diff = currentTime-ada2l.startTime;
+ if (diff > AUTO_DISPOSE_TIMEOUT) {
+ ada2l.addr2line.dispose();
+ ada2l.addr2line = null;
+ iter.remove();
+ }
+ }
+
+ Iterator<Entry<String, AutoDisposeCPPFilt> > iter2 = cppfilts.entrySet().iterator();
+ while (iter2.hasNext()) {
+ Entry<String, AutoDisposeCPPFilt> entry = iter2.next();
+ AutoDisposeCPPFilt adcppf = entry.getValue();
+ long diff = currentTime-adcppf.startTime;
+ if (diff > AUTO_DISPOSE_TIMEOUT) {
+ if (adcppf.cppfilt != null) {
+ adcppf.cppfilt.dispose();
+ adcppf.cppfilt = null;
+ }
+ iter2.remove();
+ }
+ }
+ }
+
+
+ /**
+ * Demangle the given symbol
+ * @param symbol
+ * @return
+ */
+ public synchronized String demangle(ISymbol symbol) {
+ String cpu = symbol.getBinaryObject().getCPU();
+ String symbolName = symbol.getName();
+ return demangleImpl(symbolName, cpu);
+ }
+
+ /**
+ * Demangle the given symbol
+ * @param program
+ * @param symbolName
+ * @return
+ */
+ public synchronized String demangle(IBinaryObject program, String symbolName) {
+ String cpu = program.getCPU();
+ return demangleImpl(symbolName, cpu);
+ }
+
+
+ /**
+ * Demangle the given symbol
+ * @param symbol
+ * @return
+ */
+ private synchronized String demangleImpl(String symbolName, String cpu) {
+ CPPFilt cppfilt = getCppFilt(cpu);
+ if (cppfilt != null && (symbolName.startsWith("_Z") || symbolName.startsWith("_G"))) {
+ try {
+ symbolName = cppfilt.getFunction(symbolName);
+ } catch (IOException _) {
+ // TODO: log the error ?
+ }
+ }
+ return symbolName;
+ }
+
+
+ /**
+ * @param symbol
+ * @return the location (as returned by addr2line, e.g. file:line) of the given address
+ */
+ public synchronized String getLine(ISymbol symbol) {
+ IBinaryObject binary = symbol.getBinaryObject();
+ IAddress address = symbol.getAddress();
+ return getLine(binary, address);
+ }
+
+
+ /**
+ * @param program
+ * @param address
+ * @return the location (as returned by addr2line, e.g. file:line) of the given address
+ */
+ public synchronized String getLine(IBinaryObject program, IAddress address) {
+ Addr2line addr2line = getAddr2line(program);
+ if (addr2line == null) return "??:0";
+ try {
+ return addr2line.getLine(address);
+ } catch (IOException _) {
+ // TODO: log the error ?;
+ // Perhaps log the error only once, because
+ // this method is called many many times...
+ return "??:0";
+ }
+ }
+
+ /**
+ * @param program
+ * @param address an address, in hex, octal or decimal format (0xabcdef, 07654, 12345)
+ * @return the location (as returned by addr2line, e.g. file:line) of the given address
+ */
+ public synchronized String getLine(IBinaryObject program, String address) {
+ IAddress addr = program.getAddressFactory().createAddress(address);
+ return getLine(program, addr);
+ }
+
+ /**
+ * @param program
+ * @param address
+ * @return the location (as returned by addr2line, e.g. file:line) of the given address
+ */
+ public synchronized String getLine(IBinaryObject program, long address) {
+ IAddress addr = program.getAddressFactory().createAddress(Long.toString(address));
+ return getLine(program, addr);
+ }
+
+ /**
+ * @param program
+ * @param address
+ * @return the line number of the given address
+ */
+ public synchronized int getLineNumber(IBinaryObject program, IAddress address) {
+ Addr2line addr2line = getAddr2line(program);
+ if (addr2line == null) return -1;
+ try {
+ return addr2line.getLineNumber(address);
+ } catch (IOException _) {
+ // TODO: log the error ?;
+ // Perhaps log the error only once, because
+ // this method is called many many times...
+ return -1;
+ }
+ }
+
+ /**
+ * @param program
+ * @param address
+ * @return the line number of the given address
+ */
+ public synchronized int getLineNumber(IBinaryObject program, String address) {
+ IAddress addr = program.getAddressFactory().createAddress(address);
+ return getLineNumber(program, addr);
+ }
+
+ /**
+ * @param program
+ * @param address
+ * @return the line number of the given address
+ */
+ public synchronized int getLineNumber(IBinaryObject program, long address) {
+ IAddress addr = program.getAddressFactory().createAddress(Long.toString(address));
+ return getLineNumber(program, addr);
+ }
+
+ /**
+ *
+ * @param symbol
+ * @return the line number of the given symbol
+ */
+ public int getLineNumber(ISymbol symbol) {
+ IBinaryObject obj = symbol.getBinaryObject();
+ IAddress address = symbol.getAddress();
+ return getLineNumber(obj,address);
+ }
+
+ /**
+ *
+ * @param program
+ * @param address
+ * @return the file name of the given address
+ */
+ public synchronized String getFileName(IBinaryObject program, IAddress address) {
+ Addr2line addr2line = getAddr2line(program);
+ if (addr2line == null) return null;
+ try {
+ return addr2line.getFileName(address);
+ } catch (IOException _) {
+ // TODO: log the error ?;
+ // Perhaps log the error only once, because
+ // this method is called many many times...
+ return null;
+ }
+ }
+
+ /**
+ *
+ * @param program
+ * @param address
+ * @return the file name of the given address
+ */
+ public synchronized String getFileName(IBinaryObject program, String address) {
+ IAddress addr = program.getAddressFactory().createAddress(address);
+ return getFileName(program, addr);
+ }
+
+ /**
+ *
+ * @param program
+ * @param address
+ * @return the file name of the given address
+ */
+ public synchronized String getFileName(IBinaryObject program, long address) {
+ IAddress addr = program.getAddressFactory().createAddress(Long.toString(address));
+ return getFileName(program, addr);
+ }
+
+ /**
+ *
+ * @param symbol
+ * @return the filename of the given symbol
+ */
+ public String getFilename(ISymbol symbol) {
+ IBinaryObject obj = symbol.getBinaryObject();
+ IAddress address = symbol.getAddress();
+ return getFileName(obj,address);
+ }
+
+
+ /**
+ * @param program
+ * @param address an address
+ * @return the function name of the given address, based on addr2line output
+ */
+ public synchronized String getFunctionName(IBinaryObject program, long address) {
+ IAddress addr = program.getAddressFactory().createAddress(Long.toString(address));
+ return getFunctionName(program, addr);
+ }
+
+ /**
+ * @param program
+ * @param address an address, in hex, octal or decimal format (0xabcdef, 07654, 12345)
+ * @return the function name of the given address, based on addr2line output
+ */
+ public synchronized String getFunctionName(IBinaryObject program, String address) {
+ IAddress addr = program.getAddressFactory().createAddress(address);
+ return getFunctionName(program, addr);
+ }
+
+ /**
+ * @param program
+ * @param address an address
+ * @return the function name of the given address, based on addr2line output
+ */
+ public synchronized String getFunctionName(IBinaryObject program, IAddress address) {
+ Addr2line addr2line = getAddr2line(program);
+ if (addr2line == null) return null;
+ try {
+ return addr2line.getFunction(address);
+ } catch (IOException _) {
+ // TODO: log the error ?;
+ // Perhaps log the error only once, because
+ // this method is called many many times...
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets the c++filt support for the given program
+ * Note that the instance if kept in a local hashmap, and discarded after 30 seconds of inactivity.
+ * @param program
+ * @return an instance of CPPFilt suitable for the given program
+ */
+ private synchronized CPPFilt getCppFilt(String cpu) {
+ AutoDisposeCPPFilt adCppfilt = cppfilts.get(cpu);
+ if (adCppfilt == null) {
+ adCppfilt = new AutoDisposeCPPFilt();
+ cppfilts.put(cpu, adCppfilt);
+ }
+ if (adCppfilt.cppfilt == null) {
+ try {
+ adCppfilt.cppfilt = STCPPFiltFactory.getCPPFilt(cpu);
+ } catch (IOException _) {
+ // TODO: log the error ?;
+ // Perhaps log the error only once, because
+ // this method is called many many times...
+ return null;
+ }
+ }
+ adCppfilt.startTime = System.currentTimeMillis();
+ return adCppfilt.cppfilt;
+ }
+
+ /**
+ * Gets the addr2line support for the given program
+ * Note that the instance if kept in a local hashmap, and discarded after 30 seconds of inactivity.
+ * @param program
+ * @return an instance of Addr2line suitable for the given program
+ */
+ private synchronized Addr2line getAddr2line(IBinaryObject program) {
+ AutoDisposeAddr2line adAddr2line = addr2lines.get(program);
+ if (adAddr2line == null) {
+ adAddr2line = new AutoDisposeAddr2line();
+ addr2lines.put(program, adAddr2line);
+ }
+ if (adAddr2line.addr2line == null) {
+ try {
+ adAddr2line.addr2line = STAddr2LineFactory.getAddr2line(program.getCPU(), program.getPath().toOSString());
+ } catch (IOException _) {
+ // TODO: log the error ?;
+ // Perhaps log the error only once, because
+ // this method is called many many times...
+ return null;
+ }
+ }
+ adAddr2line.startTime = System.currentTimeMillis();
+ return adAddr2line.addr2line;
+ }
+
+ /**
+ * Gets the IBinaryObject corresponding to the given path (absolute path in filesystem).
+ * If a IBinaryObject corresponding to the given path has been already built by eclipse, return it.
+ * Otherwise build a new IBinaryObject, according to project preferences.
+ * Note that it may return null if the path is invalid, or is not a valid binary file.
+ * @param path
+ * @return a IBinaryObject
+ */
+ public IBinaryObject getBinaryObject(String loc) {
+ IPath path = new Path(loc);
+ return getBinaryObject(path);
+ }
+
+
+ /**
+ * Gets the IBinaryObject corresponding to the given path (absolute path in filesystem).
+ * If a IBinaryObject corresponding to the given path has been already built by eclipse, return it.
+ * Otherwise build a new IBinaryObject, according to project preferences.
+ * Note that it may return null if the path is invalid, or is not a valid binary file.
+ * @param path
+ * @return a IBinaryObject
+ */
+ public IBinaryObject getBinaryObject(IPath path) {
+
+ return getBinaryObject(path, null);
+ }
+
+ /**
+ * Gets the IBinaryObject corresponding to the given path (absolute path in filesystem).
+ * If a IBinaryObject corresponding to the given path has been already built by eclipse, return it.
+ * Otherwise build a new IBinaryObject, according to project preferences.
+ * Note that it may return null if the path is invalid, or is not a valid binary file.
+ * @param path
+ * @param default parser
+ * @return a IBinaryObject
+ */
+ public IBinaryObject getBinaryObject(IPath path, IBinaryParser defaultparser) {
+ IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ List<IBinaryParser> parsers;
+ if (c != null) {
+ IBinaryObject object = getAlreadyExistingBinaryObject(c);
+ if (object != null) return object;
+ parsers = getBinaryParser(c.getProject());
+ } else {
+ parsers = new LinkedList<IBinaryParser>();
+ }
+
+ if (defaultparser == null) {
+ try {
+ defaultparser = CCorePlugin.getDefault().getDefaultBinaryParser();
+ } catch (CoreException _) {
+ Activator.getDefault().getLog().log(_.getStatus());
+ }
+ }
+ if (defaultparser != null) {
+ parsers.add(defaultparser);
+ }
+ return buildBinaryObject(path, parsers);
+ }
+
+ /**
+ * Validate the binary file.
+ * In particular, verify that this binary file can be decoded.
+ * @param o
+ * @return the binary object, or null.
+ */
+ private IBinaryObject validateBinary(IBinaryFile o) {
+ if (o instanceof IBinaryObject) {
+ IBinaryObject object = (IBinaryObject) o;
+ String s = null;
+ try {
+ s = object.getCPU(); //
+ } catch (Exception _) {}
+ if (s.length() > 0) {
+ return object;
+ }
+ }
+ return null;
+ }
+
+ private IBinaryObject buildBinaryObject(IPath path, List<IBinaryParser> parsers) {
+ for (IBinaryParser iBinaryParser : parsers) {
+ IBinaryObject o = buildBinaryObject(path, iBinaryParser);
+ if (o != null) return o;
+ }
+ return null;
+ }
+
+ /**
+ * Build a binary object with the given file and parser.
+ * Also verify that the builded binary object is valid (@see #validateBinary)
+ */
+ private IBinaryObject buildBinaryObject(IPath path, IBinaryParser parser) {
+ if (parser == null) return null;
+ IBinaryFile bf = null;
+ try {
+ bf = parser.getBinary(path);
+ } catch (IOException _) {
+ // do nothing ?
+ }
+ return validateBinary(bf);
+ }
+
+ /**
+ * Ask the workbench to find if a binary object already exist for the given file
+ */
+ private IBinaryObject getAlreadyExistingBinaryObject(IFile c) {
+ IProject project = c.getProject();
+ if (project != null && project.exists()) {
+ ICProject cproject = CoreModel.getDefault().create(project);
+ if (cproject != null) {
+ try {
+ IBinary[] b = cproject.getBinaryContainer()
+ .getBinaries();
+ for (IBinary binary : b) {
+ IResource r = binary.getResource();
+ if (r.equals(c)) {
+ IBinaryObject binaryObject = (IBinaryObject) binary.getAdapter(IBinaryObject.class);
+ return validateBinary(binaryObject);
+ }
+ }
+ } catch (CModelException _) {
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve the list of binary parsers defined for the given project
+ */
+ private List<IBinaryParser> getBinaryParser(IProject project) {
+ List<IBinaryParser> parsers = new LinkedList<IBinaryParser>();
+
+ ICProjectDescription projDesc = CCorePlugin.getDefault().getProjectDescription(project);
+ if (projDesc == null) return parsers;
+ ICConfigurationDescription[] cfgs = projDesc.getConfigurations();
+ String[] binaryParserIds = CoreModelUtil.getBinaryParserIds(cfgs);
+
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
+ for (String id : binaryParserIds) {
+ IExtension extension = extensionPoint.getExtension(id);
+ if (extension != null) {
+ IConfigurationElement element[] = extension.getConfigurationElements();
+ for (IConfigurationElement element2 : element) {
+ if (element2.getName().equalsIgnoreCase("cextension")) { //$NON-NLS-1$
+ try {
+ IBinaryParser parser = (IBinaryParser) element2.createExecutableExtension("run"); //$NON-NLS-1$
+ if (parser != null) parsers.add(parser);
+ } catch (CoreException _) {
+ // TODO: handle exception ?
+ }
+ }
+ }
+ }
+ }
+ return parsers;
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.classpath b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.project b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.project
new file mode 100644
index 0000000..0e6347d
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.dataviewers.annotatedsourceeditor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..5466d96
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,3 @@
+#Tue Jun 03 09:41:19 CEST 2008
+eclipse.preferences.version=1
+instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..fbc03a9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Tue Jun 03 09:41:19 CEST 2008
+eclipse.preferences.version=1
+internal.default.compliance=default
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..b32e17f
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;singleton:=true
+Bundle-Version: 4.1.0.qualifier
+Bundle-Activator: org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedSourceEditorActivator
+Bundle-Vendor: %bundleProvider
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.filesystem,
+ org.eclipse.ui.ide,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.cdt.ui,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.core.resources,
+ org.eclipse.cdt.core
+Export-Package: org.eclipse.linuxtools.dataviewers.annotatedsourceeditor,
+ org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.actions,
+ org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.hyperlink,
+ org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.preferencespages
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/about.html b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/build.properties b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/build.properties
new file mode 100644
index 0000000..d9e2367
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = .,\
+ META-INF/,\
+ icons/,\
+ plugin.xml,\
+ about.html,\
+ plugin.properties
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/icons/c_file_obj.gif b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/icons/c_file_obj.gif
new file mode 100644
index 0000000..8fd6adb
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/icons/c_file_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.properties b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.properties
new file mode 100644
index 0000000..ad2f7d2
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.properties
@@ -0,0 +1,12 @@
+#******************************************************************************
+# Copyright (c) 2009 STMicroelectronics.
+# 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:
+# STMicroelectronics - initial API and implementation
+#*******************************************************************************
+bundleProvider = Eclipse Linux Tools
+bundleName = Annotated Source Editor Plug-in (Incubation) \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.xml b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.xml
new file mode 100644
index 0000000..9cf43ea
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/plugin.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.rulerColumns">
+ <column
+ class="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STContributedRulerColumn"
+ enabled="false"
+ global="false"
+ id="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.column"
+ includeInMenu="false"
+ name="ST Column">
+ <placement
+ gravity="0.8"></placement>
+ <targetEditor
+ id="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.editor">
+ </targetEditor>
+ </column>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors.markerAnnotationSpecification">
+ <specification
+ annotationType="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.coloredLines"
+ colorPreferenceKey="coloredLinesResultIndicationColor"
+ colorPreferenceValue="250,0,0"
+ highlightPreferenceKey="coloredLinesHighlighting"
+ includeOnPreferencePage="false"
+ label="Colored Lines"
+ overviewRulerPreferenceKey="coloredLinesIndicationInOverviewRuler"
+ overviewRulerPreferenceValue="true"
+ presentationLayer="1"
+ textPreferenceKey="coloredLinedResultIndication"
+ verticalRulerPreferenceKey="coloredLinesIndicationInVerticalRuler">
+ </specification>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor"
+ icon="icons/c_file_obj.gif"
+ id="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.editor"
+ name="ST Annotated Source Editor">
+ </editor>
+ <editor
+ id="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.editor2"
+ name="name">
+ </editor>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="%ActionDefinition.STColumnToggle.description"
+ id=" org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STColumnToggle"
+ name="Show Annotation Columns">
+ </command>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/AbstractSTAnnotatedSourceEditorInput.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/AbstractSTAnnotatedSourceEditorInput.java
new file mode 100644
index 0000000..1a4a0f5
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/AbstractSTAnnotatedSourceEditorInput.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.ide.FileStoreEditorInput;
+
+public abstract class AbstractSTAnnotatedSourceEditorInput extends FileStoreEditorInput{
+ private ArrayList<ISTAnnotationColumn> columns;
+
+ public AbstractSTAnnotatedSourceEditorInput(IFileStore fileStore) {
+ super(fileStore);
+ }
+
+ /** gets how many STColumn exist
+ *
+ * @return
+ */
+ public int getColumnCount(){
+ if (columns == null){
+ columns = getColumns();
+ }
+ return columns!=null ? columns.size() : 0;
+ }
+
+ /** gets the title of a ST Column
+ *
+ * @param column
+ * @return
+ */
+ public String getTitle(ISTAnnotationColumn column){
+ if (columns == null){
+ columns = getColumns();
+ }
+ return column!=null ? column.getTitle() : null;
+ }
+
+ /** gets the background column of a editor line
+ *
+ * @param line
+ * @return
+ */
+ public abstract Color getColor(int line);
+
+ public String getAnnotation(int line, ISTAnnotationColumn column){
+ if (columns == null){
+ columns = getColumns();
+ }
+ return column!=null ? column.getAnnotation(line) : null;
+ }
+
+ public String getLongDescription(int line, ISTAnnotationColumn column){
+ if (columns == null){
+ columns = getColumns();
+ }
+ return column!=null ? column.getLongDescription(line) : null;
+ }
+
+ public String getTooltip(int line, ISTAnnotationColumn column){
+ if (columns == null){
+ columns = getColumns();
+ }
+ return column!=null ? column.getTooltip(line) : null;
+ }
+
+ /** gets the ISTAnnotationColumn objects list
+ *
+ * @return
+ */
+ public abstract ArrayList<ISTAnnotationColumn> getColumns();
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTAnnotationColumn.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTAnnotationColumn.java
new file mode 100644
index 0000000..0d7291e
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTAnnotationColumn.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+public interface ISTAnnotationColumn {
+ String getTitle();
+ String getAnnotation(int line);
+ String getTooltip(int line);
+ String getLongDescription(int line);
+ String getHeaderTooltip();
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionConstants.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionConstants.java
new file mode 100644
index 0000000..9e24ca9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionConstants.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+
+public interface ISTTextEditorActionConstants extends
+ ITextEditorActionConstants {
+
+ String ST_TOGGLE= "ST.Toggle"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionDefinitionIds.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionDefinitionIds.java
new file mode 100644
index 0000000..88915bb
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/ISTTextEditorActionDefinitionIds.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+public interface ISTTextEditorActionDefinitionIds extends
+ ITextEditorActionDefinitionIds {
+
+ String ST_TOGGLE= "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STColumnToggle"; //$NON-NLS-1$
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedCSourceEditor.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedCSourceEditor.java
new file mode 100644
index 0000000..3b77d6c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedCSourceEditor.java
@@ -0,0 +1,449 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.AnnotationModel;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.IChangeRulerColumn;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.IVerticalRulerColumn;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.window.DefaultToolTip;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.LineBackgroundEvent;
+import org.eclipse.swt.custom.LineBackgroundListener;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.StyledTextContent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+import org.eclipse.ui.internal.texteditor.AnnotationColumn;
+import org.eclipse.ui.internal.texteditor.LineNumberColumn;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
+import org.eclipse.ui.texteditor.ResourceAction;
+import org.eclipse.ui.texteditor.rulers.IColumnSupport;
+import org.eclipse.ui.texteditor.rulers.IContributedRulerColumn;
+import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor;
+import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry;
+
+
+public class STAnnotatedCSourceEditor extends CEditor implements LineBackgroundListener {
+ private final static String ST_RULER= "STRuler";
+
+ protected STContributedRulerColumn fAbstractSTRulerColumn;
+
+ private IColumnSupport fColumnSupport;
+
+ private LineNumberColumn fLineColumn;
+
+ private STContributedRulerColumn fColumn;
+
+ private StyledText fCachedTextWidget;
+
+ private AbstractSTAnnotatedSourceEditorInput fInput;
+
+ private ArrayList<ISTAnnotationColumn> fListColumns;
+
+ private STChangeRulerColumn fSTChangeRulerColumn;
+
+ @Override
+ public void createPartControl(Composite parent){
+ if (fInput == null){
+ super.createPartControl(parent);
+ return;
+ }
+
+ GridLayout layout= new GridLayout();
+ layout.numColumns=fInput.getColumnCount()+1;
+ layout.horizontalSpacing=0;
+ parent.setLayout(layout);
+ GridData gd =new GridData();
+ gd.grabExcessHorizontalSpace =false;
+ gd.grabExcessVerticalSpace =true;
+
+ parent.setLayoutData(gd );
+
+ Composite fParentSv= new Composite(parent, SWT.NONE);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan =fInput.getColumnCount()+1;
+ gd.horizontalIndent=gd.verticalIndent=0;
+ fParentSv.setLayoutData(gd);
+ FillLayout fillLayout= new FillLayout(SWT.HORIZONTAL|SWT.VERTICAL);
+ fillLayout.marginWidth=fillLayout.marginHeight=0;
+ fParentSv.setLayout(fillLayout);
+
+ super.createPartControl(fParentSv);
+
+ STColumnSupport columnSupport= (STColumnSupport)getAdapter(IColumnSupport.class);
+ RulerColumnRegistry registry = RulerColumnRegistry.getDefault();
+
+ for(int i=1;i<=fInput.getColumnCount();i++){
+ RulerColumnDescriptor abstractSTColumnDescriptor= registry.getColumnDescriptor(STContributedRulerColumn.ID);
+ columnSupport.addSTColumn((CompositeRuler)getVerticalRuler(), abstractSTColumnDescriptor,fListColumns.get(i-1));
+
+ }
+
+ CompositeRuler vr = (CompositeRuler)super.getVerticalRuler();
+ int count = 0;
+ Font font = parent.getFont();
+ FontData fd = font.getFontData()[0];
+ fd.setStyle(SWT.BOLD);
+ for(Iterator<?> iter = vr.getDecoratorIterator();iter.hasNext();){
+ IVerticalRulerColumn column = (IVerticalRulerColumn)iter.next();
+ if (column instanceof STContributedRulerColumn){
+ STContributedRulerColumn fSTColumn = (STContributedRulerColumn)column;
+ Label label = new Label(parent, SWT.BORDER);
+ gd = new GridData();
+ count++;
+ if (count==1) gd.horizontalIndent=VERTICAL_RULER_WIDTH+5;
+ else gd.horizontalIndent=0;
+ gd.widthHint = fSTColumn.getWidth();
+ label.setFont(new Font(label.getDisplay(), fd));
+ label.setLayoutData(gd);
+ label.moveAbove(fParentSv);
+ label.setText(fSTColumn.getAnnotationColumn(0).getTitle());
+ fSTColumn.setLabelColumn(label);
+
+ if (fSTColumn.isShowingSTRuler()){
+ ToolTipSupport.enableFor(fSTColumn);
+ }
+ }
+ }
+
+ Label label = new Label(parent, SWT.BORDER);
+ gd = new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ label.setFont(new Font(label.getDisplay(), fd));
+ label.setLayoutData(gd);
+ label.moveAbove(fParentSv);
+ label.setText(getTitle());
+
+ showLinesColored();
+
+ if (getViewer() != null){
+ ISourceViewer sv = getViewer();
+
+ if (sv.getTextWidget() != null){
+
+ fCachedTextWidget = sv.getTextWidget();
+ fCachedTextWidget.addLineBackgroundListener(this);
+ }
+ }
+ }
+
+ @Override
+ protected void rulerContextMenuAboutToShow(IMenuManager menu) {
+ super.rulerContextMenuAboutToShow(menu);
+
+ CompositeRuler vr = (CompositeRuler)super.getVerticalRuler();
+
+ for(Iterator<?> iter = vr.getDecoratorIterator();iter.hasNext();){
+ IVerticalRulerColumn column = (IVerticalRulerColumn)iter.next();
+ if (column instanceof STContributedRulerColumn){
+ STContributedRulerColumn fSTColumn = (STContributedRulerColumn)column;
+ IAction stprofcolAction = getAction(ISTTextEditorActionConstants.ST_TOGGLE);
+ stprofcolAction.setChecked(fSTColumn != null && fSTColumn.isShowingSTRuler());
+ }
+ else if (column instanceof LineNumberColumn){
+ LineNumberColumn fLineColumn = (LineNumberColumn)column;
+ IAction lineNumberAction= getAction(ITextEditorActionConstants.LINENUMBERS_TOGGLE);
+ lineNumberAction.setChecked(fLineColumn != null && fLineColumn.isShowingLineNumbers());
+ }
+ }
+
+ if (fInput != null){
+ IAction stAction= getAction(ISTTextEditorActionConstants.ST_TOGGLE);
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, stAction);
+ }
+
+
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object getAdapter(Class required) {
+ if (IColumnSupport.class.equals(required)) {
+ if (fColumnSupport == null)
+ fColumnSupport= createSTColumnSupport();
+ return fColumnSupport;
+ }
+
+ return super.getAdapter(required);
+ }
+
+ protected IColumnSupport createSTColumnSupport() {
+ return new STColumnSupport(this,RulerColumnRegistry.getDefault());
+ }
+
+ protected class STColumnSupport extends AbstractDecoratedTextEditor.ColumnSupport{
+ private final STAnnotatedCSourceEditor fEditor;
+ private final RulerColumnRegistry fRegistry;
+ private final ArrayList<ISTAnnotationColumn> fColumns;
+
+ public STColumnSupport(STAnnotatedCSourceEditor editor, RulerColumnRegistry registry) {
+ super(editor, registry);
+ fEditor = editor;
+ fRegistry = registry;
+ fColumns= new ArrayList<ISTAnnotationColumn>();
+ }
+
+ private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
+ int index= 0;
+ List<?> all= fRegistry.getColumnDescriptors();
+ int newPos= all.indexOf(descriptor);
+ for (Iterator<?> it= ruler.getDecoratorIterator(); it.hasNext();) {
+ IVerticalRulerColumn column= (IVerticalRulerColumn) it.next();
+ if (column instanceof IContributedRulerColumn) {
+ RulerColumnDescriptor rcd= ((IContributedRulerColumn)column).getDescriptor();
+ if (rcd != null && all.indexOf(rcd) > newPos)
+ break;
+ } else if ("org.eclipse.jface.text.source.projection.ProjectionRulerColumn".equals(column.getClass().getName())) { //$NON-NLS-1$
+ // projection column is always the rightmost column
+ break;
+ }
+ index++;
+ }
+ return index;
+ }
+
+ public void addSTColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor,final ISTAnnotationColumn annotationColumn) {
+
+ final int idx= computeIndex(ruler, descriptor);
+
+ SafeRunnable runnable= new SafeRunnable() {
+ public void run() throws Exception {
+ IContributedRulerColumn column= descriptor.createColumn(fEditor);
+ fColumns.add(annotationColumn);
+ initializeColumn(column);
+ ruler.addDecorator(idx, column);
+ }
+ };
+ SafeRunner.run(runnable);
+ }
+
+ protected void initializeColumn(IContributedRulerColumn column) {
+ super.initializeColumn(column);
+ RulerColumnDescriptor descriptor= column.getDescriptor();
+ IVerticalRuler ruler= getVerticalRuler();
+ if (ruler instanceof CompositeRuler) {
+ if (AnnotationColumn.ID.equals(descriptor.getId())) {
+ ((AnnotationColumn)column).setDelegate(createAnnotationRulerColumn((CompositeRuler) ruler));
+ } else if (LineNumberColumn.ID.equals(descriptor.getId())) {
+ fLineColumn= ((LineNumberColumn) column);
+ fLineColumn.setForwarder(new LineNumberColumn.ICompatibilityForwarder() {
+ public IVerticalRulerColumn createLineNumberRulerColumn() {
+ return fEditor.createLineNumberRulerColumn();
+ }
+ public boolean isQuickDiffEnabled() {
+ return fEditor.isPrefQuickDiffAlwaysOn();
+ }
+ public boolean isLineNumberRulerVisible() {
+ return fEditor.isLineNumberRulerVisible();
+ }
+ });
+ }
+ if (STContributedRulerColumn.ID.equals(descriptor.getId())){
+ fColumn = ((STContributedRulerColumn) column);
+ //this is a workaround...
+ fColumn.setForwarder(new STContributedRulerColumn.ICompatibilityForwarder() {
+ public IVerticalRulerColumn createSTRulerColumn() {
+ if (fColumns != null && fColumns.size() > 0){
+ IVerticalRulerColumn fDelegate = fEditor.createSTRulerColumn(fColumns.get(fColumns.size()-1));
+ return fDelegate;
+ }
+ return null;
+ }
+ public boolean isQuickDiffEnabled() {
+ return fEditor.isPrefQuickDiffAlwaysOn();
+ }
+ public boolean isSTRulerVisible() {
+ return fEditor.isSTRulerVisible();
+ }
+ });
+ }
+ }
+ }
+ }
+
+ protected IVerticalRulerColumn createSTRulerColumn(ISTAnnotationColumn annotationColumn) {
+ fSTChangeRulerColumn= new STChangeRulerColumn(getSharedColors(),annotationColumn);
+ ((IChangeRulerColumn) fSTChangeRulerColumn).setHover(createChangeHover());
+ initializeLineNumberRulerColumn(fLineNumberRulerColumn);
+
+ return fSTChangeRulerColumn;
+ }
+
+ public void lineGetBackground(LineBackgroundEvent event) {
+ if (fInput != null){
+ StyledTextContent c = (StyledTextContent)event.data;
+ int line = c.getLineAtOffset(event.lineOffset);
+ event.lineBackground = fInput.getColor(line);
+ }
+ }
+
+ @Override
+ protected void doSetInput(IEditorInput input) throws CoreException {
+ super.doSetInput(input);
+
+ if (input!=null && input instanceof AbstractSTAnnotatedSourceEditorInput){
+ fInput = (AbstractSTAnnotatedSourceEditorInput)input;
+ fListColumns = fInput.getColumns();
+ }
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ ResourceAction action;
+
+ action= new ResourceAction(STTextEditorMessages.getBundleForConstructedKeys(), "Editor.ToggleSTColumnAction.", IAction.AS_CHECK_BOX) { //$NON-NLS-1$
+ @Override
+ public void run() {
+ toggleSTRuler();
+ }
+ };
+
+ if (fInput != null){
+ action.setActionDefinitionId(ISTTextEditorActionDefinitionIds.ST_TOGGLE);
+ setAction(ISTTextEditorActionConstants.ST_TOGGLE, action);
+ }
+ }
+
+ private void toggleSTRuler() {
+ // globally
+ IPreferenceStore store= EditorsUI.getPreferenceStore();
+ store.setValue(ST_RULER, !isSTRulerVisible());
+ }
+
+ protected boolean isSTRulerVisible() {
+ IPreferenceStore store= getPreferenceStore();
+ return store != null ? store.getBoolean(ST_RULER) : true;
+ }
+
+ private static class ToolTipSupport extends DefaultToolTip{
+ private STContributedRulerColumn control;
+ class ToolTipArea{
+ int line;
+ ISTAnnotationColumn ac;
+
+ ToolTipArea(int line,ISTAnnotationColumn ac){
+ this.line = line;
+ this.ac = ac;
+ }
+
+ public String getToolTip(){
+ return ac.getTooltip(line);
+ }
+
+ }
+
+ protected ToolTipSupport(STContributedRulerColumn control, int style,boolean manualActivation) {
+ super(control.getControl(), style, manualActivation);
+ this.control = control;
+ }
+
+ protected Object getToolTipArea(Event event) {
+
+ int line = control.toDocumentLineNumber(event.y);
+
+ return new ToolTipArea(line,control.getAnnotationColumn(line));
+ }
+
+ protected Composite createToolTipContentArea(Event event,
+ Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new FillLayout());
+ Label b = new Label(comp,SWT.NONE);
+ ToolTipArea area = (ToolTipArea)getToolTipArea(event);
+ if (area != null && area.getToolTip().trim().length()>0){
+ b.setText(area.getToolTip());
+ }
+ return comp;
+ }
+
+ public static void enableFor(STContributedRulerColumn control) {
+ new ToolTipSupport(control, ToolTip.NO_RECREATE, false);
+ }
+ }
+
+ protected IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors) {
+ IOverviewRuler ruler= new STOverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, sharedColors);
+ MarkerAnnotationPreferences fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
+ Iterator<?> e= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ while (e.hasNext()) {
+ AnnotationPreference preference= (AnnotationPreference) e.next();
+ if (preference.contributesToHeader())
+ ruler.addHeaderAnnotationType(preference.getAnnotationType());
+ }
+ return ruler;
+
+ }
+
+ private void showLinesColored(){
+ STOverviewRuler or = (STOverviewRuler)getOverviewRuler();
+ AnnotationModel am = (AnnotationModel)or.getModel();
+ IDocument doc = getSourceViewer().getDocument();
+ int lines = doc.getNumberOfLines();
+
+ for(int i=0;i<lines;i++){
+ try {
+ Color color = fInput.getColor(i);
+ int r = color.getRed();
+ int g = color.getGreen();
+ int b = color.getBlue();
+ if (r !=255 || g != 255 || b!= 255){
+ int offset = doc.getLineOffset(i);
+ String type = STAnnotatedSourceEditorActivator.getUniqueIdentifier() + STAnnotatedSourceEditorActivator.getAnnotationType();
+ Annotation annotation = new Annotation(type,true,"");
+ or.setAnnotationColor(annotation, color);
+ am.addAnnotation(annotation,new Position(offset));
+ }
+ } catch (BadLocationException e) {
+ Status s =new Status(Status.ERROR,STAnnotatedSourceEditorActivator.PLUGIN_ID,Status.ERROR,e.getMessage(),e);
+ STAnnotatedSourceEditorActivator.getDefault().getLog().log(s);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedSourceEditorActivator.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedSourceEditorActivator.java
new file mode 100644
index 0000000..90cedbf
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STAnnotatedSourceEditorActivator.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+
+**********************************************************************
+*********/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class STAnnotatedSourceEditorActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor";
+
+ private static final String ANNOTATION_TYPE = ".coloredLines";
+
+ // The shared instance
+ private static STAnnotatedSourceEditorActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public STAnnotatedSourceEditorActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ EditorsUI.getPreferenceStore().setValue("STRuler",true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static STAnnotatedSourceEditorActivator getDefault() {
+ return plugin;
+ }
+
+ public static String getAnnotationType()
+ {
+ return ANNOTATION_TYPE;
+ }
+
+ public static String getUniqueIdentifier()
+ {
+ return PLUGIN_ID;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STChangeRulerColumn.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STChangeRulerColumn.java
new file mode 100644
index 0000000..fa2e057
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STChangeRulerColumn.java
@@ -0,0 +1,390 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.internal.text.revisions.RevisionPainter;
+import org.eclipse.jface.internal.text.source.DiffPainter;
+import org.eclipse.jface.text.revisions.IRevisionListener;
+import org.eclipse.jface.text.revisions.IRevisionRulerColumn;
+import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
+import org.eclipse.jface.text.revisions.RevisionInformation;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IChangeRulerColumn;
+import org.eclipse.jface.text.source.ILineRange;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.jface.text.source.IVerticalRulerInfoExtension;
+import org.eclipse.jface.text.source.IVerticalRulerListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * A vertical ruler column displaying line numbers and serving as a UI for quick diff.
+ * Clients usually instantiate and configure object of this class.
+ *
+ * @since 3.0
+ */
+public final class STChangeRulerColumn extends STRulerColumn implements IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn, IRevisionRulerColumn, IRevisionRulerColumnExtension {
+ /** The ruler's annotation model. */
+ private IAnnotationModel fAnnotationModel;
+ /** <code>true</code> if changes should be displayed using character indications instead of background colors. */
+ private boolean fCharacterDisplay;
+ /**
+ * The revision painter strategy.
+ *
+ * @since 3.2
+ */
+ private final RevisionPainter fRevisionPainter;
+ /**
+ * The diff information painter strategy.
+ *
+ * @since 3.2
+ */
+ private final DiffPainter fDiffPainter;
+ /**
+ * Whether to show number or to behave like a change ruler column.
+ * @since 3.3
+ */
+ private boolean fShowSTRuler= true;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param sharedColors the shared colors provider to use
+ */
+ public STChangeRulerColumn(ISharedTextColors sharedColors,ISTAnnotationColumn ac) {
+ super(ac);
+ Assert.isNotNull(sharedColors);
+ fRevisionPainter= new RevisionPainter(this, sharedColors);
+ fDiffPainter= new DiffPainter(this, sharedColors);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.LineNumberRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite)
+ */
+ public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
+ Control control= super.createControl(parentRuler, parentControl);
+ fRevisionPainter.setParentRuler(parentRuler);
+ fDiffPainter.setParentRuler(parentRuler);
+ return control;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
+ */
+ public int getLineOfLastMouseButtonActivity() {
+ return getParentRuler().getLineOfLastMouseButtonActivity();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
+ */
+ public int toDocumentLineNumber(int y_coordinate) {
+ return getParentRuler().toDocumentLineNumber(y_coordinate);
+ }
+
+ /*
+ * @see IVerticalRulerColumn#setModel(IAnnotationModel)
+ */
+ public void setModel(IAnnotationModel model) {
+ setAnnotationModel(model);
+ fRevisionPainter.setModel(model);
+ fDiffPainter.setModel(model);
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(true);
+ postRedraw();
+ }
+
+ private void setAnnotationModel(IAnnotationModel model) {
+ if (fAnnotationModel != model)
+ fAnnotationModel= model;
+ }
+
+
+ /**
+ * Sets the display mode of the ruler. If character mode is set to <code>true</code>, diff
+ * information will be displayed textually on the line number ruler.
+ *
+ * @param characterMode <code>true</code> if diff information is to be displayed textually.
+ */
+ public void setDisplayMode(boolean characterMode) {
+ if (characterMode != fCharacterDisplay) {
+ fCharacterDisplay= characterMode;
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(true);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
+ */
+ public IAnnotationModel getModel() {
+ return fAnnotationModel;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.LineNumberRulerColumn#createDisplayString(int)
+ */
+ protected String createDisplayString(int line) {
+ StringBuffer buffer= new StringBuffer();
+ if (fShowSTRuler)
+ buffer.append(super.createDisplayString(line));
+ if (fCharacterDisplay && getModel() != null)
+ buffer.append(fDiffPainter.getDisplayCharacter(line));
+ return buffer.toString();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.LineNumberRulerColumn#computeNumberOfDigits()
+ */
+ protected int computeNumberOfDigits() {
+ int digits;
+ if (fCharacterDisplay && getModel() != null) {
+ if (fShowSTRuler)
+ digits= super.computeNumberOfDigits() + 1;
+ else
+ digits= 1;
+ } else {
+ if (fShowSTRuler)
+ digits= super.computeNumberOfDigits();
+ else
+ digits= 0;
+ }
+ if (fRevisionPainter.hasInformation())
+ digits+= fRevisionPainter.getRequiredWidth();
+ return digits;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener)
+ */
+ public void addVerticalRulerListener(IVerticalRulerListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener)
+ */
+ public void removeVerticalRulerListener(IVerticalRulerListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.LineNumberRulerColumn#doPaint(org.eclipse.swt.graphics.GC)
+ */
+ void doPaint(GC gc, ILineRange visibleLines) {
+ Color foreground= gc.getForeground();
+ if (visibleLines != null) {
+ if (fRevisionPainter.hasInformation())
+ fRevisionPainter.paint(gc, visibleLines);
+ else if (fDiffPainter.hasInformation()) // don't paint quick diff colors if revisions are painted
+ fDiffPainter.paint(gc, visibleLines);
+ }
+ gc.setForeground(foreground);
+ if (fShowSTRuler || fCharacterDisplay)
+ super.doPaint(gc, visibleLines);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
+ */
+ public IAnnotationHover getHover() {
+ int activeLine= getParentRuler().getLineOfLastMouseButtonActivity();
+ if (fRevisionPainter.hasHover(activeLine))
+ return fRevisionPainter.getHover();
+ if (fDiffPainter.hasHover(activeLine))
+ return fDiffPainter.getHover();
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IChangeRulerColumn#setHover(org.eclipse.jface.text.source.IAnnotationHover)
+ */
+ public void setHover(IAnnotationHover hover) {
+ fRevisionPainter.setHover(hover);
+ fDiffPainter.setHover(hover);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IChangeRulerColumn#setBackground(org.eclipse.swt.graphics.Color)
+ */
+ public void setBackground(Color background) {
+ super.setBackground(background);
+ fRevisionPainter.setBackground(background);
+ fDiffPainter.setBackground(background);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IChangeRulerColumn#setAddedColor(org.eclipse.swt.graphics.Color)
+ */
+ public void setAddedColor(Color addedColor) {
+ fDiffPainter.setAddedColor(addedColor);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IChangeRulerColumn#setChangedColor(org.eclipse.swt.graphics.Color)
+ */
+ public void setChangedColor(Color changedColor) {
+ fDiffPainter.setChangedColor(changedColor);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IChangeRulerColumn#setDeletedColor(org.eclipse.swt.graphics.Color)
+ */
+ public void setDeletedColor(Color deletedColor) {
+ fDiffPainter.setDeletedColor(deletedColor);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.revisions.IRevisionRulerColumn#setRevisionInformation(org.eclipse.jface.text.revisions.RevisionInformation)
+ */
+ public void setRevisionInformation(RevisionInformation info) {
+ fRevisionPainter.setRevisionInformation(info);
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(true);
+ postRedraw();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension#getRevisionSelectionProvider()
+ * @since 3.2
+ */
+ public ISelectionProvider getRevisionSelectionProvider() {
+ return fRevisionPainter.getRevisionSelectionProvider();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension#setRenderingMode(org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode)
+ * @since 3.3
+ */
+ public void setRevisionRenderingMode(RenderingMode renderingMode) {
+ fRevisionPainter.setRenderingMode(renderingMode);
+ }
+
+ /**
+ * Sets the line number display mode.
+ *
+ * @param showNumbers <code>true</code> to show numbers, <code>false</code> to only show
+ * diff / revision info.
+ * @since 3.3
+ */
+ public void showLineNumbers(boolean showNumbers) {
+ if (fShowSTRuler != showNumbers) {
+ fShowSTRuler= showNumbers;
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(true);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.LineNumberRulerColumn#getWidth()
+ * @since 3.3
+ */
+ public int getWidth() {
+ int width= super.getWidth();
+ return width > 0 ? width : 8; // minimal width to display quick diff / revisions if no textual info is shown
+ }
+
+ /**
+ * Returns <code>true</code> if the ruler is showing line numbers, <code>false</code>
+ * otherwise
+ *
+ * @return <code>true</code> if line numbers are shown, <code>false</code> otherwise
+ * @since 3.3
+ */
+ public boolean isShowingSTRuler() {
+ return fShowSTRuler;
+ }
+
+ /**
+ * Returns <code>true</code> if the ruler is showing revision information, <code>false</code>
+ * otherwise
+ *
+ * @return <code>true</code> if revision information is shown, <code>false</code> otherwise
+ * @since 3.3
+ */
+ public boolean isShowingRevisionInformation() {
+ return fRevisionPainter.hasInformation();
+ }
+
+ /**
+ * Returns <code>true</code> if the ruler is showing change information, <code>false</code>
+ * otherwise
+ *
+ * @return <code>true</code> if change information is shown, <code>false</code> otherwise
+ * @since 3.3
+ */
+ public boolean isShowingChangeInformation() {
+ return fDiffPainter.hasInformation();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension#showRevisionAuthor(boolean)
+ * @since 3.3
+ */
+ public void showRevisionAuthor(boolean show) {
+ fRevisionPainter.showRevisionAuthor(show);
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(true);
+ postRedraw();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension#showRevisionId(boolean)
+ * @since 3.3
+ */
+ public void showRevisionId(boolean show) {
+ fRevisionPainter.showRevisionId(show);
+ updateNumberOfDigits();
+ computeIndentations();
+ layout(true);
+ postRedraw();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension#addRevisionListener(org.eclipse.jface.text.revisions.IRevisionListener)
+ * @since 3.3
+ */
+ public void addRevisionListener(IRevisionListener listener) {
+ fRevisionPainter.addRevisionListener(listener);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension#removeRevisionListener(org.eclipse.jface.text.revisions.IRevisionListener)
+ * @since 3.3
+ */
+ public void removeRevisionListener(IRevisionListener listener) {
+ fRevisionPainter.removeRevisionListener(listener);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.LineNumberRulerColumn#handleDispose()
+ * @since 3.3
+ */
+ protected void handleDispose() {
+ fRevisionPainter.setParentRuler(null);
+ fRevisionPainter.setModel(null);
+ fDiffPainter.setParentRuler(null);
+ fDiffPainter.setModel(null);
+ super.handleDispose();
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STConstructedTextEditorMessages.properties b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STConstructedTextEditorMessages.properties
new file mode 100644
index 0000000..0c9d76c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STConstructedTextEditorMessages.properties
@@ -0,0 +1,4 @@
+Editor.ToggleSTColumnAction.label=Show Annotation &Columns
+Editor.ToggleSTColumnAction.description=Show Annotation Columns
+Editor.STColumnAction.tooltip=Display the Annotation Column Ruler
+Editor.STColumnAction.image=
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STContributedRulerColumn.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STContributedRulerColumn.java
new file mode 100644
index 0000000..0836fd7
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STContributedRulerColumn.java
@@ -0,0 +1,798 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.revisions.IRevisionRulerColumn;
+import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
+import org.eclipse.jface.text.revisions.RevisionInformation;
+import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode;
+import org.eclipse.jface.text.source.AnnotationModel;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelExtension;
+import org.eclipse.jface.text.source.IChangeRulerColumn;
+import org.eclipse.jface.text.source.ILineDifferExtension;
+import org.eclipse.jface.text.source.ILineDifferExtension2;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRulerColumn;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.jface.text.source.IVerticalRulerInfoExtension;
+import org.eclipse.jface.text.source.IVerticalRulerListener;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.preferencespages.STAnnotatedSourceEditorPreferencePage;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+import org.eclipse.ui.internal.texteditor.PropertyEventDispatcher;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension;
+import org.eclipse.ui.texteditor.ITextEditorExtension2;
+import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
+import org.eclipse.ui.texteditor.quickdiff.QuickDiff;
+import org.eclipse.ui.texteditor.rulers.AbstractContributedRulerColumn;
+
+
+public class STContributedRulerColumn extends AbstractContributedRulerColumn implements IVerticalRulerInfo, IVerticalRulerInfoExtension {
+ /**
+ * Forwarder for preference checks and ruler creation. Needed to maintain the forwarded APIs in
+ * {@link AbstractDecoratedTextEditor}.
+ */
+ public static interface ICompatibilityForwarder {
+ IVerticalRulerColumn createSTRulerColumn();
+ boolean isQuickDiffEnabled();
+ boolean isSTRulerVisible();
+ }
+
+ public static final String ID= "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.column"; //$NON-NLS-1$
+
+ private static final String FG_COLOR_KEY= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR;
+ private static final String BG_COLOR_KEY= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND;
+ private static final String USE_DEFAULT_BG_KEY= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT;
+ private final static String ST_KEY= STAnnotatedSourceEditorPreferencePage.EDITOR_ST_RULER;
+ private final static String REVISION_ASK_BEFORE_QUICKDIFF_SWITCH_KEY= AbstractDecoratedTextEditorPreferenceConstants.REVISION_ASK_BEFORE_QUICKDIFF_SWITCH;
+
+ private IVerticalRulerColumn fDelegate;
+ /**
+ * The annotation preferences.
+ */
+ private final MarkerAnnotationPreferences fAnnotationPreferences= EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
+
+ /**
+ * Preference dispatcher that registers a single listener so we don't have to manage every
+ * single preference listener.
+ */
+ private PropertyEventDispatcher fDispatcher;
+ private ISourceViewer fViewer;
+ private ICompatibilityForwarder fForwarder;
+
+
+ private Label labelColumn;
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite)
+ */
+ public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
+ Assert.isTrue(fDelegate != null);
+ ITextViewer viewer= parentRuler.getTextViewer();
+ Assert.isLegal(viewer instanceof ISourceViewer);
+ fViewer= (ISourceViewer) viewer;
+ initialize();
+ Control control= fDelegate.createControl(parentRuler, parentControl);
+ return control;
+ }
+
+ public void setLabelColumn(Label label){
+ labelColumn = label;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerColumn#getControl()
+ */
+ public Control getControl() {
+ return fDelegate.getControl();
+ }
+
+ public ISTAnnotationColumn getAnnotationColumn(int line){
+ if (fDelegate instanceof STChangeRulerColumn){
+ return ((STChangeRulerColumn)fDelegate).getSTAnnotationColumn();
+ }
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerColumn#getWidth()
+ */
+ public int getWidth() {
+ return fDelegate.getWidth();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerColumn#redraw()
+ */
+ public void redraw() {
+ fDelegate.redraw();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerColumn#setFont(org.eclipse.swt.graphics.Font)
+ */
+ public void setFont(Font font) {
+ fDelegate.setFont(font);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerColumn#setModel(org.eclipse.jface.text.source.IAnnotationModel)
+ */
+ public void setModel(IAnnotationModel model) {
+ if (getQuickDiffPreference())
+ fDelegate.setModel(model);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
+ */
+ public int getLineOfLastMouseButtonActivity() {
+ if (fDelegate instanceof IVerticalRulerInfo)
+ ((IVerticalRulerInfo) fDelegate).getLineOfLastMouseButtonActivity();
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int)
+ */
+ public int toDocumentLineNumber(int y_coordinate) {
+ if (fDelegate instanceof IVerticalRulerInfo)
+ return ((IVerticalRulerInfo) fDelegate).toDocumentLineNumber(y_coordinate);
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener)
+ */
+ public void addVerticalRulerListener(IVerticalRulerListener listener) {
+ if (fDelegate instanceof IVerticalRulerInfoExtension)
+ ((IVerticalRulerInfoExtension) fDelegate).addVerticalRulerListener(listener);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover()
+ */
+ public IAnnotationHover getHover() {
+ if (fDelegate instanceof IVerticalRulerInfoExtension)
+ return ((IVerticalRulerInfoExtension) fDelegate).getHover();
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel()
+ */
+ public IAnnotationModel getModel() {
+ if (fDelegate instanceof IVerticalRulerInfoExtension)
+ return ((IVerticalRulerInfoExtension) fDelegate).getModel();
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener)
+ */
+ public void removeVerticalRulerListener(IVerticalRulerListener listener) {
+ if (fDelegate instanceof IVerticalRulerInfoExtension)
+ ((IVerticalRulerInfoExtension) fDelegate).removeVerticalRulerListener(listener);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.rulers.AbstractContributedRulerColumn#columnRemoved()
+ */
+ public void columnRemoved() {
+ if (fDispatcher != null) {
+ fDispatcher.dispose();
+ fDispatcher= null;
+ }
+ }
+
+ private IPreferenceStore getPreferenceStore() {
+ return EditorsUI.getPreferenceStore();
+ }
+
+ private ISharedTextColors getSharedColors() {
+ return EditorsUI.getSharedTextColors();
+ }
+
+ /**
+ * Initializes the given line number ruler column from the preference store.
+ */
+ private void initialize() {
+ final IPreferenceStore store= getPreferenceStore();
+ if (store == null)
+ return;
+
+ // initial set up
+ updateForegroundColor(store, fDelegate);
+ updateBackgroundColor(store, fDelegate);
+
+ updateLineNumbersVisibility(fDelegate);
+ updateQuickDiffVisibility(fDelegate);
+ updateCharacterMode(store, fDelegate);
+ updateRevisionRenderingMode(store, fDelegate);
+ updateRevisionAuthorVisibility(store, fDelegate);
+ updateRevisionIdVisibility(store, fDelegate);
+
+ Map<Object, AnnotationPreference> annotationPrefs= getAnnotationPreferenceMap();
+ final AnnotationPreference changedPref= annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffChange"); //$NON-NLS-1$
+ final AnnotationPreference addedPref= annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffAddition"); //$NON-NLS-1$
+ final AnnotationPreference deletedPref= annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffDeletion"); //$NON-NLS-1$
+ updateChangedColor(changedPref, store, fDelegate);
+ updateAddedColor(addedPref, store, fDelegate);
+ updateDeletedColor(deletedPref, store, fDelegate);
+
+ if (fDelegate != null)
+ fDelegate.redraw();
+
+ // listen to changes
+ fDispatcher= new PropertyEventDispatcher(store);
+
+ fDispatcher.addPropertyChangeListener(FG_COLOR_KEY, new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateForegroundColor(store, fDelegate);
+ fDelegate.redraw();
+ }
+ });
+ IPropertyChangeListener backgroundHandler= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateBackgroundColor(store, fDelegate);
+ fDelegate.redraw();
+ }
+ };
+ fDispatcher.addPropertyChangeListener(BG_COLOR_KEY, backgroundHandler);
+ fDispatcher.addPropertyChangeListener(USE_DEFAULT_BG_KEY, backgroundHandler);
+
+ fDispatcher.addPropertyChangeListener(ST_KEY, new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ // only handle quick diff on/off information, but not ruler visibility (handled by AbstractDecoratedTextEditor)
+
+ updateLineNumbersVisibility(fDelegate);
+ }
+ });
+
+ fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateCharacterMode(store, fDelegate);
+ }
+ });
+
+ fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE, new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateRevisionRenderingMode(store, fDelegate);
+ }
+ });
+
+ fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_AUTHOR, new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateRevisionAuthorVisibility(store, fDelegate);
+ }
+ });
+
+ fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_REVISION, new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateRevisionIdVisibility(store, fDelegate);
+ }
+ });
+
+ fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateQuickDiffVisibility(fDelegate);
+ }
+ });
+
+ if (changedPref != null) {
+ fDispatcher.addPropertyChangeListener(changedPref.getColorPreferenceKey(), new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateChangedColor(changedPref, store, fDelegate);
+ fDelegate.redraw();
+ }
+ });
+ }
+ if (addedPref != null) {
+ fDispatcher.addPropertyChangeListener(addedPref.getColorPreferenceKey(), new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateAddedColor(addedPref, store, fDelegate);
+ fDelegate.redraw();
+ }
+ });
+ }
+ if (deletedPref != null) {
+ fDispatcher.addPropertyChangeListener(deletedPref.getColorPreferenceKey(), new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ updateDeletedColor(deletedPref, store, fDelegate);
+ fDelegate.redraw();
+ }
+ });
+ }
+ }
+
+ private Map<Object, AnnotationPreference> getAnnotationPreferenceMap() {
+ Map<Object, AnnotationPreference> annotationPrefs= new HashMap<Object, AnnotationPreference>();
+ Iterator<?> iter= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ while (iter.hasNext()) {
+ AnnotationPreference pref= (AnnotationPreference) iter.next();
+ Object type= pref.getAnnotationType();
+ annotationPrefs.put(type, pref);
+ }
+ return annotationPrefs;
+ }
+
+ private void updateForegroundColor(IPreferenceStore store, IVerticalRulerColumn column) {
+ RGB rgb= getColorFromStore(store, FG_COLOR_KEY);
+ if (rgb == null)
+ rgb= new RGB(0, 0, 0);
+ ISharedTextColors sharedColors= getSharedColors();
+ if (column instanceof STRulerColumn)
+ ((STRulerColumn) column).setForeground(sharedColors.getColor(rgb));
+ }
+
+ private void updateBackgroundColor(IPreferenceStore store, IVerticalRulerColumn column) {
+ // background color: same as editor, or system default
+ RGB rgb;
+ if (store.getBoolean(USE_DEFAULT_BG_KEY))
+ rgb= null;
+ else
+ rgb= getColorFromStore(store, BG_COLOR_KEY);
+ ISharedTextColors sharedColors= getSharedColors();
+ if (column instanceof STRulerColumn)
+ ((STRulerColumn) column).setBackground(sharedColors.getColor(rgb));
+ }
+
+ private void updateChangedColor(AnnotationPreference pref, IPreferenceStore store, IVerticalRulerColumn column) {
+ if (pref != null && column instanceof IChangeRulerColumn) {
+ RGB rgb= getColorFromAnnotationPreference(store, pref);
+ ((IChangeRulerColumn) column).setChangedColor(getSharedColors().getColor(rgb));
+ }
+ }
+
+ private void updateAddedColor(AnnotationPreference pref, IPreferenceStore store, IVerticalRulerColumn column) {
+ if (pref != null && column instanceof IChangeRulerColumn) {
+ RGB rgb= getColorFromAnnotationPreference(store, pref);
+ ((IChangeRulerColumn) column).setAddedColor(getSharedColors().getColor(rgb));
+ }
+ }
+
+ private void updateDeletedColor(AnnotationPreference pref, IPreferenceStore store, IVerticalRulerColumn column) {
+ if (pref != null && column instanceof IChangeRulerColumn) {
+ RGB rgb= getColorFromAnnotationPreference(store, pref);
+ ((IChangeRulerColumn) column).setDeletedColor(getSharedColors().getColor(rgb));
+ }
+ }
+
+ private void updateCharacterMode(IPreferenceStore store, IVerticalRulerColumn column) {
+ if (column instanceof STChangeRulerColumn) {
+ STChangeRulerColumn lncrc= (STChangeRulerColumn) column;
+ lncrc.setDisplayMode(store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE));
+ }
+ }
+
+ private void updateLineNumbersVisibility(IVerticalRulerColumn column) {
+ if (column instanceof STChangeRulerColumn){
+ if (labelColumn != null){
+ labelColumn.setVisible(getLineNumberPreference());
+ Label labelName = (Label)labelColumn.getParent().getChildren()[labelColumn.getParent().getChildren().length-2];
+ labelName.setVisible(labelColumn.isVisible());
+
+ }
+ ((STChangeRulerColumn) column).showLineNumbers(getLineNumberPreference());
+ }
+ }
+
+ private void updateRevisionRenderingMode(IPreferenceStore store, IVerticalRulerColumn column) {
+ if (column instanceof IRevisionRulerColumnExtension) {
+ String option= store.getString(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE);
+ RenderingMode[] modes= { IRevisionRulerColumnExtension.AUTHOR, IRevisionRulerColumnExtension.AGE, IRevisionRulerColumnExtension.AUTHOR_SHADED_BY_AGE };
+ for (int i= 0; i < modes.length; i++) {
+ if (modes[i].name().equals(option)) {
+ ((IRevisionRulerColumnExtension) column).setRevisionRenderingMode(modes[i]);
+ return;
+ }
+ }
+ }
+ }
+
+ private void updateRevisionAuthorVisibility(IPreferenceStore store, IVerticalRulerColumn column) {
+ if (column instanceof IRevisionRulerColumnExtension) {
+ boolean show= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_AUTHOR);
+ ((IRevisionRulerColumnExtension) column).showRevisionAuthor(show);
+ }
+ }
+
+ private void updateRevisionIdVisibility(IPreferenceStore store, IVerticalRulerColumn column) {
+ if (column instanceof IRevisionRulerColumnExtension) {
+ boolean show= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_REVISION);
+ ((IRevisionRulerColumnExtension) column).showRevisionId(show);
+ }
+ }
+
+ private void updateQuickDiffVisibility(IVerticalRulerColumn column) {
+ boolean show= getQuickDiffPreference();
+ if (show == isShowingChangeInformation())
+ return;
+
+ if (show)
+ installChangeRulerModel(column);
+ else
+ uninstallChangeRulerModel(column);
+ }
+
+ /**
+ * Returns whether the line number ruler column should be
+ * visible according to the preference store settings. Subclasses may override this
+ * method to provide a custom preference setting.
+ *
+ * @return <code>true</code> if the line numbers should be visible
+ */
+ private boolean getLineNumberPreference() {
+ if (fForwarder != null)
+ return fForwarder.isSTRulerVisible();
+ IPreferenceStore store= getPreferenceStore();
+ return store != null ? store.getBoolean(ST_KEY) : false;
+ }
+
+ /**
+ * Returns whether quick diff info should be visible upon opening an editor
+ * according to the preference store settings.
+ *
+ * @return <code>true</code> if the line numbers should be visible
+ */
+ private boolean getQuickDiffPreference() {
+ if (fForwarder != null)
+ return fForwarder.isQuickDiffEnabled();
+ IPreferenceStore store= getPreferenceStore();
+ boolean setting= store != null ? store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON) : false;
+ if (!setting)
+ return false;
+
+ boolean modifiable;
+ ITextEditor editor= getEditor();
+ if (editor instanceof ITextEditorExtension2) {
+ ITextEditorExtension2 ext= (ITextEditorExtension2) editor;
+ modifiable= ext.isEditorInputModifiable();
+ } else if (editor instanceof ITextEditorExtension) {
+ ITextEditorExtension ext= (ITextEditorExtension) editor;
+ modifiable= ext.isEditorInputReadOnly();
+ } else if (editor != null) {
+ modifiable= editor.isEditable();
+ } else {
+ modifiable= true;
+ }
+ return modifiable;
+ }
+
+ /**
+ * Extracts the color preference for the given preference from the given store.
+ * If the given store indicates that the default value is to be used, or
+ * the value stored in the preferences store is <code>null</code>,
+ * the value is taken from the <code>AnnotationPreference</code>'s default
+ * color value.
+ * <p>
+ * The return value is
+ * </p>
+ *
+ * @param store the preference store
+ * @param pref the annotation preference
+ * @return the RGB color preference, not <code>null</code>
+ */
+ private static RGB getColorFromAnnotationPreference(IPreferenceStore store, AnnotationPreference pref) {
+ String key= pref.getColorPreferenceKey();
+ RGB rgb= null;
+ if (store.contains(key)) {
+ if (store.isDefault(key))
+ rgb= pref.getColorPreferenceValue();
+ else
+ rgb= PreferenceConverter.getColor(store, key);
+ }
+ if (rgb == null)
+ rgb= pref.getColorPreferenceValue();
+ return rgb;
+ }
+
+ private static RGB getColorFromStore(IPreferenceStore store, String key) {
+ RGB rgb= null;
+ if (store.contains(key)) {
+ if (store.isDefault(key))
+ rgb= PreferenceConverter.getDefaultColor(store, key);
+ else
+ rgb= PreferenceConverter.getColor(store, key);
+ }
+ return rgb;
+ }
+
+ /**
+ * Ensures that quick diff information is displayed and the quick diff provider is the one with
+ * the specified id. If a different quick diff provider is in use, the user may be asked whether
+ * he wants to switch.
+ *
+ * @param diffProviderId the quick diff provider id to use
+ * @return <code>true</code> if quick diff could be enabled for the given id,
+ * <code>false</code> otherwise
+ */
+ private boolean ensureQuickDiffProvider(String diffProviderId) {
+ if (!isShowingChangeInformation())
+ installChangeRulerModel(fDelegate); // FIXME pass provider id
+
+ IAnnotationModel annotationModel= fViewer.getAnnotationModel();
+ IAnnotationModel oldDiffer= getDiffer();
+ if (oldDiffer == null && annotationModel != null)
+ return false; // quick diff is enabled, but no differ? not working for whatever reason
+
+ if (annotationModel == null)
+ annotationModel= new AnnotationModel();
+ if (!(annotationModel instanceof IAnnotationModelExtension))
+ return false;
+
+ QuickDiff util= new QuickDiff();
+ Object oldDifferId= util.getConfiguredQuickDiffProvider(oldDiffer);
+ if (oldDifferId.equals(diffProviderId)) {
+ if (oldDiffer instanceof ILineDifferExtension)
+ ((ILineDifferExtension) oldDiffer).resume();
+ return true;
+ }
+
+ // Check whether the desired provider is available at all
+ IAnnotationModel newDiffer= util.createQuickDiffAnnotationModel(getEditor(), diffProviderId);
+ if (util.getConfiguredQuickDiffProvider(newDiffer).equals(oldDifferId)) {
+ if (oldDiffer instanceof ILineDifferExtension)
+ ((ILineDifferExtension) oldDiffer).resume();
+ return true;
+ }
+
+ // quick diff is showing with the wrong provider - ask the user whether he wants to switch
+ IPreferenceStore store= EditorsUI.getPreferenceStore();
+ if (oldDiffer != null && !store.getString(REVISION_ASK_BEFORE_QUICKDIFF_SWITCH_KEY).equals(MessageDialogWithToggle.ALWAYS)) {
+ MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openOkCancelConfirm(
+ fViewer.getTextWidget().getShell(),
+ STRulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_title,
+ STRulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_message,
+ STRulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_rememberquestion,
+ true,
+ store,
+ REVISION_ASK_BEFORE_QUICKDIFF_SWITCH_KEY);
+ if (toggleDialog.getReturnCode() != Window.OK)
+ return false;
+ }
+
+ IAnnotationModelExtension modelExtension=(IAnnotationModelExtension) annotationModel;
+ modelExtension.removeAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
+
+
+ modelExtension.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, newDiffer);
+
+ if (fDelegate instanceof IChangeRulerColumn)
+ ((IChangeRulerColumn) fDelegate).setModel(annotationModel); // picks up the new model attachment
+
+ return true;
+ }
+
+ /**
+ * Installs the differ annotation model with the current quick diff display.
+ *
+ * @param column the column to install the model on
+ */
+ private void installChangeRulerModel(IVerticalRulerColumn column) {
+ if (column instanceof IChangeRulerColumn) {
+ IAnnotationModel model= getAnnotationModelWithDiffer();
+ ((IChangeRulerColumn) column).setModel(model);
+ if (model != null) {
+ ISourceViewer viewer= fViewer;
+ if (viewer != null && viewer.getAnnotationModel() == null)
+ viewer.showAnnotations(true);
+ }
+ }
+ }
+
+ /**
+ * Uninstalls the differ annotation model from the current quick diff display.
+ *
+ * @param column the column to remove the model from
+ */
+ private void uninstallChangeRulerModel(IVerticalRulerColumn column) {
+ if (column instanceof IChangeRulerColumn)
+ ((IChangeRulerColumn) column).setModel(null);
+ IAnnotationModel model= getDiffer();
+ if (model instanceof ILineDifferExtension)
+ ((ILineDifferExtension) model).suspend();
+
+ ISourceViewer viewer= fViewer;
+ if (viewer != null && viewer.getAnnotationModel() == null)
+ viewer.showAnnotations(false);
+ }
+
+ /**
+ * Returns the annotation model that contains the quick diff annotation model.
+ * <p>
+ * Extracts the line differ from the displayed document's annotation model. If none can be found,
+ * a new differ is created and attached to the annotation model.</p>
+ *
+ * @return the annotation model that contains the line differ, or <code>null</code> if none could be found or created
+ * @see IChangeRulerColumn#QUICK_DIFF_MODEL_ID
+ */
+ private IAnnotationModel getAnnotationModelWithDiffer() {
+ ISourceViewer viewer= fViewer;
+ if (viewer == null)
+ return null;
+
+ IAnnotationModel m= viewer.getAnnotationModel();
+ IAnnotationModelExtension model= null;
+ if (m instanceof IAnnotationModelExtension)
+ model= (IAnnotationModelExtension) m;
+
+ IAnnotationModel differ= getDiffer();
+ // create diff model if it doesn't
+ if (differ == null) {
+ IPreferenceStore store= getPreferenceStore();
+ if (store != null) {
+ String defaultId= store.getString(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER);
+ differ= new QuickDiff().createQuickDiffAnnotationModel(getEditor(), defaultId);
+ if (differ != null) {
+ if (model == null)
+ model= new AnnotationModel();
+ model.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, differ);
+ }
+ }
+ } else if (differ instanceof ILineDifferExtension2) {
+ if (((ILineDifferExtension2) differ).isSuspended())
+ ((ILineDifferExtension) differ).resume();
+ } else if (differ instanceof ILineDifferExtension) {
+ ((ILineDifferExtension) differ).resume();
+ }
+
+ return (IAnnotationModel)model;
+ }
+
+ /**
+ * Extracts the line differ from the displayed document's annotation model. If none can be found,
+ * <code>null</code> is returned.
+ *
+ * @return the line differ, or <code>null</code> if none could be found
+ */
+ private IAnnotationModel getDiffer() {
+ // get annotation model extension
+ ISourceViewer viewer= fViewer;
+ if (viewer == null)
+ return null;
+
+ IAnnotationModel m= viewer.getAnnotationModel();
+ if (m == null && fDelegate instanceof IChangeRulerColumn)
+ m= ((IChangeRulerColumn)fDelegate).getModel();
+
+ if (!(m instanceof IAnnotationModelExtension))
+ return null;
+
+ IAnnotationModelExtension model= (IAnnotationModelExtension)m;
+
+ // get diff model if it exists already
+ return model.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
+ }
+
+ /**
+ * Sets the forwarder. Used by {@link AbstractDecoratedTextEditor} to maintain the contract of
+ * its {@link AbstractDecoratedTextEditor#createLineNumberRulerColumn} method.
+ *
+ * @param forwarder the forwarder
+ */
+ public void setForwarder(ICompatibilityForwarder forwarder) {
+ fForwarder= forwarder;
+ fDelegate= forwarder.createSTRulerColumn();
+ }
+
+ /**
+ * Initializes the given line number ruler column from the preference store.
+ *
+ * @param rulerColumn the ruler column to be initialized
+ */
+ public void initializeSTRulerColumn(STRulerColumn rulerColumn) {
+ IPreferenceStore store= getPreferenceStore();
+ if (store != null) {
+ updateForegroundColor(store, rulerColumn);
+ updateBackgroundColor(store, rulerColumn);
+ updateLineNumbersVisibility(rulerColumn);
+ rulerColumn.redraw();
+ }
+ }
+
+ /**
+ * Returns <code>true</code> if the ruler is showing line numbers, <code>false</code> if it
+ * is only showing change information.
+ *
+ * @return <code>true</code> if line numbers are shown, <code>false</code> otherwise
+ */
+ public boolean isShowingSTRuler() {
+ boolean b = fDelegate instanceof STRulerColumn && ((STChangeRulerColumn) fDelegate).isShowingSTRuler();
+ return b;
+ }
+
+ /**
+ * Returns <code>true</code> if the ruler is showing change information, <code>false</code>
+ * if it is only showing line numbers.
+ *
+ * @return <code>true</code> if change information is shown, <code>false</code> otherwise
+ */
+ public boolean isShowingChangeInformation() {
+ return fDelegate instanceof STChangeRulerColumn && ((STChangeRulerColumn) fDelegate).isShowingChangeInformation();
+ }
+
+ /**
+ * Shows revision information on the receiver.
+ *
+ * @param info the revision information to show
+ * @param quickDiffProviderId the id of the corresponding quick diff provider
+ */
+ public void showRevisionInformation(RevisionInformation info, String quickDiffProviderId) {
+ if (!ensureQuickDiffProvider(quickDiffProviderId))
+ return;
+
+ if (fDelegate instanceof IRevisionRulerColumn)
+ ((IRevisionRulerColumn) fDelegate).setRevisionInformation(info);
+ }
+
+ /**
+ * Hides revision information.
+ */
+ public void hideRevisionInformation() {
+ if (fDelegate instanceof IRevisionRulerColumn)
+ ((IRevisionRulerColumn) fDelegate).setRevisionInformation(null);
+ }
+
+ /**
+ * Returns <code>true</code> if the ruler is showing revision information, <code>false</code>
+ * if it is only showing line numbers.
+ *
+ * @return <code>true</code> if revision information is shown, <code>false</code> otherwise
+ */
+ public boolean isShowingRevisionInformation() {
+ if (fDelegate instanceof STChangeRulerColumn)
+ return ((STChangeRulerColumn) fDelegate).isShowingRevisionInformation();
+ return false;
+ }
+
+ /**
+ * Returns the selection provider of the revision column, <code>null</code> if none is
+ * available.
+ *
+ * @return the revision selection provider
+ */
+ public ISelectionProvider getRevisionSelectionProvider() {
+ if (fDelegate instanceof IRevisionRulerColumnExtension)
+ return ((IRevisionRulerColumnExtension) fDelegate).getRevisionSelectionProvider();
+ return null;
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STJFaceTextMessages.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STJFaceTextMessages.java
new file mode 100644
index 0000000..410b5cf
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STJFaceTextMessages.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+02: * Copyright (c) 2000, 2005 IBM Corporation and others.
+03: * All rights reserved. This program and the accompanying materials
+04: * are made available under the terms of the Eclipse Public License v1.0
+05: * which accompanies this distribution, and is available at
+06: * http://www.eclipse.org/legal/epl-v10.html
+07: *
+08: * Contributors:
+09: * IBM Corporation - initial API and implementation
+10: *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Accessor for the <code>JFaceTextMessages.properties</code> file in
+ * package <code>org.eclipse.jface.text</code>.
+ * @since 2.0
+ */
+class STJFaceTextMessages {
+
+ /** The resource bundle name. */
+ private static final String RESOURCE_BUNDLE= "org.eclipse.jface.text.JFaceTextMessages";//$NON-NLS-1$
+
+ /** The resource bundle. */
+ private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+ /**
+ * Prohibits the creation of accessor objects.
+ */
+ private STJFaceTextMessages() {
+ }
+
+ /**
+ * Returns the string found in the resource bundle under the given key or a place holder string.
+ *
+ * @param key the look up key
+ * @return the value found under the given key
+ */
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Gets a string from the resource bundle and formats it with the argument
+ *
+ * @param key the string used to get the bundle value, must not be null
+ * @param args arguments used when formatting the string
+ * @return the formatted string
+ * @since 3.0
+ */
+ public static String getFormattedString(String key, Object[] args) {
+ String format= null;
+ try {
+ format= fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ return MessageFormat.format(format, args);
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STOverviewRuler.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STOverviewRuler.java
new file mode 100644
index 0000000..cf7f084
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STOverviewRuler.java
@@ -0,0 +1,1309 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.jface.text.JFaceTextUtil;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationAccess;
+import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelListener;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.source.projection.AnnotationBag;
+
+public class STOverviewRuler implements IOverviewRuler {
+
+ /**
+ * Internal listener class.
+ */
+ class InternalListener implements ITextListener, IAnnotationModelListener {
+
+ /*
+ * @see ITextListener#textChanged
+ */
+ public void textChanged(TextEvent e) {
+ if (fTextViewer != null && e.getDocumentEvent() == null && e.getViewerRedrawState()) {
+ // handle only changes of visible document
+ redraw();
+ }
+ }
+
+ /*
+ * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
+ */
+ public void modelChanged(IAnnotationModel model) {
+ update();
+ }
+ }
+
+ /**
+ * Enumerates the annotations of a specified type and characteristics
+ * of the associated annotation model.
+ */
+ class FilterIterator implements Iterator<Annotation> {
+
+ final static int TEMPORARY= 1 << 1;
+ final static int PERSISTENT= 1 << 2;
+ final static int IGNORE_BAGS= 1 << 3;
+
+ private Iterator<?> fIterator;
+ private Object fType;
+ private Annotation fNext;
+ private int fStyle;
+
+ /**
+ * Creates a new filter iterator with the given specification.
+ *
+ * @param annotationType the annotation type
+ * @param style the style
+ */
+ public FilterIterator(Object annotationType, int style) {
+ fType= annotationType;
+ fStyle= style;
+ if (fModel != null) {
+ fIterator= fModel.getAnnotationIterator();
+ skip();
+ }
+ }
+
+ /**
+ * Creates a new filter iterator with the given specification.
+ *
+ * @param annotationType the annotation type
+ * @param style the style
+ * @param iterator the iterator
+ */
+ public FilterIterator(Object annotationType, int style, Iterator<?> iterator) {
+ fType= annotationType;
+ fStyle= style;
+ fIterator= iterator;
+ skip();
+ }
+
+ private void skip() {
+
+ boolean temp= (fStyle & TEMPORARY) != 0;
+ boolean pers= (fStyle & PERSISTENT) != 0;
+ boolean ignr= (fStyle & IGNORE_BAGS) != 0;
+
+ while (fIterator.hasNext()) {
+ Annotation next= (Annotation) fIterator.next();
+
+ if (next.isMarkedDeleted())
+ continue;
+
+ if (ignr && (next instanceof AnnotationBag))
+ continue;
+
+ fNext= next;
+ Object annotationType= next.getType();
+ if (fType == null || isSubtype(annotationType)) {
+ if (temp && pers) return;
+ if (pers && next.isPersistent()) return;
+ if (temp && !next.isPersistent()) return;
+ }
+ }
+ fNext= null;
+ }
+
+ private boolean isSubtype(Object annotationType) {
+ if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
+ IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
+ return extension.isSubtype(annotationType, fType);
+ }
+ return fType.equals(annotationType);
+ }
+
+ /*
+ * @see Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return fNext != null;
+ }
+ /*
+ * @see Iterator#next()
+ */
+ public Annotation next() {
+ try {
+ return fNext;
+ } finally {
+ if (fIterator != null)
+ skip();
+ }
+ }
+ /*
+ * @see Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ * The painter of the overview ruler's header.
+ */
+ class HeaderPainter implements PaintListener {
+
+ private Color fIndicatorColor;
+ private Color fSeparatorColor;
+
+ /**
+ * Creates a new header painter.
+ */
+ public HeaderPainter() {
+ fSeparatorColor= fSharedTextColors.getColor(ViewForm.borderInsideRGB);
+ }
+
+ /**
+ * Sets the header color.
+ *
+ * @param color the header color
+ */
+ public void setColor(Color color) {
+ fIndicatorColor= color;
+ }
+
+ private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topLeft, Color bottomRight) {
+ gc.setForeground(topLeft == null ? fSeparatorColor : topLeft);
+ gc.drawLine(x, y, x + w -1, y);
+ gc.drawLine(x, y, x, y + h -1);
+
+ gc.setForeground(bottomRight == null ? fSeparatorColor : bottomRight);
+ gc.drawLine(x + w, y, x + w, y + h);
+ gc.drawLine(x, y + h, x + w, y + h);
+ }
+
+ public void paintControl(PaintEvent e) {
+
+ Point s= fHeader.getSize();
+
+ if (fIndicatorColor != null) {
+ e.gc.setBackground(fIndicatorColor);
+ Rectangle r= new Rectangle(INSET, (s.y - (2*ANNOTATION_HEIGHT)) / 2, s.x - (2*INSET), 2*ANNOTATION_HEIGHT);
+ e.gc.fillRectangle(r);
+ Display d= fHeader.getDisplay();
+ if (d != null)
+// drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, d.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), d.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ drawBevelRect(e.gc, r.x, r.y, r.width -1, r.height -1, null, null);
+ }
+
+ e.gc.setForeground(fSeparatorColor);
+ e.gc.setLineWidth(1);
+ e.gc.drawLine(0, s.y -1, s.x -1, s.y -1);
+ }
+ }
+
+ private static final int INSET= 2;
+ private static final int ANNOTATION_HEIGHT= 1;
+ private static boolean ANNOTATION_HEIGHT_SCALABLE= true;
+
+
+ /** The model of the overview ruler */
+ private IAnnotationModel fModel;
+ /** The view to which this ruler is connected */
+ private ITextViewer fTextViewer;
+ /** The ruler's canvas */
+ private Canvas fCanvas;
+ /** The ruler's header */
+ private Canvas fHeader;
+ /** The buffer for double buffering */
+ private Image fBuffer;
+ /** The internal listener */
+ private InternalListener fInternalListener= new InternalListener();
+ /** The width of this vertical ruler */
+ private int fWidth;
+ /** The hit detection cursor */
+ private Cursor fHitDetectionCursor;
+ /** The last cursor */
+ private Cursor fLastCursor;
+ /** The line of the last mouse button activity */
+ private int fLastMouseButtonActivityLine= -1;
+ /** The actual annotation height */
+ private int fAnnotationHeight= -1;
+ /** The annotation access */
+ private IAnnotationAccess fAnnotationAccess;
+ /** The header painter */
+ private HeaderPainter fHeaderPainter;
+ /**
+ * The list of annotation types to be shown in this ruler.
+ * @since 3.0
+ */
+ private Set<Object> fConfiguredAnnotationTypes= new HashSet<Object>();
+ /**
+ * The list of annotation types to be shown in the header of this ruler.
+ * @since 3.0
+ */
+ private Set<Object> fConfiguredHeaderAnnotationTypes= new HashSet<Object>();
+ /** The mapping between annotation types and colors */
+ private Map<Object, Color> fAnnotationTypes2Colors= new HashMap<Object, Color>();
+
+ /** The mapping between annotation and colors */
+ private Map<Annotation, Color> fAnnotationColors = new HashMap<Annotation, Color>();
+
+ /** The color manager */
+ private ISharedTextColors fSharedTextColors;
+ /**
+ * All available annotation types sorted by layer.
+ *
+ * @since 3.0
+ */
+ private List<Object> fAnnotationsSortedByLayer= new ArrayList<Object>();
+ /**
+ * All available layers sorted by layer.
+ * This list may contain duplicates.
+ * @since 3.0
+ */
+ private List<Integer> fLayersSortedByLayer= new ArrayList<Integer>();
+ /**
+ * Map of allowed annotation types.
+ * An allowed annotation type maps to <code>true</code>, a disallowed
+ * to <code>false</code>.
+ * @since 3.0
+ */
+ private Map fAllowedAnnotationTypes= new HashMap();
+ /**
+ * Map of allowed header annotation types.
+ * An allowed annotation type maps to <code>true</code>, a disallowed
+ * to <code>false</code>.
+ * @since 3.0
+ */
+ private Map fAllowedHeaderAnnotationTypes= new HashMap();
+ /**
+ * The cached annotations.
+ * @since 3.0
+ */
+ private List<Annotation> fCachedAnnotations= new ArrayList<Annotation>();
+
+
+ /**
+ * Constructs a overview ruler of the given width using the given annotation access and the given
+ * color manager.
+ *
+ * @param annotationAccess the annotation access
+ * @param width the width of the vertical ruler
+ * @param sharedColors the color manager
+ */
+ public STOverviewRuler(IAnnotationAccess annotationAccess, int width, ISharedTextColors sharedColors) {
+ fAnnotationAccess= annotationAccess;
+ fWidth= width;
+ fSharedTextColors= sharedColors;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getControl()
+ */
+ public Control getControl() {
+ return fCanvas;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getWidth()
+ */
+ public int getWidth() {
+ return fWidth;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRuler#setModel(org.eclipse.jface.text.source.IAnnotationModel)
+ */
+ public void setModel(IAnnotationModel model) {
+ if (model != fModel || model != null) {
+
+ if (fModel != null)
+ fModel.removeAnnotationModelListener(fInternalListener);
+
+ fModel= model;
+
+ if (fModel != null)
+ fModel.addAnnotationModelListener(fInternalListener);
+
+ update();
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRuler#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.ITextViewer)
+ */
+ public Control createControl(Composite parent, ITextViewer textViewer) {
+
+ fTextViewer= textViewer;
+
+ fHitDetectionCursor= new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
+
+ fHeader= new Canvas(parent, SWT.NONE);
+
+ fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
+
+ fCanvas.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent event) {
+ if (fTextViewer != null)
+ doubleBufferPaint(event.gc);
+ }
+ });
+
+ fCanvas.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ handleDispose();
+ fTextViewer= null;
+ }
+ });
+
+ fCanvas.addMouseListener(new MouseAdapter() {
+ public void mouseDown(MouseEvent event) {
+ handleMouseDown(event);
+ }
+ });
+
+ fCanvas.addMouseMoveListener(new MouseMoveListener() {
+ public void mouseMove(MouseEvent event) {
+ handleMouseMove(event);
+ }
+ });
+
+ if (fTextViewer != null)
+ fTextViewer.addTextListener(fInternalListener);
+
+ return fCanvas;
+ }
+
+ /**
+ * Disposes the ruler's resources.
+ */
+ private void handleDispose() {
+
+ if (fTextViewer != null) {
+ fTextViewer.removeTextListener(fInternalListener);
+ fTextViewer= null;
+ }
+
+ if (fModel != null)
+ fModel.removeAnnotationModelListener(fInternalListener);
+
+ if (fBuffer != null) {
+ fBuffer.dispose();
+ fBuffer= null;
+ }
+
+ if (fHitDetectionCursor != null) {
+ fHitDetectionCursor.dispose();
+ fHitDetectionCursor= null;
+ }
+
+ fConfiguredAnnotationTypes.clear();
+ fAllowedAnnotationTypes.clear();
+ fConfiguredHeaderAnnotationTypes.clear();
+ fAllowedHeaderAnnotationTypes.clear();
+ fAnnotationTypes2Colors.clear();
+ fAnnotationsSortedByLayer.clear();
+ fLayersSortedByLayer.clear();
+ }
+
+ /**
+ * Double buffer drawing.
+ *
+ * @param dest the GC to draw into
+ */
+ private void doubleBufferPaint(GC dest) {
+
+ Point size= fCanvas.getSize();
+
+ if (size.x <= 0 || size.y <= 0)
+ return;
+
+ if (fBuffer != null) {
+ Rectangle r= fBuffer.getBounds();
+ if (r.width != size.x || r.height != size.y) {
+ fBuffer.dispose();
+ fBuffer= null;
+ }
+ }
+ if (fBuffer == null)
+ fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
+
+ GC gc= new GC(fBuffer);
+ try {
+ gc.setBackground(fCanvas.getBackground());
+ gc.fillRectangle(0, 0, size.x, size.y);
+
+ if (fTextViewer instanceof ITextViewerExtension5)
+ doPaint1(gc);
+ else
+ doPaint(gc);
+
+ } finally {
+ gc.dispose();
+ }
+
+ dest.drawImage(fBuffer, 0, 0);
+ }
+
+ /**
+ * Draws this overview ruler.
+ *
+ * @param gc the GC to draw into
+ */
+ private void doPaint(GC gc) {
+ Rectangle r= new Rectangle(0, 0, 0, 0);
+ int yy, hh= ANNOTATION_HEIGHT;
+
+ IDocument document= fTextViewer.getDocument();
+ IRegion visible= fTextViewer.getVisibleRegion();
+
+ StyledText textWidget= fTextViewer.getTextWidget();
+ int maxLines= textWidget.getLineCount();
+
+ Point size= fCanvas.getSize();
+ int writable= JFaceTextUtil.computeLineHeight(textWidget, 0, maxLines, maxLines);
+
+ if (size.y > writable)
+ size.y= Math.max(writable - fHeader.getSize().y, 0);
+
+ for (Iterator<Object> iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
+ Object annotationType= iterator.next();
+
+ if (skip(annotationType))
+ continue;
+
+ int[] style= new int[] { FilterIterator.PERSISTENT, FilterIterator.TEMPORARY };
+ for (int t=0; t < style.length; t++) {
+ Color fill = null;
+ Color stroke = null;
+ FilterIterator e = new FilterIterator(annotationType, style[t]);
+ if (annotationType.toString().compareTo(getAnnotationTypeColoredLines()) != 0){
+ fill= getFillColor(annotationType, style[t] == FilterIterator.TEMPORARY);
+ stroke= getStrokeColor(annotationType, style[t] == FilterIterator.TEMPORARY);
+ }
+
+ for (int i= 0; e.hasNext(); i++) {
+
+ Annotation a= e.next();
+ Position p= fModel.getPosition(a);
+
+ if (p == null || !p.overlapsWith(visible.getOffset(), visible.getLength()))
+ continue;
+
+
+ if (a.getType().compareTo(getAnnotationTypeColoredLines()) == 0){
+ fill= getFPFillColor(a, true);
+ stroke= getFPStrokeColor(a, false);
+ }
+
+ int annotationOffset= Math.max(p.getOffset(), visible.getOffset());
+ int annotationEnd= Math.min(p.getOffset() + p.getLength(), visible.getOffset() + visible.getLength());
+ int annotationLength= annotationEnd - annotationOffset;
+
+ try {
+ if (ANNOTATION_HEIGHT_SCALABLE) {
+ int numbersOfLines= document.getNumberOfLines(annotationOffset, annotationLength);
+ // don't count empty trailing lines
+ IRegion lastLine= document.getLineInformationOfOffset(annotationOffset + annotationLength);
+ if (lastLine.getOffset() == annotationOffset + annotationLength) {
+ numbersOfLines -= 2;
+ hh= (numbersOfLines * size.y) / maxLines + ANNOTATION_HEIGHT;
+ if (hh < ANNOTATION_HEIGHT)
+ hh= ANNOTATION_HEIGHT;
+ } else
+ hh= ANNOTATION_HEIGHT;
+ }
+ fAnnotationHeight= hh;
+
+ int startLine= textWidget.getLineAtOffset(annotationOffset - visible.getOffset());
+ yy= Math.min((startLine * size.y) / maxLines, size.y - hh);
+
+ if (fill != null) {
+ gc.setBackground(fill);
+ gc.fillRectangle(INSET, yy, size.x-(2*INSET), hh);
+ }
+
+ if (stroke != null) {
+ gc.setForeground(stroke);
+ r.x= INSET;
+ r.y= yy;
+ r.width= size.x - (2 * INSET);
+ r.height= hh;
+ gc.setLineWidth(1);
+ gc.drawRectangle(r);
+ }
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Draws this overview ruler. Uses <code>ITextViewerExtension5</code> for
+ * its implementation. Will replace <code>doPaint(GC)</code>.
+ *
+ * @param gc the GC to draw into
+ */
+ private void doPaint1(GC gc) {
+ Rectangle r= new Rectangle(0, 0, 0, 0);
+ int yy, hh= ANNOTATION_HEIGHT;
+
+ ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
+ IDocument document= fTextViewer.getDocument();
+ StyledText textWidget= fTextViewer.getTextWidget();
+
+ int maxLines= textWidget.getLineCount();
+ Point size= fCanvas.getSize();
+ int writable= JFaceTextUtil.computeLineHeight(textWidget, 0, maxLines, maxLines);
+ if (size.y > writable)
+ size.y= Math.max(writable - fHeader.getSize().y, 0);
+
+ fCachedAnnotations.clear();
+ if (fModel != null) {
+ Iterator<?> iter= fModel.getAnnotationIterator();
+ while (iter.hasNext()) {
+ Annotation annotation= (Annotation) iter.next();
+
+ if (annotation.isMarkedDeleted())
+ continue;
+
+ if (skip(annotation.getType()))
+ continue;
+
+ fCachedAnnotations.add(annotation);
+ }
+ }
+
+ for (Iterator<Object> iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
+ Object annotationType= iterator.next();
+
+ if (skip(annotationType))
+ continue;
+
+ int[] style= new int[] { FilterIterator.PERSISTENT, FilterIterator.TEMPORARY };
+ for (int t=0; t < style.length; t++) {
+
+ FilterIterator e= new FilterIterator(annotationType, style[t], fCachedAnnotations.iterator());
+ Color fill = null;
+ Color stroke = null;
+ if (annotationType.toString().compareTo(getAnnotationTypeColoredLines()) != 0){
+ fill= getFillColor(annotationType, style[t] == FilterIterator.TEMPORARY);
+ stroke= getStrokeColor(annotationType, style[t] == FilterIterator.TEMPORARY);
+ }
+
+ for (int i= 0; e.hasNext(); i++) {
+
+ Annotation a= e.next();
+
+
+ Position p= fModel.getPosition(a);
+
+ if (p == null)
+ continue;
+
+ IRegion widgetRegion= extension.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength()));
+ if (widgetRegion == null)
+ continue;
+
+ if (a.getType().compareTo(getAnnotationTypeColoredLines()) == 0){
+ fill= getFPFillColor(a, true);
+ stroke= getFPStrokeColor(a, false);
+ }
+
+ try {
+ if (ANNOTATION_HEIGHT_SCALABLE) {
+ int numbersOfLines= document.getNumberOfLines(p.getOffset(), p.getLength());
+ // don't count empty trailing lines
+ IRegion lastLine= document.getLineInformationOfOffset(p.getOffset() + p.getLength());
+ if (lastLine.getOffset() == p.getOffset() + p.getLength()) {
+ numbersOfLines -= 2;
+ hh= (numbersOfLines * size.y) / maxLines + ANNOTATION_HEIGHT;
+ if (hh < ANNOTATION_HEIGHT)
+ hh= ANNOTATION_HEIGHT;
+ } else
+ hh= ANNOTATION_HEIGHT;
+ }
+ fAnnotationHeight= hh;
+
+ int startLine= textWidget.getLineAtOffset(widgetRegion.getOffset());
+ yy= Math.min((startLine * size.y) / maxLines, size.y - hh);
+
+ if (fill != null) {
+ gc.setBackground(fill);
+ gc.fillRectangle(INSET, yy, size.x-(2*INSET), hh);
+ }
+
+ if (stroke != null) {
+ gc.setForeground(stroke);
+ r.x= INSET;
+ r.y= yy;
+ r.width= size.x - (2 * INSET);
+ r.height= hh;
+ gc.setLineWidth(1);
+ gc.drawRectangle(r);
+ }
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+ }
+ fCachedAnnotations.clear();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRuler#update()
+ */
+ public void update() {
+ if (fCanvas != null && !fCanvas.isDisposed()) {
+ Display d= fCanvas.getDisplay();
+ if (d != null) {
+ d.asyncExec(new Runnable() {
+ public void run() {
+ redraw();
+ updateHeader();
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Redraws the overview ruler.
+ */
+ private void redraw() {
+
+ if (fTextViewer == null || fModel == null)
+ return;
+
+ if (fCanvas != null && !fCanvas.isDisposed()) {
+ GC gc= new GC(fCanvas);
+ doubleBufferPaint(gc);
+ gc.dispose();
+ }
+ }
+
+ /**
+ * Translates a given y-coordinate of this ruler into the corresponding
+ * document lines. The number of lines depends on the concrete scaling
+ * given as the ration between the height of this ruler and the length
+ * of the document.
+ *
+ * @param y_coordinate the y-coordinate
+ * @return the corresponding document lines
+ */
+ private int[] toLineNumbers(int y_coordinate) {
+
+ StyledText textWidget= fTextViewer.getTextWidget();
+ int maxLines= textWidget.getContent().getLineCount();
+
+ int rulerLength= fCanvas.getSize().y;
+ int writable= JFaceTextUtil.computeLineHeight(textWidget, 0, maxLines, maxLines);
+
+ if (rulerLength > writable)
+ rulerLength= Math.max(writable - fHeader.getSize().y, 0);
+
+ if (y_coordinate >= writable || y_coordinate >= rulerLength)
+ return new int[] {-1, -1};
+
+ int[] lines= new int[2];
+
+ int pixel0= Math.max(y_coordinate - 1, 0);
+ int pixel1= Math.min(rulerLength, y_coordinate + 1);
+ rulerLength= Math.max(rulerLength, 1);
+
+ lines[0]= (pixel0 * maxLines) / rulerLength;
+ lines[1]= (pixel1 * maxLines) / rulerLength;
+
+ if (fTextViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension= (ITextViewerExtension5) fTextViewer;
+ lines[0]= extension.widgetLine2ModelLine(lines[0]);
+ lines[1]= extension.widgetLine2ModelLine(lines[1]);
+ } else {
+ try {
+ IRegion visible= fTextViewer.getVisibleRegion();
+ int lineNumber= fTextViewer.getDocument().getLineOfOffset(visible.getOffset());
+ lines[0] += lineNumber;
+ lines[1] += lineNumber;
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return lines;
+ }
+
+ /**
+ * Returns the position of the first annotation found in the given line range.
+ *
+ * @param lineNumbers the line range
+ * @param ignoreSelectedAnnotation whether to ignore the current selection
+ * @return the position of the first found annotation
+ */
+ private Position getAnnotationPosition(int[] lineNumbers, boolean ignoreSelectedAnnotation) {
+ if (lineNumbers[0] == -1)
+ return null;
+
+ Position found= null;
+
+ try {
+ IDocument d= fTextViewer.getDocument();
+ IRegion line= d.getLineInformation(lineNumbers[0]);
+
+ Point currentSelection= fTextViewer.getSelectedRange();
+
+ int start= line.getOffset();
+
+ line= d.getLineInformation(lineNumbers[lineNumbers.length - 1]);
+ int end= line.getOffset() + line.getLength();
+
+ for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
+
+ Object annotationType= fAnnotationsSortedByLayer.get(i);
+
+ FilterIterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY);
+ while (e.hasNext() && found == null) {
+ Annotation a= e.next();
+ if (a.isMarkedDeleted())
+ continue;
+
+ if (skip(a.getType()))
+ continue;
+
+ Position p= fModel.getPosition(a);
+ if (p == null)
+ continue;
+
+ int posOffset= p.getOffset();
+ int posEnd= posOffset + p.getLength();
+ IRegion region= d.getLineInformationOfOffset(posEnd);
+ // trailing empty lines don't count
+ if (posEnd > posOffset && region.getOffset() == posEnd) {
+ posEnd--;
+ region= d.getLineInformationOfOffset(posEnd);
+ }
+
+ if (posOffset <= end && posEnd >= start) {
+ if (ignoreSelectedAnnotation || currentSelection.x != posOffset || currentSelection.y != p.getLength())
+ found= p;
+ }
+ }
+ }
+ } catch (BadLocationException x) {
+ }
+
+ return found;
+ }
+
+ /**
+ * Returns the line which corresponds best to one of
+ * the underlying annotations at the given y-coordinate.
+ *
+ * @param lineNumbers the line numbers
+ * @return the best matching line or <code>-1</code> if no such line can be found
+ */
+ private int findBestMatchingLineNumber(int[] lineNumbers) {
+ if (lineNumbers == null || lineNumbers.length < 1)
+ return -1;
+
+ try {
+ Position pos= getAnnotationPosition(lineNumbers, true);
+ if (pos == null)
+ return -1;
+ return fTextViewer.getDocument().getLineOfOffset(pos.getOffset());
+ } catch (BadLocationException ex) {
+ return -1;
+ }
+ }
+
+ /**
+ * Handles mouse clicks.
+ *
+ * @param event the mouse button down event
+ */
+ private void handleMouseDown(MouseEvent event) {
+ if (fTextViewer != null) {
+ int[] lines= toLineNumbers(event.y);
+ Position p= getAnnotationPosition(lines, false);
+ if (p != null) {
+ fTextViewer.revealRange(p.getOffset(), p.getLength());
+ fTextViewer.setSelectedRange(p.getOffset(), p.getLength());
+ }
+ fTextViewer.getTextWidget().setFocus();
+ }
+ fLastMouseButtonActivityLine= toDocumentLineNumber(event.y);
+ }
+
+ /**
+ * Handles mouse moves.
+ *
+ * @param event the mouse move event
+ */
+ private void handleMouseMove(MouseEvent event) {
+ if (fTextViewer != null) {
+ int[] lines= toLineNumbers(event.y);
+ Position p= getAnnotationPosition(lines, true);
+ Cursor cursor= (p != null ? fHitDetectionCursor : null);
+ if (cursor != fLastCursor) {
+ fCanvas.setCursor(cursor);
+ fLastCursor= cursor;
+ }
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#addAnnotationType(java.lang.Object)
+ */
+ public void addAnnotationType(Object annotationType) {
+ fConfiguredAnnotationTypes.add(annotationType);
+ fAllowedAnnotationTypes.clear();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#removeAnnotationType(java.lang.Object)
+ */
+ public void removeAnnotationType(Object annotationType) {
+ fConfiguredAnnotationTypes.remove(annotationType);
+ fAllowedAnnotationTypes.clear();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#setAnnotationTypeLayer(java.lang.Object, int)
+ */
+ public void setAnnotationTypeLayer(Object annotationType, int layer) {
+ int j= fAnnotationsSortedByLayer.indexOf(annotationType);
+ if (j != -1) {
+ fAnnotationsSortedByLayer.remove(j);
+ fLayersSortedByLayer.remove(j);
+ }
+
+ if (layer >= 0) {
+ int i= 0;
+ int size= fLayersSortedByLayer.size();
+ while (i < size && layer >= fLayersSortedByLayer.get(i))
+ i++;
+ fLayersSortedByLayer.add(i, layer);
+ fAnnotationsSortedByLayer.add(i, annotationType);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#setAnnotationTypeColor(java.lang.Object, org.eclipse.swt.graphics.Color)
+ */
+
+ public void setAnnotationColor(Annotation annotation,Color color){
+ if (color != null)
+ fAnnotationColors.put(annotation, color);
+ else
+ fAnnotationColors.remove(annotation);
+ }
+
+
+ public void setAnnotationTypeColor(Object annotationType, Color color) {
+ if (color != null)
+ fAnnotationTypes2Colors.put(annotationType, color);
+ else
+ fAnnotationTypes2Colors.remove(annotationType);
+ }
+
+ /**
+ * Returns whether the given annotation type should be skipped by the drawing routine.
+ *
+ * @param annotationType the annotation type
+ * @return <code>true</code> if annotation of the given type should be skipped
+ */
+ private boolean skip(Object annotationType) {
+ return !contains(annotationType, fAllowedAnnotationTypes, fConfiguredAnnotationTypes);
+ }
+
+ /**
+ * Returns whether the given annotation type should be skipped by the drawing routine of the header.
+ *
+ * @param annotationType the annotation type
+ * @return <code>true</code> if annotation of the given type should be skipped
+ * @since 3.0
+ */
+ private boolean skipInHeader(Object annotationType) {
+ return !contains(annotationType, fAllowedHeaderAnnotationTypes, fConfiguredHeaderAnnotationTypes);
+ }
+
+ /**
+ * Returns whether the given annotation type is mapped to <code>true</code>
+ * in the given <code>allowed</code> map or covered by the <code>configured</code>
+ * set.
+ *
+ * @param annotationType the annotation type
+ * @param allowed the map with allowed annotation types mapped to booleans
+ * @param configured the set with configured annotation types
+ * @return <code>true</code> if annotation is contained, <code>false</code>
+ * otherwise
+ * @since 3.0
+ */
+ private boolean contains(Object annotationType, Map allowed, Set configured) {
+ Boolean cached= (Boolean) allowed.get(annotationType);
+ if (cached != null)
+ return cached.booleanValue();
+
+ boolean covered= isCovered(annotationType, configured);
+ allowed.put(annotationType, covered ? Boolean.TRUE : Boolean.FALSE);
+ return covered;
+ }
+
+ /**
+ * Computes whether the annotations of the given type are covered by the given <code>configured</code>
+ * set. This is the case if either the type of the annotation or any of its
+ * super types is contained in the <code>configured</code> set.
+ *
+ * @param annotationType the annotation type
+ * @param configured the set with configured annotation types
+ * @return <code>true</code> if annotation is covered, <code>false</code>
+ * otherwise
+ * @since 3.0
+ */
+ private boolean isCovered(Object annotationType, Set configured) {
+ if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
+ IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
+ Iterator<?> e= configured.iterator();
+ while (e.hasNext()) {
+ if (extension.isSubtype(annotationType,e.next()))
+ return true;
+ }
+ return false;
+ }
+ return configured.contains(annotationType);
+ }
+
+ /**
+ * Returns a specification of a color that lies between the given
+ * foreground and background color using the given scale factor.
+ *
+ * @param fg the foreground color
+ * @param bg the background color
+ * @param scale the scale factor
+ * @return the interpolated color
+ */
+ private static RGB interpolate(RGB fg, RGB bg, double scale) {
+ return new RGB(
+ (int) ((1.0-scale) * fg.red + scale * bg.red),
+ (int) ((1.0-scale) * fg.green + scale * bg.green),
+ (int) ((1.0-scale) * fg.blue + scale * bg.blue)
+ );
+ }
+
+ /**
+ * Returns the grey value in which the given color would be drawn in grey-scale.
+ *
+ * @param rgb the color
+ * @return the grey-scale value
+ */
+ private static double greyLevel(RGB rgb) {
+ if (rgb.red == rgb.green && rgb.green == rgb.blue)
+ return rgb.red;
+ return (0.299 * rgb.red + 0.587 * rgb.green + 0.114 * rgb.blue + 0.5);
+ }
+
+ /**
+ * Returns whether the given color is dark or light depending on the colors grey-scale level.
+ *
+ * @param rgb the color
+ * @return <code>true</code> if the color is dark, <code>false</code> if it is light
+ */
+ private static boolean isDark(RGB rgb) {
+ return greyLevel(rgb) > 128;
+ }
+
+ /**
+ * Returns a color based on the color configured for the given annotation type and the given scale factor.
+ *
+ * @param annotationType the annotation type
+ * @param scale the scale factor
+ * @return the computed color
+ */
+ private Color getColor(Object annotationType, double scale) {
+ Color base= findColor(annotationType);
+ return getInterpolatedColor(base,scale);
+ }
+
+
+ private Color getFPColor(Object annotation, double scale){
+ Color base= (Color) fAnnotationColors.get(annotation);
+ return getInterpolatedColor(base,scale);
+ }
+
+ private Color getInterpolatedColor(Color base,double scale){
+ if (base == null)
+ return null;
+
+ RGB baseRGB= base.getRGB();
+ RGB background= fCanvas.getBackground().getRGB();
+
+ boolean darkBase= isDark(baseRGB);
+ boolean darkBackground= isDark(background);
+ if (darkBase && darkBackground)
+ background= new RGB(255, 255, 255);
+ else if (!darkBase && !darkBackground)
+ background= new RGB(0, 0, 0);
+
+ return fSharedTextColors.getColor(interpolate(baseRGB, background, scale));
+
+ }
+
+
+ /**
+ * Returns the color for the given annotation type
+ *
+ * @param annotationType the annotation type
+ * @return the color
+ * @since 3.0
+ */
+ private Color findColor(Object annotationType) {
+ Color color= (Color) fAnnotationTypes2Colors.get(annotationType);
+ if (color != null)
+ return color;
+
+ if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
+ IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
+ Object[] superTypes= extension.getSupertypes(annotationType);
+ if (superTypes != null) {
+ for (int i= 0; i < superTypes.length; i++) {
+ color= (Color) fAnnotationTypes2Colors.get(superTypes[i]);
+ if (color != null)
+ return color;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the stroke color for the given annotation type and characteristics.
+ *
+ * @param annotationType the annotation type
+ * @param temporary <code>true</code> if for temporary annotations
+ * @return the stroke color
+ */
+ private Color getStrokeColor(Object annotationType, boolean temporary) {
+ return getColor(annotationType, temporary ? 0.5 : 0.2);
+ }
+
+
+ private Color getFPStrokeColor(Object annotation, boolean temporary) {
+ return getFPColor(annotation, temporary ? 0.5 : 0.2);
+ }
+
+ /**
+ * Returns the fill color for the given annotation type and characteristics.
+ *
+ * @param annotationType the annotation type
+ * @param temporary <code>true</code> if for temporary annotations
+ * @return the fill color
+ */
+ private Color getFillColor(Object annotationType, boolean temporary) {
+ return getColor(annotationType, temporary ? 0.9 : 0.6);
+ }
+
+ private Color getFPFillColor(Object annotation, boolean temporary){
+ return getFPColor(annotation, temporary ? 0.9 : 0.6);
+ }
+
+ /*
+ * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
+ */
+ public int getLineOfLastMouseButtonActivity() {
+ return fLastMouseButtonActivityLine;
+ }
+
+ /*
+ * @see IVerticalRulerInfo#toDocumentLineNumber(int)
+ */
+ public int toDocumentLineNumber(int y_coordinate) {
+
+ if (fTextViewer == null || y_coordinate == -1)
+ return -1;
+
+ int[] lineNumbers= toLineNumbers(y_coordinate);
+ int bestLine= findBestMatchingLineNumber(lineNumbers);
+ if (bestLine == -1 && lineNumbers.length > 0)
+ return lineNumbers[0];
+ return bestLine;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IVerticalRuler#getModel()
+ */
+ public IAnnotationModel getModel() {
+ return fModel;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#getAnnotationHeight()
+ */
+ public int getAnnotationHeight() {
+ return fAnnotationHeight;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#hasAnnotation(int)
+ */
+ public boolean hasAnnotation(int y) {
+ return findBestMatchingLineNumber(toLineNumbers(y)) != -1;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#getHeaderControl()
+ */
+ public Control getHeaderControl() {
+ return fHeader;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#addHeaderAnnotationType(java.lang.Object)
+ */
+ public void addHeaderAnnotationType(Object annotationType) {
+ fConfiguredHeaderAnnotationTypes.add(annotationType);
+ fAllowedHeaderAnnotationTypes.clear();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IOverviewRuler#removeHeaderAnnotationType(java.lang.Object)
+ */
+ public void removeHeaderAnnotationType(Object annotationType) {
+ fConfiguredHeaderAnnotationTypes.remove(annotationType);
+ fAllowedHeaderAnnotationTypes.clear();
+ }
+
+ /**
+ * Updates the header of this ruler.
+ */
+ private void updateHeader() {
+
+ if (fHeader == null || fHeader.isDisposed())
+ return;
+
+ Object colorType= null;
+ outer: for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
+
+ Object annotationType= fAnnotationsSortedByLayer.get(i);
+
+ if (skipInHeader(annotationType) || skip(annotationType))
+ continue;
+
+ for (FilterIterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS); e.hasNext();) {
+ if (e.next() != null) {
+ colorType= annotationType;
+ break outer;
+ }
+ }
+ }
+
+ Color color= null;
+ if (colorType != null)
+ color= findColor(colorType);
+
+ if (color == null) {
+ if (fHeaderPainter != null)
+ fHeaderPainter.setColor(null);
+ } else {
+ if (fHeaderPainter == null) {
+ fHeaderPainter= new HeaderPainter();
+ fHeader.addPaintListener(fHeaderPainter);
+ }
+ fHeaderPainter.setColor(color);
+ }
+
+ fHeader.redraw();
+ updateHeaderToolTipText();
+ }
+
+ /**
+ * Updates the tool tip text of the header of this ruler.
+ *
+ * @since 3.0
+ */
+ private void updateHeaderToolTipText() {
+
+ if (fHeader == null || fHeader.isDisposed())
+ return;
+
+ fHeader.setToolTipText(null);
+
+ if (!(fAnnotationAccess instanceof IAnnotationAccessExtension))
+ return;
+
+ String overview= ""; //$NON-NLS-1$
+
+ for (int i= fAnnotationsSortedByLayer.size() -1; i >= 0; i--) {
+
+ Object annotationType= fAnnotationsSortedByLayer.get(i);
+
+ if (skipInHeader(annotationType) || skip(annotationType))
+ continue;
+
+ int count= 0;
+ String annotationTypeLabel= null;
+
+ for (FilterIterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS); e.hasNext();) {
+ Annotation annotation= e.next();
+ if (annotation != null) {
+ if (annotationTypeLabel == null)
+ annotationTypeLabel= ((IAnnotationAccessExtension)fAnnotationAccess).getTypeLabel(annotation);
+ count++;
+ }
+ }
+
+ if (annotationTypeLabel != null) {
+ if (overview.length() > 0)
+ overview += "\n"; //$NON-NLS-1$
+ overview += STJFaceTextMessages.getFormattedString("OverviewRulerHeader.toolTipTextEntry", new Object[] {annotationTypeLabel, new Integer(count)}); //$NON-NLS-1$
+ }
+ }
+ if (overview.length() > 0)
+ fHeader.setToolTipText(overview);
+ }
+
+ private String getAnnotationTypeColoredLines(){
+ return (STAnnotatedSourceEditorActivator.getUniqueIdentifier() + STAnnotatedSourceEditorActivator.getAnnotationType());
+ }
+}
+
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerColumn.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerColumn.java
new file mode 100644
index 0000000..8af7be3
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerColumn.java
@@ -0,0 +1,876 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.IViewportListener;
+import org.eclipse.jface.text.JFaceTextUtil;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ILineRange;
+import org.eclipse.jface.text.source.IVerticalRulerColumn;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.hyperlink.ISTAnnotationHyperlink;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.TextLayout;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+
+public class STRulerColumn implements IVerticalRulerColumn{
+ /**
+ * Internal listener class.
+ */
+ class InternalListener implements IViewportListener, ITextListener {
+
+ /**
+ * @since 3.1
+ */
+ private boolean fCachedRedrawState= true;
+
+ /*
+ * @see IViewportListener#viewportChanged(int)
+ */
+ public void viewportChanged(int verticalPosition) {
+ if (fCachedRedrawState && verticalPosition != fScrollPos)
+ redraw();
+ }
+
+ /*
+ * @see ITextListener#textChanged(TextEvent)
+ */
+ public void textChanged(TextEvent event) {
+
+ fCachedRedrawState= event.getViewerRedrawState();
+ if (!fCachedRedrawState)
+ return;
+
+ if (updateNumberOfDigits()) {
+ computeIndentations();
+ layout(event.getViewerRedrawState());
+ return;
+ }
+
+ boolean viewerCompletelyShown= isViewerCompletelyShown();
+ if (viewerCompletelyShown || fSensitiveToTextChanges || event.getDocumentEvent() == null)
+ postRedraw();
+ fSensitiveToTextChanges= viewerCompletelyShown;
+ }
+ }
+
+ /**
+ * Handles all the mouse interaction in this line number ruler column.
+ */
+ class MouseHandler implements MouseListener, MouseMoveListener {
+
+ /** The cached view port size */
+ private int fCachedViewportSize;
+ /** The area of the line at which line selection started */
+ private IRegion fStartLine;
+ /** The number of the line at which line selection started */
+ private int fStartLineNumber;
+ /** The auto scroll direction */
+ private int fAutoScrollDirection;
+ /* @since 3.2 */
+ private boolean fIsListeningForMove= false;
+
+ /*
+ * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseUp(MouseEvent event) {
+ // see bug 45700
+ if (event.button == 1) {
+ stopSelecting();
+ stopAutoScroll();
+ }
+ }
+
+ /*
+ * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDown(MouseEvent event) {
+ fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
+
+ int newLine= fParentRuler.toDocumentLineNumber(event.y) + 1;
+ if (annotationColumn instanceof ISTAnnotationHyperlink){
+ ISTAnnotationHyperlink ahp = (ISTAnnotationHyperlink)annotationColumn;
+ if (ahp.isAnnotationHyperlink(newLine) && annotationColumn.getAnnotation(newLine).trim() != ""){
+ ahp.handleHyperlink(newLine);
+ }
+
+ }
+ else{
+ // see bug 45700
+ if (event.button == 1) {
+ startSelecting();
+ }
+ }
+ }
+
+ /*
+ * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDoubleClick(MouseEvent event) {
+ fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
+ stopSelecting();
+ stopAutoScroll();
+ }
+
+ /*
+ * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseMove(MouseEvent event) {
+ int newLine= fParentRuler.toDocumentLineNumber(event.y) + 1;
+ if (annotationColumn instanceof ISTAnnotationHyperlink){
+ if (((ISTAnnotationHyperlink)annotationColumn).isAnnotationHyperlink(newLine) && annotationColumn.getAnnotation(newLine).trim() != ""){
+ Cursor cursor = new Cursor(event.display,SWT.CURSOR_HAND);
+ fCanvas.setCursor(cursor);
+ }
+ else{
+ Cursor cursor = new Cursor(event.display,SWT.CURSOR_ARROW);
+ fCanvas.setCursor(cursor);
+ }
+ }
+ if (fIsListeningForMove && !autoScroll(event)) {
+ expandSelection(newLine);
+ }
+ fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
+ }
+
+ /**
+ * Called when line drag selection started. Adds mouse move and track
+ * listeners to this column's control.
+ */
+ private void startSelecting() {
+ try {
+
+ // select line
+ IDocument document= fCachedTextViewer.getDocument();
+ fStartLineNumber= fParentRuler.getLineOfLastMouseButtonActivity();
+ fStartLine= document.getLineInformation(fStartLineNumber);
+ fCachedTextViewer.setSelectedRange(fStartLine.getOffset(), fStartLine.getLength());
+
+ // prepare for drag selection
+ fIsListeningForMove= true;
+
+ } catch (BadLocationException x) {
+ }
+ }
+
+ /**
+ * Called when line drag selection stopped. Removes all previously
+ * installed listeners from this column's control.
+ */
+ private void stopSelecting() {
+ // drag selection stopped
+ fIsListeningForMove= false;
+ }
+
+ /**
+ * Expands the line selection from the remembered start line to the
+ * given line.
+ *
+ * @param lineNumber the line to which to expand the selection
+ */
+ private void expandSelection(int lineNumber) {
+ try {
+
+ IDocument document= fCachedTextViewer.getDocument();
+ IRegion lineInfo= document.getLineInformation(lineNumber);
+
+ int start= Math.min(fStartLine.getOffset(), lineInfo.getOffset());
+ int end= Math.max(fStartLine.getOffset() + fStartLine.getLength(), lineInfo.getOffset() + lineInfo.getLength());
+
+ if (lineNumber < fStartLineNumber)
+ fCachedTextViewer.setSelectedRange(end, start - end);
+ else
+ fCachedTextViewer.setSelectedRange(start, end - start);
+
+ } catch (BadLocationException x) {
+ }
+ }
+
+ /**
+ * Called when auto scrolling stopped. Clears the auto scroll direction.
+ */
+ private void stopAutoScroll() {
+ fAutoScrollDirection= SWT.NULL;
+ }
+
+ /**
+ * Called on drag selection.
+ *
+ * @param event the mouse event caught by the mouse move listener
+ * @return <code>true</code> if scrolling happened, <code>false</code> otherwise
+ */
+ private boolean autoScroll(MouseEvent event) {
+ Rectangle area= fCanvas.getClientArea();
+
+ if (event.y > area.height) {
+ autoScroll(SWT.DOWN);
+ return true;
+ }
+
+ if (event.y < 0) {
+ autoScroll(SWT.UP);
+ return true;
+ }
+
+ stopAutoScroll();
+ return false;
+ }
+
+ /**
+ * Scrolls the viewer into the given direction.
+ *
+ * @param direction the scroll direction
+ */
+ private void autoScroll(int direction) {
+
+ if (fAutoScrollDirection == direction)
+ return;
+
+ final int TIMER_INTERVAL= 5;
+ final Display display = fCanvas.getDisplay();
+ Runnable timer= null;
+ switch (direction) {
+ case SWT.UP:
+ timer= new Runnable() {
+ public void run() {
+ if (fAutoScrollDirection == SWT.UP) {
+ int top= getInclusiveTopIndex();
+ if (top > 0) {
+ fCachedTextViewer.setTopIndex(top -1);
+ expandSelection(top -1);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ }
+ };
+ break;
+ case SWT.DOWN:
+ timer = new Runnable() {
+ public void run() {
+ if (fAutoScrollDirection == SWT.DOWN) {
+ int top= getInclusiveTopIndex();
+ fCachedTextViewer.setTopIndex(top +1);
+ expandSelection(top +1 + fCachedViewportSize);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ break;
+ }
+
+ if (timer != null) {
+ fAutoScrollDirection= direction;
+ display.timerExec(TIMER_INTERVAL, timer);
+ }
+ }
+
+ /**
+ * Returns the viewer's first visible line, even if only partially visible.
+ *
+ * @return the viewer's first visible line
+ */
+ private int getInclusiveTopIndex() {
+ if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed()) {
+ return JFaceTextUtil.getPartialTopIndex(fCachedTextViewer);
+ }
+ return -1;
+ }
+ }
+
+ /** This column's parent ruler */
+ private CompositeRuler fParentRuler;
+ /** Cached text viewer */
+ private ITextViewer fCachedTextViewer;
+ /** Cached text widget */
+ private StyledText fCachedTextWidget;
+ /** The columns canvas */
+ private Canvas fCanvas;
+ /** Cache for the actual scroll position in pixels */
+ private int fScrollPos;
+ /** The drawable for double buffering */
+ private Image fBuffer;
+ /** The internal listener */
+ private InternalListener fInternalListener= new InternalListener();
+ /** The font of this column */
+ private Font fFont;
+ /** The indentation cache */
+ private int[] fIndentation;
+ /** Indicates whether this column reacts on text change events */
+ private boolean fSensitiveToTextChanges= false;
+ /** The foreground color */
+ private Color fForeground;
+ /** The background color */
+ private Color fBackground;
+ /** Cached number of displayed digits */
+ private int fCachedNumberOfDigits= -1;
+ /** Flag indicating whether a relayout is required */
+ private boolean fRelayoutRequired= false;
+ /**
+ * Redraw runnable lock
+ * @since 3.0
+ */
+ private Object fRunnableLock= new Object();
+ /**
+ * Redraw runnable state
+ * @since 3.0
+ */
+ private boolean fIsRunnablePosted= false;
+ /**
+ * Redraw runnable
+ * @since 3.0
+ */
+ private Runnable fRunnable= new Runnable() {
+ public void run() {
+ synchronized (fRunnableLock) {
+ fIsRunnablePosted= false;
+ }
+ redraw();
+ }
+ };
+ /* @since 3.2 */
+ private MouseHandler fMouseHandler;
+
+ private ISTAnnotationColumn annotationColumn;
+
+ /**
+ * Constructs a new vertical ruler column.
+ */
+ public STRulerColumn(ISTAnnotationColumn ac) {
+ annotationColumn = ac;
+ }
+
+ public ISTAnnotationColumn getSTAnnotationColumn(){
+ return annotationColumn;
+ }
+
+ public STRulerColumn() {
+ }
+
+ /**
+ * Sets the foreground color of this column.
+ *
+ * @param foreground the foreground color
+ */
+ public void setForeground(Color foreground) {
+ fForeground= foreground;
+ }
+
+ /**
+ * Returns the foreground color being used to print the line numbers.
+ *
+ * @return the configured foreground color
+ * @since 3.0
+ */
+ protected Color getForeground() {
+ return fForeground;
+ }
+
+ /**
+ * Sets the background color of this column.
+ *
+ * @param background the background color
+ */
+ public void setBackground(Color background) {
+ fBackground= background;
+ if (fCanvas != null && !fCanvas.isDisposed())
+ fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
+ }
+
+ /**
+ * Returns the System background color for list widgets.
+ *
+ * @param display the display
+ * @return the System background color for list widgets
+ */
+ protected Color getBackground(Display display) {
+ if (fBackground == null)
+ return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ return fBackground;
+ }
+
+ /*
+ * @see IVerticalRulerColumn#getControl()
+ */
+ public Control getControl() {
+ return fCanvas;
+ }
+
+ /*
+ * @see IVerticalRuleColumnr#getWidth
+ */
+ public int getWidth() {
+ return fIndentation[0];
+ }
+
+ /**
+ * Computes the number of digits to be displayed. Returns
+ * <code>true</code> if the number of digits changed compared
+ * to the previous call of this method. If the method is called
+ * for the first time, the return value is also <code>true</code>.
+ *
+ * @return whether the number of digits has been changed
+ * @since 3.0
+ */
+ protected boolean updateNumberOfDigits() {
+ if (fCachedTextViewer == null)
+ return false;
+
+ int digits= computeNumberOfDigits();
+
+ if (fCachedNumberOfDigits != digits) {
+ fCachedNumberOfDigits= digits;
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Does the real computation of the number of digits. Subclasses may override this method if
+ * they need extra space on the line number ruler.
+ *
+ * @return the number of digits to be displayed on the line number ruler.
+ */
+ protected int computeNumberOfDigits() {
+ IDocument document= fCachedTextViewer.getDocument();
+ int lines= document == null ? 0 : document.getNumberOfLines();
+ int digits = 0;
+ if (annotationColumn.getTitle() != null && annotationColumn.getTitle().length() >0){
+ digits= annotationColumn.getTitle().length() + 3;
+ }
+ else
+ digits = 3;
+
+ while (lines > Math.pow(10, digits) -1) {
+ ++digits;
+ }
+ return (digits);
+ }
+
+ /**
+ * Layouts the enclosing viewer to adapt the layout to changes of the
+ * size of the individual components.
+ *
+ * @param redraw <code>true</code> if this column can be redrawn
+ */
+ protected void layout(boolean redraw) {
+ if (!redraw) {
+ fRelayoutRequired= true;
+ return;
+ }
+
+ fRelayoutRequired= false;
+ if (fCachedTextViewer instanceof ITextViewerExtension) {
+ ITextViewerExtension extension= (ITextViewerExtension) fCachedTextViewer;
+ Control control= extension.getControl();
+ if (control instanceof Composite && !control.isDisposed()) {
+ Composite composite= (Composite) control;
+ composite.layout(true);
+ }
+ }
+ }
+
+ /**
+ * Computes the indentations for the given font and stores them in
+ * <code>fIndentation</code>.
+ */
+ protected void computeIndentations() {
+ if (fCanvas == null || fCanvas.isDisposed())
+ return;
+
+ GC gc= new GC(fCanvas);
+ try {
+
+ gc.setFont(fCanvas.getFont());
+
+ fIndentation= new int[fCachedNumberOfDigits + 3];
+
+ char[] nines= new char[fCachedNumberOfDigits + 2];
+ Arrays.fill(nines, '9');
+ String nineString= new String(nines);
+ Point p= gc.stringExtent(nineString);
+ fIndentation[0]= p.x;
+
+ for (int i= 1; i <= fCachedNumberOfDigits; i++) {
+ p= gc.stringExtent(nineString.substring(0, i));
+ fIndentation[i]= fIndentation[0] - p.x;
+ }
+
+ } finally {
+ gc.dispose();
+ }
+ }
+
+ /*
+ * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite)
+ */
+ public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
+
+ fParentRuler= parentRuler;
+ fCachedTextViewer= parentRuler.getTextViewer();
+ fCachedTextWidget= fCachedTextViewer.getTextWidget();
+
+ fCanvas= new Canvas(parentControl, SWT.BORDER);
+ fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
+ fCanvas.setForeground(fForeground);
+
+ fCanvas.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent event) {
+ if (fCachedTextViewer != null)
+ doubleBufferPaint(event.gc);
+ }
+ });
+
+ fCanvas.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ handleDispose();
+ fCachedTextViewer= null;
+ fCachedTextWidget= null;
+ }
+ });
+
+ fMouseHandler= new MouseHandler();
+ fCanvas.addMouseListener(fMouseHandler);
+ fCanvas.addMouseMoveListener(fMouseHandler);
+
+ if (fCachedTextViewer != null) {
+
+ fCachedTextViewer.addViewportListener(fInternalListener);
+ fCachedTextViewer.addTextListener(fInternalListener);
+
+ if (fFont == null) {
+ if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed())
+ fFont= fCachedTextWidget.getFont();
+ }
+ }
+
+ if (fFont != null)
+ fCanvas.setFont(fFont);
+
+ updateNumberOfDigits();
+ computeIndentations();
+ return fCanvas;
+ }
+
+ /**
+ * Disposes the column's resources.
+ */
+ protected void handleDispose() {
+
+ if (fCachedTextViewer != null) {
+ fCachedTextViewer.removeViewportListener(fInternalListener);
+ fCachedTextViewer.removeTextListener(fInternalListener);
+ }
+
+ if (fBuffer != null) {
+ fBuffer.dispose();
+ fBuffer= null;
+ }
+ }
+
+ /**
+ * Double buffer drawing.
+ *
+ * @param dest the GC to draw into
+ */
+ private void doubleBufferPaint(GC dest) {
+
+ Point size= fCanvas.getSize();
+
+ if (size.x <= 0 || size.y <= 0)
+ return;
+
+ if (fBuffer != null) {
+ Rectangle r= fBuffer.getBounds();
+ if (r.width != size.x || r.height != size.y) {
+ fBuffer.dispose();
+ fBuffer= null;
+ }
+ }
+ if (fBuffer == null)
+ fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
+
+ GC gc= new GC(fBuffer);
+ gc.setFont(fCanvas.getFont());
+ if (fForeground != null)
+ gc.setForeground(fForeground);
+
+ try {
+ gc.setBackground(getBackground(fCanvas.getDisplay()));
+ gc.fillRectangle(0, 0, size.x, size.y);
+
+ ILineRange visibleLines= JFaceTextUtil.getVisibleModelLines(fCachedTextViewer);
+ if (visibleLines == null)
+ return;
+ fScrollPos= fCachedTextWidget.getTopPixel();
+ doPaint(gc, visibleLines);
+ fCachedTextWidget.addMouseTrackListener(new MouseTrackListener(){
+
+ @Override
+ public void mouseEnter(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseExit(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseHover(MouseEvent e) {
+
+
+ }
+
+ });
+
+ } finally {
+ gc.dispose();
+ }
+
+ dest.drawImage(fBuffer, 0, 0);
+ }
+
+ /**
+ * Returns <code>true</code> if the viewport displays the entire viewer contents, i.e. the
+ * viewer is not vertically scrollable.
+ *
+ * @return <code>true</code> if the viewport displays the entire contents, <code>false</code> otherwise
+ * @since 3.2
+ */
+ protected final boolean isViewerCompletelyShown() {
+ return JFaceTextUtil.isShowingEntireContents(fCachedTextWidget);
+ }
+
+ /**
+ * Draws the ruler column.
+ *
+ * @param gc the GC to draw into
+ * @param visibleLines the visible model lines
+ * @since 3.2
+ */
+ void doPaint(GC gc, ILineRange visibleLines) {
+ Display display= fCachedTextWidget.getDisplay();
+
+ // draw diff info
+ int y= -JFaceTextUtil.getHiddenTopLinePixels(fCachedTextWidget);
+
+ int lastLine= end(visibleLines);
+ for (int line= visibleLines.getStartLine(); line < lastLine; line++) {
+ int widgetLine= JFaceTextUtil.modelLineToWidgetLine(fCachedTextViewer, line);
+ if (widgetLine == -1)
+ continue;
+
+ int lineHeight= fCachedTextWidget.getLineHeight(fCachedTextWidget.getOffsetAtLine(widgetLine));
+ paintLine(line, y, lineHeight, gc, display);
+ y += lineHeight;
+ }
+ }
+
+ /* @since 3.2 */
+ private static int end(ILineRange range) {
+ return range.getStartLine() + range.getNumberOfLines();
+ }
+
+ /**
+ * Computes the string to be printed for <code>line</code>. The default implementation returns
+ * <code>Integer.toString(line + 1)</code>.
+ *
+ * @param line the line number for which the line number string is generated
+ * @return the string to be printed on the line number bar for <code>line</code>
+ * @since 3.0
+ */
+ protected String createDisplayString(int line) {
+ return Integer.toString(line);
+ }
+
+ /**
+ * Returns the difference between the baseline of the widget and the
+ * baseline as specified by the font for <code>gc</code>. When drawing
+ * line numbers, the returned bias should be added to obtain text lined up
+ * on the correct base line of the text widget.
+ *
+ * @param gc the <code>GC</code> to get the font metrics from
+ * @param widgetLine the widget line
+ * @return the baseline bias to use when drawing text that is lined up with
+ * <code>fCachedTextWidget</code>
+ * @since 3.2
+ */
+ private int getBaselineBias(GC gc, int widgetLine) {
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=62951
+ * widget line height may be more than the font height used for the
+ * line numbers, since font styles (bold, italics...) can have larger
+ * font metrics than the simple font used for the numbers.
+ */
+ int offset= fCachedTextWidget.getOffsetAtLine(widgetLine);
+ int widgetBaseline= fCachedTextWidget.getBaseline(offset);
+
+ FontMetrics fm = gc.getFontMetrics();
+ int fontBaseline = fm.getAscent() + fm.getLeading();
+ int baselineBias= widgetBaseline - fontBaseline;
+ return Math.max(0, baselineBias);
+ }
+
+ /**
+ * Paints the line. After this method is called the line numbers are painted on top
+ * of the result of this method.
+ *
+ * @param line the line of the document which the ruler is painted for
+ * @param y the y-coordinate of the box being painted for <code>line</code>, relative to <code>gc</code>
+ * @param lineheight the height of one line (and therefore of the box being painted)
+ * @param gc the drawing context the client may choose to draw on.
+ * @param display the display the drawing occurs on
+ * @since 3.0
+ */
+ protected void paintLine(int line, int y, int lineheight, GC gc, Display display) {
+ int widgetLine= JFaceTextUtil.modelLineToWidgetLine(fParentRuler.getTextViewer(), line);
+ String s = "";
+ int indentation= fCachedNumberOfDigits;
+
+ if (annotationColumn instanceof ISTAnnotationHyperlink){
+ ISTAnnotationHyperlink ah = (ISTAnnotationHyperlink)annotationColumn;
+ if (ah.isAnnotationHyperlink(widgetLine)){
+ paintHyperLink(line, y, indentation, lineheight, gc, display);
+
+ }
+ }
+ else{
+ s = annotationColumn.getAnnotation(widgetLine);
+
+ if (widgetLine + 1 == 1){
+ for(int i=0;i<annotationColumn.getTitle().length();i++)
+ s = s + " ";
+ }
+
+ int baselineBias= getBaselineBias(gc, widgetLine);
+ gc.drawString(s, indentation, y + baselineBias, true);
+ }
+ }
+
+ /**
+ * Triggers a redraw in the display thread.
+ *
+ * @since 3.0
+ */
+ protected final void postRedraw() {
+ if (fCanvas != null && !fCanvas.isDisposed()) {
+ Display d= fCanvas.getDisplay();
+ if (d != null) {
+ synchronized (fRunnableLock) {
+ if (fIsRunnablePosted)
+ return;
+ fIsRunnablePosted= true;
+ }
+ d.asyncExec(fRunnable);
+ }
+ }
+ }
+
+ /*
+ * @see IVerticalRulerColumn#redraw()
+ */
+ public void redraw() {
+
+ if (fRelayoutRequired) {
+ layout(true);
+ return;
+ }
+
+ if (fCachedTextViewer != null && fCanvas != null && !fCanvas.isDisposed()) {
+ GC gc= new GC(fCanvas);
+ doubleBufferPaint(gc);
+ gc.dispose();
+ }
+ }
+
+ /*
+ * @see IVerticalRulerColumn#setModel(IAnnotationModel)
+ */
+ public void setModel(IAnnotationModel model) {
+ }
+
+ /*
+ * @see IVerticalRulerColumn#setFont(Font)
+ */
+ public void setFont(Font font) {
+ fFont= font;
+ if (fCanvas != null && !fCanvas.isDisposed()) {
+ fCanvas.setFont(fFont);
+ updateNumberOfDigits();
+ computeIndentations();
+ }
+ }
+
+ /**
+ * Returns the parent (composite) ruler of this ruler column.
+ *
+ * @return the parent ruler
+ * @since 3.0
+ */
+ protected CompositeRuler getParentRuler() {
+ return fParentRuler;
+ }
+
+ protected void paintHyperLink(int line, int y, int x,int lineheight, GC gc, Display display) {
+ String str = annotationColumn.getAnnotation(line);
+ final TextStyle styledString = new TextStyle(gc.getFont(),null,null);
+ styledString.foreground = display.getSystemColor(SWT.COLOR_BLUE);
+ styledString.underline = true;
+ TextLayout tl = new TextLayout(display);
+ tl.setText(str);
+
+ tl.setStyle(styledString, 0, str.length());
+ y = y + lineheight/2 - gc.stringExtent(str).y/2;
+ tl.draw(gc, x, y);
+ if (line + 1 == 1){
+ int baselineBias= getBaselineBias(gc, line);
+ String s = "";
+ for(int i=0;i<annotationColumn.getTitle().length();i++)
+ s = s + " ";
+ gc.drawString(s, x + tl.getWidth() + 8, y + baselineBias, true);
+ }
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerMessages.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerMessages.java
new file mode 100644
index 0000000..8c94eb7
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STRulerMessages.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Helper class to get NLSed messages.
+ */
+final class STRulerMessages extends NLS {
+
+ private static final String BUNDLE_NAME= STRulerMessages.class.getName();
+
+ private STRulerMessages() {
+ // Do not instantiate
+ }
+
+ public static String AbstractDecoratedTextEditor_revision_quickdiff_switch_title;
+ public static String AbstractDecoratedTextEditor_revision_quickdiff_switch_message;
+ public static String AbstractDecoratedTextEditor_revision_quickdiff_switch_rememberquestion;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, STRulerMessages.class);
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STTextEditorMessages.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STTextEditorMessages.java
new file mode 100644
index 0000000..0cf4097
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/STTextEditorMessages.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.osgi.util.NLS;
+
+public class STTextEditorMessages extends NLS {
+ private static final String BUNDLE_FOR_CONSTRUCTED_KEYS= "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STConstructedTextEditorMessages"; //$NON-NLS-1$
+ private static ResourceBundle fgBundleForConstructedKeys= ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
+
+ /**
+ * Returns the message bundle which contains constructed keys.
+ *
+ * @since 3.1
+ * @return the message bundle
+ */
+ public static ResourceBundle getBundleForConstructedKeys() {
+ return fgBundleForConstructedKeys;
+ }
+
+ private static final String BUNDLE_NAME= STTextEditorMessages.class.getName();
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, STTextEditorMessages.class);
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/AbstractOpenSourceFileAction.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/AbstractOpenSourceFileAction.java
new file mode 100644
index 0000000..d6d923c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/AbstractOpenSourceFileAction.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.actions;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.AbstractSTAnnotatedSourceEditorInput;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedSourceEditorActivator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+
+public abstract class AbstractOpenSourceFileAction extends Action{
+ public static final String EDITOR_ID = "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.editor";
+ private long ts;
+
+ public AbstractOpenSourceFileAction(String filepath,long ts){
+ super.setText("Open =>" + filepath);
+ this.ts = ts;
+ }
+
+ @Override
+ public void run() {
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ IFileStore fileStore = getFileStore();
+
+ if (fileStore != null && !fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
+ long timeStamp = fileStore.fetchInfo().getLastModified();
+
+ if (timeStamp>ts) {
+ MessageBox msg = new MessageBox(window.getShell(),SWT.ICON_WARNING | SWT.APPLICATION_MODAL | SWT.YES| SWT.NO);
+ msg.setText(fileStore.toString());
+ msg.setMessage("The file "
+ + fileStore
+ + " is newer than the analysis result, \n"
+ + " if you continue opening it the visualization could result inconsistent. \n Do you want to continue?");
+ }
+
+ try {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ IFileStore fs = EFS.getStore(fileStore.toURI());
+ IEditorInput input = getInput(fs);
+ page.openEditor(input, EDITOR_ID, false);
+ }
+ } catch (Exception e) {
+ Status s = new Status(
+ IStatus.ERROR,
+ STAnnotatedSourceEditorActivator.getUniqueIdentifier(),
+ IStatus.ERROR,
+ "Error when opening annotated source view",
+ e);
+ STAnnotatedSourceEditorActivator.getDefault().getLog().log(s);
+ }
+ }
+ else{
+ if (!fileStore.fetchInfo().exists()) {
+ showMessage("The selected file does not exist: " + fileStore,window.getShell());
+ }
+ }
+
+ }
+
+ private void showMessage(String message,Shell shell) {
+ MessageBox msgBox = new MessageBox(shell,SWT.ICON_ERROR);
+ msgBox.setText("Error");
+ msgBox.setMessage(message);
+ msgBox.open();
+ }
+
+ public abstract AbstractSTAnnotatedSourceEditorInput getInput(IFileStore fs);
+
+ public abstract IFileStore getFileStore();
+}
+
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenFileFullPathAction.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenFileFullPathAction.java
new file mode 100644
index 0000000..85cb88f
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenFileFullPathAction.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.actions;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.AbstractSTAnnotatedSourceEditorInput;
+
+
+public abstract class OpenFileFullPathAction extends AbstractOpenSourceFileAction {
+ private String filepath;
+ public OpenFileFullPathAction(String filepath, long ts) {
+ super(filepath, ts);
+ this.filepath = filepath;
+ }
+
+ public abstract AbstractSTAnnotatedSourceEditorInput getInput(IFileStore fs);
+
+ public IFileStore getFileStore(){
+ return EFS.getLocalFileSystem().getStore(new Path(filepath));
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenWksRelFilePathAction.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenWksRelFilePathAction.java
new file mode 100644
index 0000000..a6dce5c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/actions/OpenWksRelFilePathAction.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.actions;
+
+import java.io.File;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+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.linuxtools.dataviewers.annotatedsourceeditor.AbstractSTAnnotatedSourceEditorInput;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedSourceEditorActivator;
+
+
+
+public abstract class OpenWksRelFilePathAction extends AbstractOpenSourceFileAction {
+ private String filepath;
+
+ public OpenWksRelFilePathAction(String filepath, long ts) {
+ super(filepath, ts);
+
+ this.filepath = filepath;
+ }
+
+ @Override
+ public abstract AbstractSTAnnotatedSourceEditorInput getInput(IFileStore fs);
+
+ public IFileStore getFileStore(){
+ File file = new File(filepath);
+ IFile f = null;
+ if (!file.isAbsolute())
+ {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace != null) {
+ IWorkspaceRoot wrkRoot = workspace.getRoot();
+ f = wrkRoot.getFile(new Path(filepath));
+ IPath p = f.getLocation();
+ if (p != null) file = p.toFile();
+ }
+ try {
+ IFileStore fs = EFS.getStore(file.toURI());
+ return fs;
+ } catch (CoreException e) {
+ STAnnotatedSourceEditorActivator.getDefault().getLog().log(e.getStatus());
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/hyperlink/ISTAnnotationHyperlink.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/hyperlink/ISTAnnotationHyperlink.java
new file mode 100644
index 0000000..95dad66
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/hyperlink/ISTAnnotationHyperlink.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.hyperlink;
+
+public interface ISTAnnotationHyperlink {
+ boolean isAnnotationHyperlink(int line);
+ void handleHyperlink(int line);
+}
diff --git a/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/preferencespages/STAnnotatedSourceEditorPreferencePage.java b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/preferencespages/STAnnotatedSourceEditorPreferencePage.java
new file mode 100644
index 0000000..23fd2d9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.annotatedsourceeditor/src/org/eclipse/linuxtools/dataviewers/annotatedsourceeditor/preferencespages/STAnnotatedSourceEditorPreferencePage.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.preferencespages;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class STAnnotatedSourceEditorPreferencePage extends PreferencePage
+ implements IWorkbenchPreferencePage {
+
+ /**
+ * A named preference that controls if the line number ruler is shown in the UI
+ * (value <code>"lineNumberRuler"</code>).
+ * <p>
+ * The preference value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_ST_RULER= "STRuler"; //$NON-NLS-1$
+
+ public STAnnotatedSourceEditorPreferencePage() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public STAnnotatedSourceEditorPreferencePage(String title) {
+ super(title);
+ // TODO Auto-generated constructor stub
+ }
+
+ public STAnnotatedSourceEditorPreferencePage(String title,
+ ImageDescriptor image) {
+ super(title, image);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void init(IWorkbench workbench) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/.classpath b/org.eclipse.linuxtools.dataviewers.charts/.classpath
new file mode 100755
index 0000000..8a8f166
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.dataviewers.charts/.project b/org.eclipse.linuxtools.dataviewers.charts/.project
new file mode 100755
index 0000000..70e988c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.dataviewers.charts</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF
new file mode 100755
index 0000000..ea57dcd
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.dataviewers.charts;singleton:=true
+Bundle-Version: 4.1.0.qualifier
+Bundle-Activator: org.eclipse.linuxtools.dataviewers.charts.Activator
+Bundle-Vendor: %bundleProvider
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.linuxtools.dataviewers;bundle-version="4.0.0",
+ org.eclipse.birt.core;bundle-version="2.5.1",
+ org.eclipse.birt.chart.ui;bundle-version="2.5.1",
+ org.eclipse.birt.data;bundle-version="2.5.1",
+ org.eclipse.birt.data.aggregation;bundle-version="2.5.1",
+ org.eclipse.core.resources;bundle-version="3.4.2"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.dataviewers.charts,
+ org.eclipse.linuxtools.dataviewers.charts.actions,
+ org.eclipse.linuxtools.dataviewers.charts.dataengine,
+ org.eclipse.linuxtools.dataviewers.charts.dialogs,
+ org.eclipse.linuxtools.dataviewers.charts.provider,
+ org.eclipse.linuxtools.dataviewers.charts.view,
+ org.eclipse.linuxtools.dataviewers.charts.viewer
+Import-Package: com.ibm.icu.util;version="4.0.1"
+Bundle-Localization: plugin
diff --git a/org.eclipse.linuxtools.dataviewers.charts/about.html b/org.eclipse.linuxtools.dataviewers.charts/about.html
new file mode 100644
index 0000000..23506a4
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers.charts/build.properties b/org.eclipse.linuxtools.dataviewers.charts/build.properties
new file mode 100755
index 0000000..8ef30b8
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = .,\
+ META-INF/,\
+ icons/,\
+ plugin.xml,\
+ about.html,\
+ plugin.properties
diff --git a/org.eclipse.linuxtools.dataviewers.charts/icons/Thumbs.db b/org.eclipse.linuxtools.dataviewers.charts/icons/Thumbs.db
new file mode 100755
index 0000000..1f91a7a
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/icons/Thumbs.db
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.charts/icons/chart_icon.png b/org.eclipse.linuxtools.dataviewers.charts/icons/chart_icon.png
new file mode 100755
index 0000000..67d1a81
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/icons/chart_icon.png
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.charts/icons/dexport.gif b/org.eclipse.linuxtools.dataviewers.charts/icons/dexport.gif
new file mode 100644
index 0000000..3f89cd9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/icons/dexport.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.charts/icons/dimport.gif b/org.eclipse.linuxtools.dataviewers.charts/icons/dimport.gif
new file mode 100644
index 0000000..cd44741
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/icons/dimport.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.charts/icons/eexport.gif b/org.eclipse.linuxtools.dataviewers.charts/icons/eexport.gif
new file mode 100644
index 0000000..5a0837d
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/icons/eexport.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.charts/icons/eimport.gif b/org.eclipse.linuxtools.dataviewers.charts/icons/eimport.gif
new file mode 100644
index 0000000..d38085a
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/icons/eimport.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.charts/icons/save_chart.gif b/org.eclipse.linuxtools.dataviewers.charts/icons/save_chart.gif
new file mode 100755
index 0000000..466bfb1
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/icons/save_chart.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers.charts/plugin.properties b/org.eclipse.linuxtools.dataviewers.charts/plugin.properties
new file mode 100644
index 0000000..c1c5fab
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/plugin.properties
@@ -0,0 +1,14 @@
+#******************************************************************************
+# Copyright (c) 2009 STMicroelectronics.
+# 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:
+# STMicroelectronics - initial API and implementation
+#*******************************************************************************
+bundleProvider = Eclipse Linux Tools
+bundleName = Data Viewers Birt Charts Plug-in (Incubation)
+chartview.name = Chart View
+chartcategory.name = Charts \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers.charts/plugin.xml b/org.eclipse.linuxtools.dataviewers.charts/plugin.xml
new file mode 100755
index 0000000..fd38dfb
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ allowMultiple="true"
+ category="org.eclipse.linuxtools.dataviewers.charts"
+ class="org.eclipse.linuxtools.dataviewers.charts.view.ChartView"
+ icon="icons/chart_icon.png"
+ id="org.eclipse.linuxtools.dataviewers.charts.view"
+ name="%chartview.name"
+ restorable="true">
+ </view>
+ <category
+ id="org.eclipse.linuxtools.dataviewers.charts"
+ name="%chartcategory.name">
+ </category>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/Activator.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/Activator.java
new file mode 100755
index 0000000..0162326
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/Activator.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.dataviewers.charts";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Returns an image from the path
+ *
+ * @param path the path
+ * @return the image
+ */
+ public static Image getImage(String path) {
+ Image image = plugin.getImageRegistry().get(path);
+ if (image == null) {
+ image = getImageDescriptor(path).createImage();
+ plugin.getImageRegistry().put(path, image);
+ }
+ return image;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/ChartConstants.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/ChartConstants.java
new file mode 100755
index 0000000..431ecf0
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/ChartConstants.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts;
+
+
+/**
+ * A class that handles the constants used by the charts.
+ *
+ * <br/>
+ * <br/>
+ * It contains:
+ * <ul>
+ * <li>labels used by the chart dialog.</li>
+ * <li>keys and default values used by the dialog settings.</li>
+ * <li>predefined colors used by the charts.</li>
+ * </ul>
+ *
+ */
+public class ChartConstants {
+
+ /** The section name of the viewer's dialog settings where the chart dialog save its state */
+ public static final String TAG_SECTION_BIRTCHARTS_STATE = "birtcharts_section";
+ /** The key used by the column buttons to save their state. For example the button i will use the key <code>TAG_COLUMN_BUTTON_+i</code> */
+ public static final String TAG_COLUMN_BUTTON_ = "COLUMN_BUTTON_";
+ /** The key used by the bar graph button to save its state */
+ public static final String TAG_BAR_GRAPH_BUTTON = "BAR_GRAPH_BUTTON";
+ /** The key used by the vertical bars button to save its state */
+ public static final String TAG_VERTICAL_BARS_BUTTON = "VERTICAL_BARS_BUTTON";
+
+ /** The default value of the column buttons */
+ public static final boolean DEFAULT_COLUMN_BUTTON = true;
+ /** The default value of the bar graph button */
+ public static final boolean DEFAULT_BAR_GRAPH_BUTTON = true;
+ /** The default value of the vertical bars button */
+ public static final boolean DEFAULT_VERTICAL_BARS_BUTTON = false;
+
+ /** The section name of the "save chart as image" action dialog settings */
+ public static final String TAG_SECTION_BIRTCHARTS_SAVEACTION_STATE = "birtcharts_saveasimg_section";
+ /** The key used by the file dialog to save its file name */
+ public static final String TAG_IMG_FILE_NAME = "IMG_FILE_NAME";
+ /** The key used by the file dialog to save its filter path */
+ public static final String TAG_IMG_FILTER_PATH = "IMG_FILTER_PATH";
+
+ /** The default value of the file dialog file name */
+ public static final String DEFAULT_IMG_FILE_NAME = ".";
+ /** The default value of the file dialog filter path */
+ public static final String DEFAULT_IMG_FILTER_PATH = ".";
+
+ /** Image extension for jpg format */
+ public static final String EXT_JPG = ".jpg";
+ /** Image extension for jpeg format */
+ public static final String EXT_JPEG = ".jpeg";
+ /** Image extension for png format */
+ public static final String EXT_PNG = ".png";
+ /** Image extension for gif format */
+ public static final String EXT_GIF = ".gif";
+ /** Image extension for svg format */
+ public static final String EXT_SVG = ".svg";
+ /** The file extensions provided by the "save chart as image" file dialog */
+ public static final String[] saveAsImageExt =
+ {
+ "*"+EXT_JPG,
+ "*"+EXT_JPEG,
+ "*"+EXT_PNG,
+ "*"+EXT_GIF,
+ "*.*"
+ };
+ /** The names associated to the files extensions provided by the "save chart as image" file dialog */
+ public static String[] saveAsImageExtNames =
+ {
+ "JPEG (*.jpg)",
+ "JPEG (*.jpeg)",
+ "PNG (*.png)",
+ "GIF (*.gif)",
+ "All Files (*.*)"
+ };
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/UIHelper.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/UIHelper.java
new file mode 100644
index 0000000..1cfc2e3
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/UIHelper.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Actuate Corporation.
+ * 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:
+ * Actuate Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.charts;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * This class has been created to hold methods that provide specific
+ * functionality or services.
+ */
+public final class UIHelper
+{
+
+ /**
+ * This method returns an URL for a resource given its plugin relative path.
+ * It is intended to be used to abstract out the usage of the UI as a plugin
+ * or standalone component when it comes to accessing resources.
+ *
+ * @param sPluginRelativePath
+ * The path to the resource relative to the plugin location.
+ * @return URL representing the location of the resource.
+ */
+ public static URL getURL( String sPluginRelativePath )
+ {
+ URL url = null;
+ if ( Platform.getExtensionRegistry( ) != null )
+ {
+ try
+ {
+ url = new URL( Activator.getDefault( )
+ .getBundle( )
+ .getEntry( "/" ), sPluginRelativePath ); //$NON-NLS-1$
+ }
+ catch ( MalformedURLException e )
+ {
+ e.printStackTrace( );
+ }
+ }
+ else
+ {
+ try
+ {
+ url = new URL( "file:///" + new File( sPluginRelativePath ).getAbsolutePath( ) ); //$NON-NLS-1$
+ }
+ catch ( MalformedURLException e )
+ {
+ e.printStackTrace( );
+ }
+ }
+
+ return url;
+ }
+
+ private static Image createImage( String sPluginRelativePath )
+ {
+ Image img = null;
+ try
+ {
+ try
+ {
+ img = new Image( Display.getCurrent( ),
+ getURL( sPluginRelativePath ).openStream( ) );
+ }
+ catch ( MalformedURLException e1 )
+ {
+ img = new Image( Display.getCurrent( ),
+ new FileInputStream( getURL( sPluginRelativePath ).toString( ) ) );
+ }
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace( );
+ }
+
+ // If still can't load, return a dummy image.
+ if ( img == null )
+ {
+ img = new Image( Display.getCurrent( ), 1, 1 );
+ }
+ return img;
+ }
+
+ /**
+ * This is a convenience method to get an imgIcon from a URL.
+ *
+ * @param sPluginRelativePath
+ * The URL for the imgIcon.
+ * @return The imgIcon represented by the given URL.
+ * @see #setImageCached( boolean )
+ */
+ public static Image getImage( String sPluginRelativePath )
+ {
+ ImageRegistry registry = JFaceResources.getImageRegistry( );
+ Image image = registry.get( sPluginRelativePath );
+ if ( image == null )
+ {
+ image = createImage( sPluginRelativePath );
+ registry.put( sPluginRelativePath, image );
+ }
+ return image;
+ }
+
+ /**
+ * This is a convenience method to get an imgIcon from a URL.
+ *
+ * @param sPluginRelativePath
+ * The URL for the imgIcon.
+ * @return The imgIcon represented by the given URL.
+ * @see #setImageCached( boolean )
+ */
+ public static ImageDescriptor getImageDescriptor( String sPluginRelativePath )
+ {
+ ImageRegistry registry = JFaceResources.getImageRegistry( );
+ ImageDescriptor image = registry.getDescriptor( sPluginRelativePath );
+ if ( image == null )
+ {
+ registry.put( sPluginRelativePath,
+ createImage( sPluginRelativePath ) );
+ image = registry.getDescriptor( sPluginRelativePath );
+ }
+ return image;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java
new file mode 100755
index 0000000..43cf431
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.actions;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.charts.Activator;
+import org.eclipse.linuxtools.dataviewers.charts.dialogs.ChartDialog;
+import org.eclipse.linuxtools.dataviewers.charts.view.ChartView;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * An action that open a chart dialog from an <code>AbstractSTViewer</code>.
+ *
+ * @see AbstractSTViewer
+ */
+public class ChartAction extends Action {
+
+ /** The dialog */
+ private ChartDialog dialog;
+
+ /**
+ * The constructor.
+ *
+ * @param shell the shell used by the dialog
+ * @param viewer the viewer inputed to the disalog
+ */
+ public ChartAction(Shell shell, AbstractSTViewer viewer) {
+ super("Create chart...", Activator.getImageDescriptor("icons/chart_icon.png"));
+ dialog = createDialog(shell, viewer);
+ setEnabled(!viewer.getViewer().getSelection().isEmpty());
+ viewer.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ setEnabled(!event.getSelection().isEmpty());
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ dialog.open();
+ Chart chart = dialog.getValue();
+ if (chart != null) {
+ ChartView.createChartView(chart);
+
+ }
+ }
+
+ protected ChartDialog createDialog(Shell shell,AbstractSTViewer viewer){
+ return new ChartDialog(shell,viewer);
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartActionRenderer.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartActionRenderer.java
new file mode 100644
index 0000000..cd47aab
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartActionRenderer.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.actions;
+
+import org.eclipse.birt.chart.render.ActionRendererAdapter;
+import org.eclipse.birt.chart.computation.DataPointHints;
+import org.eclipse.birt.chart.event.StructureSource;
+import org.eclipse.birt.chart.event.StructureType;
+import org.eclipse.birt.chart.model.attribute.ActionType;
+import org.eclipse.birt.chart.model.attribute.TooltipValue;
+import org.eclipse.birt.chart.model.attribute.impl.JavaNumberFormatSpecifierImpl;
+import org.eclipse.birt.chart.model.data.Action;
+
+import com.ibm.icu.util.ULocale;
+
+
+/**
+ * Simple implementation for IActionRenderer
+ */
+public class ChartActionRenderer extends ActionRendererAdapter {
+
+
+ public void processAction( Action action, StructureSource source )
+ {
+ if ( ActionType.SHOW_TOOLTIP_LITERAL.equals( action.getType( ) ) )
+ {
+ TooltipValue tv = (TooltipValue) action.getValue( );
+ if ( StructureType.SERIES_DATA_POINT.equals( source.getType( ) ) )
+ {
+ final DataPointHints dph = (DataPointHints) source.getSource( );
+ String MyToolTip = "Value is " +
+ JavaNumberFormatSpecifierImpl.create("0.00").format(
+ ((Double)dph.getOrthogonalValue()).doubleValue(),ULocale.getDefault());
+ tv.setText( MyToolTip );
+ }
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/OpenChartAction.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/OpenChartAction.java
new file mode 100644
index 0000000..539ef4c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/OpenChartAction.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.actions;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.Serializer;
+import org.eclipse.birt.chart.model.impl.SerializerImpl;
+import org.eclipse.birt.core.ui.frameworks.taskwizard.WizardBase;
+import org.eclipse.jface.action.Action;
+import org.eclipse.linuxtools.dataviewers.charts.UIHelper;
+import org.eclipse.linuxtools.dataviewers.charts.view.ChartView;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+
+
+
+public class OpenChartAction extends Action {
+ private Chart chart = null;
+ private FileDialog dialog;
+ private ChartView chartView;
+
+ public OpenChartAction(Shell shell,ChartView cView){
+ setImageDescriptor( UIHelper.getImageDescriptor( "icons/eimport.gif" ) );
+ setDisabledImageDescriptor( UIHelper.getImageDescriptor( "icons/dimport.gif" ) );
+ setToolTipText( "Open XML Source" );
+ setEnabled(true);
+ this.chartView = cView;
+ this.dialog = new FileDialog(shell, SWT.OPEN);
+ dialog.setText("Select a chart file ");
+ dialog.setFilterExtensions(new String[]{"*.chart"});
+ }
+
+ public void run() {
+ String path = dialog.open();
+
+ if (path == null) {
+ // cancel pressed
+ return;
+ }
+
+ Serializer serializer = null;
+ final File chartFile = new File( path );
+
+ // Reads the chart model
+ try
+ {
+ serializer = SerializerImpl.instance( );
+ if ( chartFile.exists( ) )
+ {
+ chart = serializer.read( new FileInputStream( chartFile ) );
+ chartView.getChartViewer().setBuffer(null);
+ chartView.setChart(chart);
+ }
+ }
+ catch ( Exception e )
+ {
+ WizardBase.displayException( e );
+ }
+ }
+
+ public Chart getChart(){
+ return chart;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveChartAction.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveChartAction.java
new file mode 100755
index 0000000..74de88b
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveChartAction.java
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.actions;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.birt.chart.device.IDeviceRenderer;
+import org.eclipse.birt.chart.exception.ChartException;
+import org.eclipse.birt.chart.factory.GeneratedChartState;
+import org.eclipse.birt.chart.factory.Generator;
+import org.eclipse.birt.chart.factory.RunTimeContext;
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.attribute.Bounds;
+import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
+import org.eclipse.birt.chart.util.PluginSettings;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.dataviewers.charts.Activator;
+import org.eclipse.linuxtools.dataviewers.charts.ChartConstants;
+import org.eclipse.linuxtools.dataviewers.charts.view.ChartView;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import com.ibm.icu.util.ULocale;
+
+/**
+ * An action to save a chart as an image (jpeg, gif, png)
+ * @author Marzia Maugeri <marzia.maugeri@st.com>
+ */
+public class SaveChartAction extends Action {
+
+ private FileDialog dialog;
+ private Shell shell;
+ private Chart cm;
+ private IDeviceRenderer idr;
+ private Bounds bo;
+ private ChartView chartView;
+
+ /**
+ * Constructor
+ *
+ * @param shell the shell used by the dialogs
+ */
+ public SaveChartAction(Shell shell,ChartView cview) {
+ super("Save chart as...", Activator.getImageDescriptor("icons/save_chart.gif"));
+ this.chartView = cview;
+ this.setEnabled(false);
+ this.shell = shell;
+ this.dialog = new FileDialog(shell, SWT.SAVE);
+ dialog.setFileName(ChartConstants.DEFAULT_IMG_FILE_NAME);
+ dialog.setFilterPath(ChartConstants.DEFAULT_IMG_FILTER_PATH);
+ dialog.setFilterExtensions(ChartConstants.saveAsImageExt);
+ dialog.setFilterNames(ChartConstants.saveAsImageExtNames);
+ dialog.setText("Select an image file (extension will be set to \".jpeg\" if not recognized).");
+
+ // restore state if there is one saved
+ restoreState();
+ }
+
+ /**
+ * Sets the image plugins on the chart and enables the action if chart is not null.
+ *
+ * @param chart
+ */
+ public void setChart(Chart chart) {
+ try {
+ if (chart != null) {
+ setEnabled(true);
+ } else {
+ setEnabled(false);
+ }
+ cm = chart;
+ } catch (Throwable _)
+ {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ "Error when creating \"save as image\" action...",
+ _);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+
+ public void setBounds(Bounds bo){
+ this.bo = bo;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ String path = dialog.open();
+ if (path == null) {
+ // cancel pressed
+ return;
+ }
+
+ String ext = "";
+
+
+ int dotIdx = path.lastIndexOf(".");
+ if (dotIdx > 0) ext = path.substring(dotIdx);
+
+ try {
+ if (ext.equals(ChartConstants.EXT_GIF)) {
+ idr = PluginSettings.instance().getDevice("dv.GIF");
+ }
+ else if (ext.equals(ChartConstants.EXT_JPEG)) {
+ idr = PluginSettings.instance().getDevice("dv.JPEG");
+ }
+ else if (ext.equals(ChartConstants.EXT_JPG)) {
+ idr = PluginSettings.instance().getDevice("dv.JPG");
+ }
+ else if (ext.equals(ChartConstants.EXT_PNG)) {
+ idr = PluginSettings.instance().getDevice("dv.PNG");
+ }
+ else {
+ path += ChartConstants.EXT_JPEG;
+ idr = PluginSettings.instance().getDevice("dv.JPG");
+ }
+
+ } catch (ChartException e) {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ e.getMessage(),
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+
+ final File file = new File(path);
+ if (file.exists()) {
+ boolean overwrite =
+ MessageDialog.openQuestion(shell, "Confirm overwrite", "File already exists. Overwrite?");
+ if (overwrite) {
+ file.delete();
+ } else {
+ return;
+ }
+ }
+
+ Job saveAsImage = new Job("Save chart as "+file.getName()) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ monitor.beginTask("Saving chart as "+file.getName()+"...", IProgressMonitor.UNKNOWN);
+ file.createNewFile();
+ generateImageFile(file);
+ return Status.OK_STATUS;
+ } catch (IOException e) {
+ return new Status(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ "Error saving chart to \""
+ + file.getAbsolutePath()
+ + "\":"
+ + e.getMessage(),
+ e);
+ }
+ }
+ };
+ saveAsImage.setUser(true);
+ saveAsImage.schedule();
+
+ // save the state of the dialog
+ saveState();
+ }
+
+ /**
+ * Restores the state of this action (file dialog)
+ */
+ public void restoreState() {
+ try {
+ IDialogSettings settings =
+ Activator.getDefault().getDialogSettings().getSection(ChartConstants.TAG_SECTION_BIRTCHARTS_SAVEACTION_STATE);
+ if (settings == null) {
+ settings = Activator.getDefault().getDialogSettings().addNewSection(ChartConstants.TAG_SECTION_BIRTCHARTS_SAVEACTION_STATE);
+ return;
+ }
+
+ dialog.setFileName(settings.get(ChartConstants.TAG_IMG_FILE_NAME));
+ dialog.setFilterPath(settings.get(ChartConstants.TAG_IMG_FILTER_PATH));
+ }
+ catch (Exception e) {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ e.getMessage(),
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+
+ /**
+ * Saves the state of this action (file dialog)
+ */
+ public void saveState() {
+ try {
+ IDialogSettings settings =
+ Activator.getDefault().getDialogSettings().getSection(ChartConstants.TAG_SECTION_BIRTCHARTS_SAVEACTION_STATE);
+ if (settings == null) {
+ settings = Activator.getDefault().getDialogSettings().addNewSection(ChartConstants.TAG_SECTION_BIRTCHARTS_SAVEACTION_STATE);
+ }
+
+ settings.put(ChartConstants.TAG_IMG_FILE_NAME, dialog.getFileName());
+ settings.put(ChartConstants.TAG_IMG_FILTER_PATH, dialog.getFilterPath());
+ }
+ catch (Exception e) {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ e.getMessage(),
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+
+ protected void generateImageFile(File file){
+ RunTimeContext rtc = new RunTimeContext( );
+ rtc.setULocale( ULocale.getDefault( ) );
+
+ final Generator gr = Generator.instance( );
+ GeneratedChartState gcs = null;
+
+ Bounds boFile = null;
+ bo = chartView.getChartViewer().getBounds();
+ //Set the chart size
+ if (bo != null){
+ boFile = BoundsImpl.create(bo.getLeft(), bo.getTop(), bo.getWidth(), bo.getHeight());
+ }
+ else{
+ boFile = BoundsImpl.create(0, 0, 800, 600);
+ }
+
+
+ try {
+ gcs = gr.build( idr.getDisplayServer( ), cm, boFile, null, rtc, null );
+ } catch (ChartException e) {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ e.getMessage(),
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+
+ //Specify the file to write to.
+ idr.setProperty( IDeviceRenderer.FILE_IDENTIFIER, file.getAbsolutePath() );
+
+ //generate the chart
+ try {
+ gr.render( idr, gcs );
+ } catch (ChartException e) {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ e.getMessage(),
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction.java
new file mode 100644
index 0000000..aa36687
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction.java
@@ -0,0 +1,133 @@
+/***********************************************************************
+ * Copyright (c) 2004, 2005 Actuate Corporation.
+ * 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:
+ * Actuate Corporation - initial API and implementation
+ ***********************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.charts.actions;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.Serializer;
+import org.eclipse.birt.chart.model.impl.SerializerImpl;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.linuxtools.dataviewers.charts.Activator;
+import org.eclipse.linuxtools.dataviewers.charts.UIHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.MessageBox;
+
+public class SaveXMLAction extends Action
+{
+
+ private Composite cmp;
+ private Chart cm;
+
+ public SaveXMLAction( Composite parent )
+ {
+ super( );
+ cmp = parent;
+ setImageDescriptor( UIHelper.getImageDescriptor( "icons/eexport.gif" ) );
+ setDisabledImageDescriptor( UIHelper.getImageDescriptor( "icons/dexport.gif" ) );
+ setToolTipText( "Save XML Source" );
+ setDescription( "Save XML Source to the designated directory" );
+ }
+
+ /**
+ * When the action is invoked, pop up a File Dialog to designate the
+ * directory.
+ */
+ public void run( )
+ {
+ if ( cm != null )
+ {
+ final FileDialog saveDialog = new FileDialog( cmp.getShell( ),
+ SWT.SAVE );
+ saveDialog.setFilterExtensions( new String[]{
+ "*.chart"} ); //$NON-NLS-1$
+ try
+ {
+ saveDialog.open( );
+ String name = saveDialog.getFileName( );
+ if ( name != null && name != "" ) //$NON-NLS-1$
+ {
+ Serializer serializer = null;
+ final File file = new File( saveDialog.getFilterPath( ),
+ name );
+ if ( file.exists( ) )
+ {
+ MessageBox box = new MessageBox( cmp.getShell( ),
+ SWT.ICON_WARNING | SWT.YES | SWT.NO );
+ box.setText( "Save XML Source"); //$NON-NLS-1$
+ box.setMessage( "The XML source already exists in the directory. \nDo you want to replace it?" );
+ if ( box.open( ) != SWT.YES )
+ {
+ return;
+ }
+ }
+
+ serializer = SerializerImpl.instance( );
+ try
+ {
+ // FIXED: Cloned instance of cm object must be passed. Otherwise, the chart(cm object) does not be scaled by resize event.
+ serializer.write( cm.copyInstance(), new FileOutputStream( file ) );
+ IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(file.getAbsolutePath()));
+ if (c != null){
+ try {
+ c.refreshLocal(1, new NullProgressMonitor());
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+
+ }
+ catch ( IOException ioe )
+ {
+ ioe.printStackTrace( );
+ }
+ }
+ }
+ catch ( Throwable e )
+ {
+ e.printStackTrace( );
+ }
+ }
+ }
+
+ public void setChart(Chart chart) {
+ try {
+ if (chart != null) {
+ setEnabled(true);
+ } else {
+ setEnabled(false);
+ }
+ cm = chart;
+ } catch (Throwable _)
+ {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ "Error when creating \"save as image\" action...",
+ _);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/BindDataEngine.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/BindDataEngine.java
new file mode 100644
index 0000000..a6d2d3a
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/BindDataEngine.java
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Actuate Corporation.
+ * 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:
+ * Actuate Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.dataengine;
+
+import org.eclipse.birt.chart.exception.ChartException;
+import org.eclipse.birt.chart.factory.Generator;
+import org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator;
+import org.eclipse.birt.chart.factory.RunTimeContext;
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.ChartWithAxes;
+import org.eclipse.birt.chart.model.attribute.AxisType;
+import org.eclipse.birt.chart.model.attribute.IntersectionType;
+import org.eclipse.birt.chart.model.attribute.LegendItemType;
+import org.eclipse.birt.chart.model.attribute.Position;
+import org.eclipse.birt.chart.model.attribute.TickStyle;
+import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl;
+import org.eclipse.birt.chart.model.component.Axis;
+import org.eclipse.birt.chart.model.component.Series;
+import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
+import org.eclipse.birt.chart.model.data.SeriesDefinition;
+import org.eclipse.birt.chart.model.data.impl.QueryImpl;
+import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
+import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
+import org.eclipse.birt.chart.model.layout.Legend;
+import org.eclipse.birt.chart.model.layout.Plot;
+import org.eclipse.birt.chart.model.type.BarSeries;
+import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl;
+import org.eclipse.birt.core.archive.IDocArchiveReader;
+import org.eclipse.birt.core.archive.IDocArchiveWriter;
+import org.eclipse.birt.core.data.Constants;
+import org.eclipse.birt.core.data.ExpressionUtil;
+import org.eclipse.birt.core.exception.BirtException;
+import org.eclipse.birt.data.aggregation.api.IBuildInAggregation;
+import org.eclipse.birt.data.engine.api.DataEngine;
+import org.eclipse.birt.data.engine.api.DataEngineContext;
+import org.eclipse.birt.data.engine.api.IGroupDefinition;
+import org.eclipse.birt.data.engine.api.IPreparedQuery;
+import org.eclipse.birt.data.engine.api.IQueryResults;
+import org.eclipse.birt.data.engine.api.querydefn.Binding;
+import org.eclipse.birt.data.engine.api.querydefn.GroupDefinition;
+import org.eclipse.birt.data.engine.api.querydefn.OdaDataSetDesign;
+import org.eclipse.birt.data.engine.api.querydefn.OdaDataSourceDesign;
+import org.eclipse.birt.data.engine.api.querydefn.QueryDefinition;
+import org.eclipse.birt.data.engine.api.querydefn.ScriptExpression;
+import org.eclipse.birt.data.engine.core.DataException;
+import org.eclipse.linuxtools.dataviewers.charts.Activator;
+
+import com.ibm.icu.util.ULocale;
+
+/**
+ * The example demonstrates how chart works with ODA/DtE(BIRT data engine) to
+ * get grouped/aggregated data set, the ODA/DtE is responsible to execute data
+ * query and grouping/aggregation, it returns a grouped data set to chart and
+ * chart retrieve data without grouping/aggregation by chart-self.
+ * <p>
+ * In the example, it only uses flat file as data source, actually it supports
+ * any JDBC data source, referring to {@link org.eclipse.birt.data.engine} to
+ * get detail information.
+ *
+ * @since 2.3
+ */
+public class BindDataEngine
+{
+ private String[] columnsName = null;
+ private FlatFileDataSource ffds = null;
+
+ /**
+ * Create runtime chart model and bind data.
+ *
+ * @return
+ * @throws ChartException
+ */
+ public final Chart createWorkingWithBIRTDataEngine(FlatFileDataSource ffds)
+ throws ChartException
+ {
+ this.ffds = ffds;
+ columnsName = ffds.getCOLUMNNAME();
+ String[] expressions = new String[columnsName.length];
+ expressions[0] = ExpressionUtil.createRowExpression( columnsName[0] );
+ expressions[1] = ExpressionUtil.createRowExpression( columnsName[1] );
+
+ ChartWithAxes cwaBar = createChartModel( expressions );
+
+ cwaBar = bindData( cwaBar, expressions );
+
+ return cwaBar;
+ }
+
+ /**
+ * Create chart model.
+ *
+ * @param expressions
+ * expressions are used to set category series and value series.
+ * @return
+ */
+ private static ChartWithAxes createChartModel( String[] expressions )
+ {
+ ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
+ cwaBar.setType( "Bar Chart" );
+ cwaBar.setSubType( "Side-by-side" );
+ // Plot
+ cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
+ cwaBar.getBlock( ).getOutline( ).setVisible( true );
+ Plot p = cwaBar.getPlot( );
+ p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
+ 255,
+ 225 ) );
+
+ // Title
+ cwaBar.getTitle( )
+ .getLabel( )
+ .getCaption( )
+ .setValue( "Working with BIRT Data Engine" );
+
+ // Legend
+ Legend lg = cwaBar.getLegend( );
+ lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
+
+ // X-Axis
+ Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
+
+ xAxisPrimary.setType( AxisType.TEXT_LITERAL );
+ xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
+ xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
+
+ // Y-Axis
+ Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
+ yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
+ yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
+ yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 90 );
+ yAxisPrimary.getTitle( ).setVisible( true );
+ yAxisPrimary.getTitle( ).getCaption( ).setValue( "Customer Amount" ); //$NON-NLS-1$
+ yAxisPrimary.getTitle( )
+ .getCaption( )
+ .setColor( ColorDefinitionImpl.GREEN( ) );
+
+ // X-Series
+ Series seCategory = SeriesImpl.create( );
+ // seCategory.setDataSet( categoryValues );
+
+ // Set category expression.
+ seCategory.getDataDefinition( )
+ .add( QueryImpl.create( expressions[0] ) );
+
+ SeriesDefinition sdX = SeriesDefinitionImpl.create( );
+ sdX.getSeriesPalette( ).shift( 0 );
+
+ xAxisPrimary.getSeriesDefinitions( ).add( sdX );
+ sdX.getSeries( ).add( seCategory );
+
+ // Y-Series
+ BarSeries bs1 = (BarSeries) BarSeriesImpl.create( );
+ bs1.getDataDefinition( ).add( QueryImpl.create( expressions[1] ) );
+ bs1.getLabel( ).setVisible( true );
+ bs1.setLabelPosition( Position.INSIDE_LITERAL );
+
+ SeriesDefinition sdY = SeriesDefinitionImpl.create( );
+ yAxisPrimary.getSeriesDefinitions( ).add( sdY );
+ sdY.getSeries( ).add( bs1 );
+ return cwaBar;
+ }
+
+ /**
+ * Binds data into chart model.
+ *
+ * @param cwaBar
+ * @return
+ * @throws ChartException
+ */
+ private ChartWithAxes bindData( ChartWithAxes cwaBar,
+ String[] expressions ) throws ChartException
+ {
+
+ RunTimeContext context = new RunTimeContext( );
+ context.setULocale( ULocale.getDefault( ) );
+
+ IDataRowExpressionEvaluator evaluator;
+ try
+ {
+ // Create row expression evaluator for chart doing data binding.
+ evaluator = prepareRowExpressionEvaluator( cwaBar, expressions );
+
+ // Binding data.
+ Generator.instance( ).bindData( evaluator, cwaBar, context );
+ }
+ catch ( BirtException e )
+ {
+ throw new ChartException( Activator.PLUGIN_ID,
+ ChartException.DATA_BINDING,
+ e );
+ }
+ return cwaBar;
+ }
+
+ /**
+ * Uses BIRT data engine to do query and wraps data with
+ * <code>IDataRowExpressionEvaluator</code> for chart doing data binding.
+ *
+ * @return
+ * @throws BirtException
+ */
+ private IDataRowExpressionEvaluator prepareRowExpressionEvaluator(
+ ChartWithAxes chart, String[] expressions ) throws BirtException
+ {
+
+ // Initialize data source and data set.
+ OdaDataSourceDesign odaDataSource = newDataSource( );
+ OdaDataSetDesign odaDataSet = newDataSet( odaDataSource );
+
+ // Create query definition.
+ QueryDefinition query = createQueryDefinition( odaDataSet, expressions );
+
+ // Create data engine and execute query.
+ DataEngine dataEngine = newDataEngine( );
+ dataEngine.defineDataSource( odaDataSource );
+ dataEngine.defineDataSet( odaDataSet );
+ IPreparedQuery preparedQuery = dataEngine.prepare( query );
+
+ IQueryResults queryResults = preparedQuery.execute( null );
+
+ // Create row expression evaluator.
+ return new GroupedRowExpressionsEvaluator( queryResults.getResultIterator( ),
+ true );
+ }
+
+ /**
+ * Create query definition.
+ *
+ * @param odaDataSet
+ * @param expressions
+ * @return
+ * @throws ChartException
+ */
+ private QueryDefinition createQueryDefinition(
+ OdaDataSetDesign odaDataSet, String[] expressions )
+ throws ChartException
+ {
+
+ QueryDefinition queryDefn = new QueryDefinition( );
+ queryDefn.setDataSetName( odaDataSet.getName( ) );
+
+ try
+ {
+ initDefaultBindings( queryDefn );
+
+ // Add group definitions and aggregation binding.
+ String groupName = "Group_Country"; //$NON-NLS-1$
+ GroupDefinition gd = new GroupDefinition( groupName );
+ gd.setKeyExpression( expressions[0] );
+ gd.setInterval( IGroupDefinition.NO_INTERVAL );
+ gd.setIntervalRange( 0 );
+
+ // Add expression bindings.
+ for ( int i = 0; i < expressions.length; i++ )
+ {
+ String expr = (String) expressions[i];
+ Binding colBinding = new Binding( expr );
+ colBinding.setExpression( new ScriptExpression( expr ) );
+ if ( i == 1 )
+ {
+ colBinding.setExpression( null );
+ colBinding.setAggrFunction( IBuildInAggregation.TOTAL_COUNT_FUNC );
+ colBinding.addAggregateOn( groupName );
+ colBinding.addArgument( new ScriptExpression( expressions[i] ) );
+ }
+
+ queryDefn.addBinding( colBinding );
+ }
+
+ queryDefn.addGroup( gd );
+ }
+ catch ( DataException e )
+ {
+ throw new ChartException( Activator.PLUGIN_ID,
+ ChartException.DATA_BINDING,
+ e );
+ }
+
+ return queryDefn;
+ }
+
+ /**
+ * Initialize default column bindings for original columns.
+ *
+ * @param queryDefn
+ * @throws DataException
+ */
+ private void initDefaultBindings( QueryDefinition queryDefn )
+ throws DataException
+ {
+
+ for(int i=0;i<columnsName.length;i++){
+ Binding colBinding = new Binding( columnsName[i] );
+ colBinding.setExpression( new ScriptExpression( ExpressionUtil.createDataSetRowExpression( columnsName[i]) ) );
+ queryDefn.addBinding( colBinding );
+ }
+ }
+
+ /**
+ * Create a new data engine.
+ *
+ * @return
+ * @throws BirtException
+ */
+ private static DataEngine newDataEngine( ) throws BirtException
+ {
+ DataEngineContext context = DataEngineContext.newInstance( DataEngineContext.DIRECT_PRESENTATION,null,(IDocArchiveReader) null,(IDocArchiveWriter) null);
+
+ // context.setTmpdir( this.getTempDir( ) );
+ DataEngine myDataEngine = DataEngine.newDataEngine( context );
+ return myDataEngine;
+ }
+
+ /**
+ * Create a new data set.
+ *
+ * @param dataSourceDesign
+ * @return
+ */
+ private OdaDataSetDesign newDataSet(
+ OdaDataSourceDesign dataSourceDesign )
+ {
+ OdaDataSetDesign dataSet = new OdaDataSetDesign( "Data Set1" ); //$NON-NLS-1$
+
+ dataSet.setDataSource( dataSourceDesign.getName( ) );
+ dataSet.setExtensionID( FlatFileDataSource.DATA_SET_TYPE );
+ dataSet.setQueryText( ffds.getQuery() );
+ return dataSet;
+ }
+
+ /**
+ * Create a new data source.
+ *
+ * @return
+ * @throws BirtException
+ */
+ private OdaDataSourceDesign newDataSource( ) throws BirtException
+ {
+ OdaDataSourceDesign dataSource = new OdaDataSourceDesign( "Data Source1" ); //$NON-NLS-1$
+ dataSource.setExtensionID( FlatFileDataSource.DATA_SOURCE_TYPE );
+ dataSource.addPrivateProperty( "HOME", ffds.HOME ); //$NON-NLS-1$
+ dataSource.addPrivateProperty( "CHARSET", FlatFileDataSource.CHARSET ); //$NON-NLS-1$
+ dataSource.addPrivateProperty( "DELIMTYPE", //$NON-NLS-1$
+ FlatFileDataSource.DELIMTYPE );
+ dataSource.addPrivateProperty( "INCLTYPELINE", //$NON-NLS-1$
+ FlatFileDataSource.INCLTYPELINE );
+ dataSource.addPrivateProperty( Constants.ODA_PROP_CONFIGURATION_ID,
+ dataSource.getExtensionID( )
+ + Constants.ODA_PROP_CONFIG_KEY_SEPARATOR
+ + dataSource.getName( ) );
+
+ return dataSource;
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSource.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSource.java
new file mode 100644
index 0000000..c48cb3d
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSource.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.dataengine;
+
+/**
+ * Resource of flat file data.
+ */
+public class FlatFileDataSource {
+ static final String DATA_SOURCE_TYPE = "org.eclipse.datatools.connectivity.oda.flatfile";
+ static final String DATA_SET_TYPE = "org.eclipse.datatools.connectivity.oda.flatfile.dataSet";
+ static final String CHARSET = "UTF-8";
+ static final String DELIMTYPE = "TAB";
+ static final String INCLTYPELINE = "NO";
+ protected String HOME = null;
+
+ protected String dataFile = "";
+ protected String query = "";
+ protected String[] columnsName = null;
+
+ public FlatFileDataSource(){
+ }
+
+ public FlatFileDataSource(String HOME,String dataFile,String query,String[] columns){
+ this.HOME = HOME;
+ this.dataFile = dataFile;
+ this.query = query;
+ this.columnsName = columns;
+ }
+
+ protected void setHOME_VARIABLE(String home){
+ HOME = home;
+ }
+
+ protected String getHOME(){
+ return HOME;
+ }
+
+ protected void setDataFile(String fileName){
+ dataFile = fileName;
+ }
+
+ protected String getDataFile(){
+ return dataFile;
+ }
+
+ protected void setQuery(String query){
+ this.query = query;
+ }
+
+ protected String getQuery(){
+ return query;
+ }
+
+ protected String[] getCOLUMNNAME(){
+ return columnsName;
+ }
+
+ protected void setCOLUMNName(String[] cn){
+ columnsName = cn;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSourceFactory.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSourceFactory.java
new file mode 100644
index 0000000..5f5d4a8
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/FlatFileDataSourceFactory.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.dataengine;
+
+public class FlatFileDataSourceFactory {
+ public FlatFileDataSourceFactory(){
+ }
+
+ public String createHomeVariable(){
+ return null;
+ }
+
+ public String createFileName(){
+ return null;
+
+ }
+
+ public String createQuery(){
+ return null;
+
+ }
+
+ public String[] createColumns(){
+ return null;
+ }
+
+ public FlatFileDataSource createFlatFileDataSource(){
+ return new FlatFileDataSource(createHomeVariable(),createFileName(),createQuery(),createColumns());
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/GroupedRowExpressionsEvaluator.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/GroupedRowExpressionsEvaluator.java
new file mode 100644
index 0000000..b56d135
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dataengine/GroupedRowExpressionsEvaluator.java
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Actuate Corporation.
+ * 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:
+ * Actuate Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.charts.dataengine;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.birt.chart.exception.ChartException;
+import org.eclipse.birt.chart.factory.AbstractGroupedDataRowExpressionEvaluator;
+import org.eclipse.birt.chart.log.ILogger;
+import org.eclipse.birt.chart.log.Logger;
+import org.eclipse.birt.core.exception.BirtException;
+import org.eclipse.birt.data.engine.api.IGroupDefinition;
+import org.eclipse.birt.data.engine.api.IResultIterator;
+
+/**
+ * The class implements an evaluator to retrieve grouped row data.
+ * @since 2.3
+ */
+public class GroupedRowExpressionsEvaluator extends
+ AbstractGroupedDataRowExpressionEvaluator
+{
+
+ private static ILogger sLogger = Logger.getLogger( "org.eclipse.birt.chart.examples/trace" ); //$NON-NLS-1$
+
+ private IResultIterator fResultIterator;
+
+ private boolean fIsGrouped = false;
+
+ private int fGroupCount;
+
+ private List[] faGroupBreaks;
+
+ private int fCountOfAvaiableRows = 0;
+
+ private boolean fHasAggregation = false;
+
+ /**
+ * Constructor.
+ *
+ * @param resultSet
+ * @param hasAggregation
+ * @param cm
+ * @throws ChartException
+ */
+ public GroupedRowExpressionsEvaluator( IResultIterator resultIterator,
+ boolean hasAggregation ) throws ChartException
+ {
+ fHasAggregation = hasAggregation;
+
+ fResultIterator = resultIterator;
+ List<IGroupDefinition> groupDefinitions = fResultIterator.getQueryResults( )
+ .getPreparedQuery( )
+ .getReportQueryDefn( )
+ .getGroups( );
+ if ( groupDefinitions != null && groupDefinitions.size( ) > 0 )
+ {
+ fIsGrouped = true;
+ fGroupCount = groupDefinitions.size( );
+
+ faGroupBreaks = new List[groupDefinitions.size( )];
+ for ( int i = 0; i < faGroupBreaks.length; i++ )
+ {
+ faGroupBreaks[i] = new ArrayList( );
+ }
+ }
+ }
+
+ /**
+ * Get list of group breaks, the group level is base on 0th index, 0 index
+ * means outermost group.
+ *
+ * @param groupLevel
+ * @return
+ */
+ private List getGroupBreaksList( int groupLevel )
+ {
+ if ( faGroupBreaks == null
+ || groupLevel < 0
+ || groupLevel > ( faGroupBreaks.length - 1 ) )
+ {
+ return new ArrayList( );
+ }
+
+ return faGroupBreaks[groupLevel];
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.birt.chart.factory.IGroupedDataResultSet#getGroupBreaks(int)
+ */
+ public int[] getGroupBreaks( int groupLevel )
+ {
+ Object[] breaksArray = getGroupBreaksList( groupLevel ).toArray( );
+ int[] breaks = new int[breaksArray.length];
+ for ( int i = 0; i < breaksArray.length; i++ )
+ {
+ breaks[i] = ( (Integer) breaksArray[i] ).intValue( );
+ }
+ return breaks;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator#close()
+ */
+ public void close( )
+ {
+ try
+ {
+ fResultIterator.close( );
+ }
+ catch ( BirtException e )
+ {
+ sLogger.log( e );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator#evaluate(java.lang.String)
+ */
+ public Object evaluate( String expression )
+ {
+ try
+ {
+ // Here, the expression should be binding name.
+ return fResultIterator.getValue( expression );
+ }
+ catch ( BirtException e )
+ {
+ sLogger.log( e );
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator#evaluateGlobal(java.lang.String)
+ */
+ public Object evaluateGlobal( String expression )
+ {
+ return evaluate( expression );
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator#first()
+ */
+ public boolean first( )
+ {
+ try
+ {
+ fCountOfAvaiableRows = 0;
+
+ if ( !fIsGrouped )
+ {
+ if ( fResultIterator.next( ) )
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if ( findFirst( ) )
+ {
+ return true;
+ }
+ }
+ }
+ catch ( BirtException e )
+ {
+ sLogger.log( e );
+ }
+ return false;
+ }
+
+ /**
+ * Find the first row position.
+ *
+ * @return
+ * @throws BirtException
+ */
+ private boolean findFirst( ) throws BirtException
+ {
+ if ( !fResultIterator.next( ) )
+ {
+ return false;
+ }
+
+ int groupLevel = fResultIterator.getStartingGroupLevel( );
+ if ( groupLevel == 0 ) // It means the start of current row data.
+ {
+ return true;
+ }
+ else
+ {
+ return findFirst( );
+ }
+ }
+
+ /**
+ * Find next available row position. If it has grouped-enabled, should
+ * ignore non-grouped/non-aggregation row.
+ *
+ * @return
+ * @throws BirtException
+ */
+ private boolean findNext( ) throws BirtException
+ {
+ while ( fResultIterator.next( ) )
+ {
+ int startIndex = fResultIterator.getStartingGroupLevel( );
+ if ( startIndex > 0 && startIndex <= fGroupCount )
+ {
+ fCountOfAvaiableRows++;
+ // Add break point to current grouping.
+ getGroupBreaksList( startIndex - 1 ).add( new Integer( fCountOfAvaiableRows ) );
+ // Also the sub-groupings of current grouping should be
+ // added the break point.
+ for ( int i = startIndex; i < fGroupCount; i++ )
+ {
+ getGroupBreaksList( i ).add( new Integer( fCountOfAvaiableRows ) );
+ }
+
+ return true;
+ }
+
+ if ( !fHasAggregation )
+ {
+ fCountOfAvaiableRows++;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator#next()
+ */
+ public boolean next( )
+ {
+ try
+ {
+ if ( !fIsGrouped )
+ {
+ if ( fResultIterator.next( ) )
+ {
+ fCountOfAvaiableRows++;
+ return true;
+ }
+ }
+ else
+ {
+ return findNext( );
+ }
+ }
+ catch ( BirtException e )
+ {
+ sLogger.log( e );
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dialogs/ChartDialog.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dialogs/ChartDialog.java
new file mode 100755
index 0000000..76be33e
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/dialogs/ChartDialog.java
@@ -0,0 +1,427 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.dialogs;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.charts.Activator;
+import org.eclipse.linuxtools.dataviewers.charts.ChartConstants;
+import org.eclipse.linuxtools.dataviewers.charts.provider.ChartFactory;
+import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * The dialog used to customize the chart before cerating it.
+ */
+public class ChartDialog extends Dialog {
+
+ private final AbstractSTViewer stViewer;
+ private Chart chart;
+
+ private Text errorMessageText;
+ private Button verticalBarsButton;
+ private Button pieChartButton;
+ private Button barGraphButton;
+ private Button okButton;
+ private List<Button> columnButtons;
+
+ /**
+ * The constructor
+ *
+ * @param shell
+ * @param stViewer
+ */
+ public ChartDialog(Shell shell, AbstractSTViewer stViewer)
+ {
+ super(shell);
+ this.stViewer = stViewer;
+ }
+
+ /**
+ * Restores the state of this dialog
+ */
+ public void restoreState() {
+ try {
+ IDialogSettings settings =
+ stViewer.getViewerSettings().getSection(ChartConstants.TAG_SECTION_BIRTCHARTS_STATE);
+ if (settings == null) {
+ settings = stViewer.getViewerSettings().addNewSection(ChartConstants.TAG_SECTION_BIRTCHARTS_STATE);
+ return;
+ }
+
+ for (int i=0; i<columnButtons.size(); i++) {
+ boolean selected = Boolean.parseBoolean(settings.get(ChartConstants.TAG_COLUMN_BUTTON_+i));
+ columnButtons.get(i).setSelection(selected);
+ }
+
+ boolean barGraph = Boolean.parseBoolean(settings.get(ChartConstants.TAG_BAR_GRAPH_BUTTON));
+ barGraphButton.setSelection(barGraph);
+ pieChartButton.setSelection(!barGraph);
+
+ boolean vBars = Boolean.parseBoolean(settings.get(ChartConstants.TAG_VERTICAL_BARS_BUTTON));
+ verticalBarsButton.setSelection(vBars);
+ verticalBarsButton.setEnabled(barGraph);
+ }
+ catch (Exception e) {}
+ }
+
+ /**
+ * Saves the state of this dialog
+ */
+ public void saveState() {
+ try {
+ IDialogSettings settings =
+ stViewer.getViewerSettings().getSection(ChartConstants.TAG_SECTION_BIRTCHARTS_STATE);
+ if (settings == null) {
+ settings = stViewer.getViewerSettings().addNewSection(ChartConstants.TAG_SECTION_BIRTCHARTS_STATE);
+ }
+
+ for (int i=0; i<columnButtons.size(); i++) {
+ boolean selected = columnButtons.get(i).getSelection();
+ settings.put(ChartConstants.TAG_COLUMN_BUTTON_+i, selected);
+ }
+
+ boolean barGraph = barGraphButton.getSelection();
+ settings.put(ChartConstants.TAG_BAR_GRAPH_BUTTON, barGraph);
+
+ boolean vBars = verticalBarsButton.getSelection();
+ settings.put(ChartConstants.TAG_VERTICAL_BARS_BUTTON, vBars);
+ }
+ catch (Exception e) {}
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Create chart from selection...");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+ chart = produceChart();
+ saveState();
+ } else {
+ chart = null;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ // create OK and Cancel buttons by default
+ okButton = createButton(parent, IDialogConstants.OK_ID,
+ IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID,
+ IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Control c = super.createContents(parent);
+ this.validateInput();
+ return c;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite)super.createDialogArea(parent);
+
+ Composite titleComp = new Composite(composite, SWT.NONE);
+ titleComp.setLayout(new RowLayout(SWT.HORIZONTAL));
+
+ Label icon = new Label(titleComp, SWT.NONE);
+ icon.setImage(Activator.getImage("icons/chart_icon.png"));
+
+ Label label = new Label(titleComp, SWT.WRAP);
+ label.setText("Chart builder");
+ GridData data = new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_CENTER);
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+ titleComp.setLayoutData(data);
+
+ Group chartTypeGroup = new Group(composite, SWT.NONE);
+ data = new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_FILL);
+ chartTypeGroup.setLayoutData(data);
+ chartTypeGroup.setLayout(new GridLayout(2, false));
+ chartTypeGroup.setText("Select your chart type");
+
+ ValidateSelectionListener listener = new ValidateSelectionListener();
+
+ barGraphButton = new Button(chartTypeGroup, SWT.RADIO);
+ barGraphButton.setText("Bar graph");
+ barGraphButton.addSelectionListener(listener);
+ barGraphButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ verticalBarsButton.setEnabled(barGraphButton.getSelection());
+ }
+ });
+ data = new GridData();
+ barGraphButton.setLayoutData(data);
+
+ verticalBarsButton = new Button(chartTypeGroup, SWT.CHECK);
+ verticalBarsButton.setText("Vertical bars");
+ data = new GridData();
+ verticalBarsButton.setLayoutData(data);
+
+ pieChartButton = new Button(chartTypeGroup, SWT.RADIO);
+ pieChartButton.setText("Pie chart");
+ pieChartButton.addSelectionListener(listener);
+ data = new GridData();
+ data.horizontalSpan = 2;
+ pieChartButton.setLayoutData(data);
+
+ Group chartColumnGroup = new Group(composite, SWT.NONE);
+ chartColumnGroup.setLayout(new GridLayout(1,true));
+ data = new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_FILL);
+ chartColumnGroup.setLayoutData(data);
+ chartColumnGroup.setText("Select the columns(s) to show");
+
+ addColumnButtons(chartColumnGroup, listener);
+
+ errorMessageText = new Text(composite, SWT.READ_ONLY);
+ errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_FILL));
+ errorMessageText.setBackground(errorMessageText.getDisplay()
+ .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+
+ applyDialogFont(composite);
+
+ setWidgetsValues();
+
+ return composite;
+ }
+
+ /**
+ * Sets the widgets values
+ */
+ private void setWidgetsValues() {
+ // set default values
+ barGraphButton.setSelection(ChartConstants.DEFAULT_BAR_GRAPH_BUTTON);
+ verticalBarsButton.setEnabled(barGraphButton.getSelection());
+ verticalBarsButton.setSelection(ChartConstants.DEFAULT_VERTICAL_BARS_BUTTON);
+ for (Button button : columnButtons) {
+ button.setSelection(ChartConstants.DEFAULT_COLUMN_BUTTON);
+ }
+
+ // restore state if there is one saved
+ restoreState();
+ }
+
+ /**
+ * Adds one check button for each column implementing the IChartField interface.
+ *
+ * @see IChartField
+ * @param comp
+ * @param listener
+ */
+ private void addColumnButtons(Composite comp, SelectionListener listener)
+ {
+ columnButtons = new LinkedList<Button>();
+ for (ISTDataViewersField field : stViewer.getAllFields())
+ {
+ if (field instanceof IChartField) {
+ IChartField cField = (IChartField)field;
+ Button b = new Button(comp,SWT.CHECK);
+ b.setText(cField.getColumnHeaderText());
+ b.setData(cField);
+ b.addSelectionListener(listener);
+ GridData dt = new GridData();
+ b.setLayoutData(dt);
+ columnButtons.add(b);
+ }
+ }
+
+ Label sep = new Label(comp, SWT.SEPARATOR|SWT.HORIZONTAL);
+ GridData data = new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_FILL);
+ sep.setLayoutData(data);
+ Composite buttonComposite = new Composite(comp,SWT.NONE);
+ data = new GridData();
+ buttonComposite.setLayoutData(data);
+ FillLayout l = new FillLayout();
+ l.spacing = 5;
+ buttonComposite.setLayout(l);
+
+ final Button b1 = new Button(buttonComposite, SWT.PUSH);
+ b1.setText("Select all");
+ final Button b2 = new Button(buttonComposite, SWT.PUSH);
+ b2.setText("Deselect all");
+ SelectionListener sl = new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e)
+ {
+ boolean b = (e.getSource() == b1);
+ for (Button button : columnButtons) {
+ button.setSelection(b);
+ }
+ validateInput();
+ }
+ };
+ b1.addSelectionListener(sl);
+ b2.addSelectionListener(sl);
+ }
+
+ /**
+ * Returns the Chart built by this dialog
+ *
+ * @return the chart
+ */
+ public Chart getValue() {
+ return chart;
+ }
+
+ /**
+ * Validates the input.
+ * <p>
+ * The default implementation of this framework method delegates the request
+ * to the supplied input validator object; if it finds the input invalid,
+ * the error message is displayed in the dialog's message line. This hook
+ * method is called whenever the text changes in the input field.
+ * </p>
+ */
+ protected void validateInput() {
+ String errorMessage = null;
+
+ int selectedNum = 0;
+ for (Button button : columnButtons) {
+ if (button.getSelection()) selectedNum++;
+ }
+
+ if (selectedNum == 0)
+ {
+ errorMessage = "No column selected";
+ }
+ /*else if (pieChartButton.getSelection() && selectedNum != 1)
+ {
+ errorMessage = "PieChart: Please select only one column";
+ }*/
+
+ // Bug 16256: important not to treat "" (blank error) the same as null
+ // (no error)
+ setErrorMessage(errorMessage);
+ }
+
+ /**
+ * Sets or clears the error message.
+ * If not <code>null</code>, the OK button is disabled.
+ *
+ * @param errorMessage
+ * the error message, or <code>null</code> to clear
+ * @since 3.0
+ */
+ public void setErrorMessage(String errorMessage) {
+ errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$
+ okButton.setEnabled(errorMessage == null);
+ errorMessageText.getParent().update();
+ }
+
+ /**
+ * Build the chart from configuration
+ *
+ * @return a new chart
+ */
+ private Chart produceChart()
+ {
+ IStructuredSelection selection = (IStructuredSelection)stViewer.getViewer().getSelection();
+ if (selection == StructuredSelection.EMPTY) return null;
+ Object[] objects = selection.toArray();
+
+ ISTDataViewersField labelField = getLabelField(stViewer);
+
+
+ List<IChartField> selectedFields = new ArrayList<IChartField>();
+ for (Button button : columnButtons) {
+ if (button.getSelection()) {
+ selectedFields.add((IChartField)button.getData());
+ }
+ }
+ boolean barChartType = barGraphButton.getSelection();
+ boolean horizontalBars = !verticalBarsButton.getSelection();
+
+ if (barChartType) {
+ return ChartFactory.produceBarChart(objects, labelField, selectedFields, getBarChartTitle(),horizontalBars);
+ }
+ else {
+ return ChartFactory.producePieChart(objects, labelField, selectedFields);
+ }
+ }
+
+ private class ValidateSelectionListener extends SelectionAdapter
+ {
+ public void widgetSelected(SelectionEvent e) {
+ validateInput();
+ }
+ };
+
+ /**
+ * @param viewer
+ * @return the field used to provide the labels to the series
+ */
+ protected ISTDataViewersField getLabelField(AbstractSTViewer viewer) {
+ return viewer.getAllFields()[0];
+ }
+
+ protected String getBarChartTitle(){
+ return "Bar Chart";
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java
new file mode 100755
index 0000000..89b0310
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.ChartWithAxes;
+import org.eclipse.birt.chart.model.ChartWithoutAxes;
+import org.eclipse.birt.chart.model.attribute.ActionType;
+import org.eclipse.birt.chart.model.attribute.AxisType;
+import org.eclipse.birt.chart.model.attribute.ChartDimension;
+import org.eclipse.birt.chart.model.attribute.IntersectionType;
+import org.eclipse.birt.chart.model.attribute.Position;
+import org.eclipse.birt.chart.model.attribute.TickStyle;
+import org.eclipse.birt.chart.model.attribute.TriggerCondition;
+import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl;
+import org.eclipse.birt.chart.model.attribute.impl.GradientImpl;
+import org.eclipse.birt.chart.model.attribute.impl.TooltipValueImpl;
+import org.eclipse.birt.chart.model.component.Axis;
+import org.eclipse.birt.chart.model.component.Series;
+import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
+import org.eclipse.birt.chart.model.data.NumberDataSet;
+import org.eclipse.birt.chart.model.data.SeriesDefinition;
+import org.eclipse.birt.chart.model.data.TextDataSet;
+import org.eclipse.birt.chart.model.data.Trigger;
+import org.eclipse.birt.chart.model.data.impl.ActionImpl;
+import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
+import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
+import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl;
+import org.eclipse.birt.chart.model.data.impl.TriggerImpl;
+import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
+import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl;
+import org.eclipse.birt.chart.model.layout.Legend;
+import org.eclipse.birt.chart.model.layout.Plot;
+import org.eclipse.birt.chart.model.type.BarSeries;
+import org.eclipse.birt.chart.model.type.PieSeries;
+import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl;
+import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+
+/**
+ * A utility class that handles the charts creation (pie chart & bar chart)
+ *
+ * @author Marzia Maugeri <marzia.maugeri@st.com>
+ *
+ */
+public class ChartFactory {
+
+ /**
+ * Produces a 3D pie chart from the input objects.
+ *
+ * @param objects the input data
+ * @param nameField the field used to get the labels of the objects (colored parts in the pie).
+ * @param valField the field providing the values for the pie parts.
+ * @return a new 3D pie chart
+ */
+ public static final Chart producePieChart(Object[] objects, ISTDataViewersField nameField, List<IChartField> valFields)
+ {
+ ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
+ cwoaPie.setSeriesThickness( 20 );
+ cwoaPie.setGridColumnCount( valFields.size());
+ cwoaPie.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
+
+ //2D dimensional with DEPTH (birt DOESN'T SUPPORT 3D for Pie Chart)
+ cwoaPie.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL);
+
+ // Plot
+ Plot p = cwoaPie.getPlot( );
+ p.getClientArea( ).setBackground( null );
+ p.getClientArea( ).getOutline( ).setVisible( true );
+ p.getOutline( ).setVisible( true );
+
+ // Legend
+ Legend lg = cwoaPie.getLegend( );
+ lg.getText( ).getFont( ).setSize( 16 );
+ lg.setBackground( null );
+ lg.getOutline( ).setVisible( true );
+
+ // Title
+ cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue( nameField.getColumnHeaderText());
+ cwoaPie.getTitle( ).getOutline( ).setVisible( true );
+
+ //Base Data Set
+ List<String> textLabels = new ArrayList<String>();
+ for (Object obj : objects) {
+ String label = nameField.getValue(obj);
+ textLabels.add(label);
+ }
+ TextDataSet categoryValues = TextDataSetImpl.create(textLabels );
+
+ // Base Series
+ Series seCategory = SeriesImpl.create( );
+ seCategory.setDataSet( categoryValues );
+
+ SeriesDefinition sdBase = SeriesDefinitionImpl.create( );
+ cwoaPie.getSeriesDefinitions( ).add( sdBase );
+ sdBase.getSeriesPalette( ).shift( -1 );
+ sdBase.getSeries( ).add( seCategory );
+
+ SeriesDefinition sdValue = SeriesDefinitionImpl.create( );
+ sdBase.getSeriesDefinitions( ).add( sdValue );
+
+
+ for (IChartField field : valFields) {
+ List<Double> doubleValues = new ArrayList<Double>();
+ for (Object obj : objects) {
+ doubleValues.add(field.getNumber(obj).doubleValue());
+ }
+
+ NumberDataSet Values = NumberDataSetImpl.create(doubleValues);
+
+ // Pie Series
+ PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
+ sePie.setSeriesIdentifier( field.getColumnHeaderText());
+ sePie.setExplosion(3);
+ sePie.setDataSet( Values );
+
+ //Mouse over the Serie to Show Tooltips
+ setTriggering(sePie);
+
+ sdValue.getSeries( ).add( sePie);
+ }
+
+
+ return cwoaPie;
+ }
+
+ /**
+ * Produces a 2D bar chart from the input objects.
+ *
+ * @param objects the input data
+ * @param nameField the field used to get the labels of the objects (the labels of the series groups).
+ * @param valFields the fields providing the values for the different bars in a series group.
+ * @param horizontal if true the bars are displayed horizontally, else vertically.
+ * @return a new 2D bar chart
+ */
+
+ public static final Chart produceBarChart( Object[] objects, final ISTDataViewersField nameField, List<IChartField> valFields, String title,boolean horizontal)
+ {
+ ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
+
+ // Plot
+ cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
+ Plot p = cwaBar.getPlot( );
+ p.getClientArea( )
+ .setBackground( GradientImpl.create( ColorDefinitionImpl.create( 225,
+ 225,
+ 255 ),
+ ColorDefinitionImpl.create( 255, 255, 225 ),
+ -35,
+ false ) );
+ p.getOutline( ).setVisible( true );
+
+ // Title
+ cwaBar.getTitle( ).getLabel( ).getCaption( ).setValue(title);
+ cwaBar.getTitle( ).getOutline( ).setVisible( true );
+
+ //Orientation
+ if (horizontal) cwaBar.setTransposed(true);
+
+ // Legend
+ Legend lg = cwaBar.getLegend( );
+ lg.getText( ).getFont( ).setSize( 16 );
+
+ // X-Axis
+ Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
+ xAxisPrimary.getTitle( ).setVisible( true );
+ xAxisPrimary.setTitlePosition( Position.BELOW_LITERAL );
+ xAxisPrimary.setType( AxisType.TEXT_LITERAL );
+ xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
+ xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
+ xAxisPrimary.setLabelPosition( Position.BELOW_LITERAL );
+ xAxisPrimary.getTitle().getCaption( ).setValue(nameField.getColumnHeaderText());
+
+ // Y-Axis
+ Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
+ yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
+
+
+ double max = -1D;
+ List<String> textLabels = new ArrayList<String>();
+ for (Object obj : objects) {
+ String label = nameField.getValue(obj);
+ textLabels.add(label);
+ }
+ TextDataSet categoryValues = TextDataSetImpl.create(textLabels );
+ SeriesDefinition sdY = SeriesDefinitionImpl.create( );
+ sdY.getSeriesPalette( ).shift( -1 );
+
+ yAxisPrimary.getSeriesDefinitions( ).add( sdY );
+
+ // Data Set
+ for (IChartField field : valFields) {
+ List<Double> doubleValues = new ArrayList<Double>();
+ for (Object obj : objects) {
+
+ Number num = field.getNumber(obj);
+ double longVal = num.doubleValue();
+ max = longVal > max ? longVal : max;
+ doubleValues.add(longVal);
+ }
+
+ NumberDataSet orthoValues = NumberDataSetImpl.create(doubleValues);
+ // Y-Series
+ BarSeries bs = (BarSeries) BarSeriesImpl.create( );
+ bs.setSeriesIdentifier( field.getColumnHeaderText() );
+ bs.setDataSet( orthoValues );
+ bs.setRiserOutline( null );
+
+ //Mouse over the Serie to Show Tooltips
+ setTriggering(bs);
+
+ sdY.getSeries( ).add( bs );
+ }
+
+ // X-Series
+ Series seCategory = SeriesImpl.create( );
+ seCategory.setDataSet( categoryValues );
+ SeriesDefinition sdX = SeriesDefinitionImpl.create( );
+ xAxisPrimary.getSeriesDefinitions( ).add( sdX );
+ sdX.getSeries( ).add( seCategory );
+
+ return cwaBar;
+ }
+
+ /**
+ * @param viewer
+ * @return the field used to provide the labels to the series
+ */
+ public ISTDataViewersField getLabelField(AbstractSTViewer viewer) {
+ return viewer.getAllFields()[0];
+ }
+
+ public static void setTriggering(Series series){
+ //Mouse over the Serie to Show Tooltips
+ Trigger tr = TriggerImpl.create(TriggerCondition.ONMOUSEOVER_LITERAL,
+ ActionImpl.create(ActionType.SHOW_TOOLTIP_LITERAL, TooltipValueImpl.create(200, null)));
+ series.getTriggers().add(tr);
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartUpdateNotifier.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartUpdateNotifier.java
new file mode 100644
index 0000000..c3504df
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartUpdateNotifier.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.provider;
+
+import org.eclipse.birt.chart.device.EmptyUpdateNotifier;
+import org.eclipse.birt.chart.device.ICallBackNotifier;
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.attribute.CallBackValue;
+import org.eclipse.swt.widgets.Canvas;
+
+/**
+ * @author Marzia Maugeri <marzia.maugeri@st.com>
+ */
+
+public class ChartUpdateNotifier extends EmptyUpdateNotifier implements ICallBackNotifier{
+ private Canvas preview = null;
+
+ public ChartUpdateNotifier(Canvas preview,Chart designModel, Chart runtimeModel) {
+ super(designModel, runtimeModel);
+ this.preview = preview;
+ }
+
+ public Object peerInstance( )
+ {
+ return preview;
+ }
+
+ @Override
+ public void callback(Object event, Object source, CallBackValue value) {
+
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/IChartField.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/IChartField.java
new file mode 100755
index 0000000..967c58b
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/IChartField.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.provider;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+
+/**
+ * The interface used by the charts to get a <code>Number</code> data from a field.
+ *
+ * @author Marzia Maugeri <marzia.maugeri@st.com>
+ *
+ */
+public interface IChartField extends ISTDataViewersField {
+
+ /**
+ * Returns the number to display in the chart for this object.
+ *
+ * @param obj
+ * @return the corresponding number value
+ */
+ public Number getNumber(Object obj);
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/view/ChartView.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/view/ChartView.java
new file mode 100755
index 0000000..b23913f
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/view/ChartView.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.view;
+
+
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.linuxtools.dataviewers.charts.Activator;
+import org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction;
+import org.eclipse.linuxtools.dataviewers.charts.actions.SaveXMLAction;
+import org.eclipse.linuxtools.dataviewers.charts.viewer.ChartViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * The chart view.
+ *
+ * <br/>This view is multiple and all the created chart will be displayed in an instance of this view.
+ * Each one will have a primary id equals to ChartView.VIEW_ID and an integer (increased by 1 at each new view) for the secondary id.
+ *
+ * @author Marzia Maugeri <marzia.maugeri@st.com>
+ *
+ */
+public class ChartView extends ViewPart {
+
+ /** The primary id of this view */
+ public static final String VIEW_ID = "org.eclipse.linuxtools.dataviewers.charts.view";
+
+ /** The current secondary id for these views */
+ private static Integer SEC_ID = 0;
+
+ private Canvas paintCanvas;
+
+ private ChartViewer chartViewer;
+
+ private SaveChartAction saveChartAction;
+
+ private SaveXMLAction saveXMLAction;
+
+
+
+ /**
+ * Create and open a new chart view
+ * <br/>
+ * <br/><u><b>Note</b></u>: this method uses the UI thread to open the view and then it sets the input chart.
+ * The UI thread execution is synchronized on internal Integer SEC_ID which is the secondary id of the chart view.
+ * Each new chart view has a secondary id equal to SEC_ID++.
+ *
+ * @param chart
+ */
+ public static void createChartView(final Chart chart) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ try {
+ synchronized(SEC_ID) {
+ ChartView view = (ChartView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(VIEW_ID, ""+(SEC_ID++), IWorkbenchPage.VIEW_ACTIVATE);
+ view.setChart(chart);
+
+ }
+ } catch (PartInitException e) {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ e.getMessage(),
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+ });
+
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ try {
+ paintCanvas = new Canvas( parent, SWT.NONE );
+ paintCanvas.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ paintCanvas.setBackground( Display.getDefault( )
+ .getSystemColor( SWT.COLOR_WHITE ) );
+ chartViewer = new ChartViewer( );
+ paintCanvas.addPaintListener( chartViewer );
+ paintCanvas.addControlListener( chartViewer );
+ chartViewer.setViewer( paintCanvas );
+
+
+ createActions(parent);
+ IActionBars actionBars = getViewSite().getActionBars();
+ initToolBar(actionBars.getToolBarManager());
+
+ } catch (Throwable _)
+ {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ "Error when creating AWT Frame...",
+ _);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+
+ protected void createActions(Composite parent) {
+ saveChartAction = new SaveChartAction(getViewSite().getShell(),this);
+ saveXMLAction = new SaveXMLAction(parent);
+ //openChartAction = new OpenChartAction(getViewSite().getShell(),this);
+ }
+
+ protected void initToolBar(IToolBarManager manager) {
+ manager.add(saveChartAction);
+ manager.add(saveXMLAction);
+ //manager.add(openChartAction);
+ manager.update(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ if (paintCanvas != null) {
+ paintCanvas.setFocus();
+ } else {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ "Error setting the focus to the chart view: main composite is not set!");
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+
+ /**
+ * Close this view
+ * <br/>
+ * <br/><u><b>Note</b></u>: it uses the UI thread to get the workbench window. Then it closes the view.
+ */
+ public void closeView() {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(ChartView.this);
+ }
+ });
+ }
+
+ /**
+ * Set the chart in this view
+ *
+ * @param chart
+ */
+ public void setChart(Chart chart) {
+ if (chart != null) {
+ chartViewer.renderModel(chart);
+ saveChartAction.setChart(chart);
+ saveChartAction.setBounds(chartViewer.getBounds());
+ saveXMLAction.setChart(chart);
+
+ } else {
+ saveChartAction.setEnabled(false);
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ "Error adding the chart to the chart view: SWT is not set!");
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+
+ public ChartViewer getChartViewer(){
+ return chartViewer;
+ }
+
+ public void setChartViewer(ChartViewer cv){
+ chartViewer = cv;
+ }
+
+ public void dispose( )
+ {
+ super.dispose( );
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/viewer/ChartViewer.java b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/viewer/ChartViewer.java
new file mode 100755
index 0000000..69989b1
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/viewer/ChartViewer.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ad * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.charts.viewer;
+
+import org.eclipse.birt.chart.device.IDeviceRenderer;
+import org.eclipse.birt.chart.exception.ChartException;
+import org.eclipse.birt.chart.factory.GeneratedChartState;
+import org.eclipse.birt.chart.factory.Generator;
+import org.eclipse.birt.chart.model.Chart;
+import org.eclipse.birt.chart.model.attribute.Bounds;
+import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
+import org.eclipse.birt.chart.util.PluginSettings;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.dataviewers.charts.Activator;
+import org.eclipse.linuxtools.dataviewers.charts.actions.ChartActionRenderer;
+import org.eclipse.linuxtools.dataviewers.charts.provider.ChartUpdateNotifier;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ *
+ * @author Marzia Maugeri <marzia.maugeri@st.com>
+ *
+ */
+public class ChartViewer implements PaintListener, ControlListener
+{
+
+ private transient Canvas preview = null;
+
+ private Chart cm = null;
+
+ private transient boolean bIsPainting = false;
+
+ private transient Image buffer;
+
+ private static int X_OFFSET = 3;
+
+ private static int Y_OFFSET = 3;
+
+ private GeneratedChartState gcs = null;
+
+ private IDeviceRenderer deviceRenderer = null;
+
+ private Bounds bo;
+
+ public ChartViewer( )
+ {
+ try {
+ deviceRenderer = PluginSettings.instance( ).getDevice( "dv.SWT" );
+ } catch (ChartException e) {
+ Status s = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ Status.ERROR,
+ e.getMessage(),
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+
+ }
+ /**
+ * @param cm
+ * Chart Model
+ */
+ public void renderModel( Chart cm )
+ {
+ this.cm = cm;
+
+ if ( preview != null && !preview.isDisposed( ) )
+ {
+ updateBuffer( );
+ preview.redraw( );
+ }
+ }
+
+ public Bounds getBounds()
+ {
+ return bo;
+ }
+
+ public Chart getChart(){
+ return cm;
+ }
+
+ /**
+ * Generate and render the chart model,the chart image is stored in a
+ * buffer. The buffer will be updated only when the chart model is changed.
+ */
+ private void updateBuffer( )
+ {
+ if ( bIsPainting )
+ {
+ return;
+ }
+ Throwable paintError = null;
+
+ Rectangle re = preview.getClientArea( );
+ final Rectangle adjustedRe = new Rectangle( 0, 0, re.width, re.height );
+
+ if ( adjustedRe.width - 2 * X_OFFSET <= 0
+ || adjustedRe.height - 2 * Y_OFFSET <= 0 )
+ {
+ if ( buffer != null && !buffer.isDisposed( ) )
+ {
+ buffer.dispose( );
+ buffer = null;
+ }
+ return;
+ }
+
+ if ( cm == null )
+ {
+ buffer = null;
+ }
+ else
+ {
+ bIsPainting = true;
+ Image oldBuffer = null;
+ if ( buffer == null )
+ {
+ buffer = new Image( Display.getDefault( ), adjustedRe );
+ }
+ else
+ {
+ Rectangle ore = buffer.getBounds( );
+
+ oldBuffer = buffer;
+
+ if ( !adjustedRe.equals( ore ) )
+ {
+ buffer = new Image( Display.getDefault( ), adjustedRe );
+ }
+ }
+
+ GC gc = new GC( buffer );
+
+ // fill default background as white.
+ gc.setForeground( Display.getDefault( )
+ .getSystemColor( SWT.COLOR_WHITE ) );
+ gc.fillRectangle( buffer.getBounds( ) );
+
+ bo = BoundsImpl.create( X_OFFSET,
+ Y_OFFSET,
+ adjustedRe.width - 2 * X_OFFSET,
+ adjustedRe.height - 2 * Y_OFFSET );
+
+
+ try
+ {
+ deviceRenderer.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT,gc );
+
+ bo.scale( 72d / deviceRenderer.getDisplayServer( )
+ .getDpiResolution( ) ); // CONVERT TO POINTS
+
+ // GENERATE AND RENDER THE CHART
+ final Generator gr = Generator.instance( );
+
+ gcs = gr.build(deviceRenderer.getDisplayServer( ), cm, bo, null, null, null);
+ gcs.getRunTimeContext().setActionRenderer( new ChartActionRenderer());
+ deviceRenderer.setProperty(IDeviceRenderer.UPDATE_NOTIFIER,
+ new ChartUpdateNotifier(preview,cm, gcs.getChartModel()));
+ gr.render(deviceRenderer, gcs);
+ }
+ catch ( Exception ex )
+ {
+ paintError = ex;
+ }
+
+ if ( paintError != null )
+ {
+ buffer = oldBuffer;
+ }
+ if ( oldBuffer != null && oldBuffer != buffer )
+ {
+ oldBuffer.dispose( );
+ }
+ bIsPainting = false;
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
+ */
+ public void paintControl( PaintEvent pe )
+ {
+ GC gc = pe.gc;
+ if ( buffer != null )
+ {
+ gc.drawImage( buffer, 0, 0 );
+ }
+ }
+
+ /**
+ * Set the preview canvas.
+ *
+ * @param paintCanvas
+ */
+ public void setViewer( Canvas paintCanvas )
+ {
+ this.preview = paintCanvas;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent)
+ */
+ public void controlMoved( ControlEvent e )
+ {
+ if ( preview != null && !preview.isDisposed( ) )
+ {
+ updateBuffer( );
+ preview.redraw( );
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent)
+ */
+ public void controlResized( ControlEvent e )
+ {
+ if ( preview != null && !preview.isDisposed( ) )
+ {
+ updateBuffer( );
+ preview.redraw( );
+ }
+ }
+
+ public void setBuffer(Image buffer){
+ this.buffer = buffer;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/.classpath b/org.eclipse.linuxtools.dataviewers/.classpath
new file mode 100644
index 0000000..2fbdb2c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/.classpath
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+ <accessrules>
+ <accessrule kind="accessible" pattern="*"/>
+ </accessrules>
+ </classpathentry>
+ <classpathentry excluding="**/.svn/**" kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.dataviewers/.project b/org.eclipse.linuxtools.dataviewers/.project
new file mode 100644
index 0000000..f72206c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.dataviewers</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..218fae9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,74 @@
+#Fri Jun 26 14:14:03 CEST 2009
+eclipse.preferences.version=1
+instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..50d9303
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Tue Jun 03 09:40:43 CEST 2008
+eclipse.preferences.version=1
+internal.default.compliance=default
diff --git a/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3e9ece0
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.dataviewers;singleton:=true
+Bundle-Version: 4.0.0.qualifier
+Bundle-Activator: org.eclipse.linuxtools.dataviewers.STDataViewersActivator
+Bundle-Vendor: %bundleProvider
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.jface.text,
+ org.eclipse.ui.workbench.texteditor
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.dataviewers,
+ org.eclipse.linuxtools.dataviewers.abstractview,
+ org.eclipse.linuxtools.dataviewers.abstractviewers,
+ org.eclipse.linuxtools.dataviewers.actions,
+ org.eclipse.linuxtools.dataviewers.dialogs,
+ org.eclipse.linuxtools.dataviewers.findreplace,
+ org.eclipse.linuxtools.dataviewers.listeners
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Localization: plugin
diff --git a/org.eclipse.linuxtools.dataviewers/about.html b/org.eclipse.linuxtools.dataviewers/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers/build.properties b/org.eclipse.linuxtools.dataviewers/build.properties
new file mode 100644
index 0000000..fcb28d6
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/build.properties
@@ -0,0 +1,23 @@
+<<<<<<< .working
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ plugin.properties,\
+ doc/
+src.includes = META-INF/,\
+ doc/,\
+ icons/,\
+ plugin.properties,\
+ src/
+=======
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ icons/,\
+ about.html,\
+ plugin.properties
+>>>>>>> .merge-right.r1063
diff --git a/org.eclipse.linuxtools.dataviewers/doc/AbstractSTProfViewers.ppt b/org.eclipse.linuxtools.dataviewers/doc/AbstractSTProfViewers.ppt
new file mode 100644
index 0000000..8f2712c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/doc/AbstractSTProfViewers.ppt
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/doc/DataViewersFind.html b/org.eclipse.linuxtools.dataviewers/doc/DataViewersFind.html
new file mode 100644
index 0000000..fdd6d72
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/doc/DataViewersFind.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
+ <title>DataViewersFind</title>
+</head>
+<body style="color: rgb(0, 0, 0); background-color: rgb(204, 255, 255);"
+ alink="#ee0000" link="#0000ee" vlink="#551a8b">
+<div style="text-align: center;">
+<h3><span style="color: rgb(204, 0, 0);">DATA VIEWERS FIND <br>
+</span></h3>
+<div style="text-align: left;"><small>The package
+"org.eclipse.linuxtools.dataviewers.findreplace" added into the plugin
+"org.eclipse.linuxtools.dataviewers" allows to enable the "FIND" action of the standard
+workbench adapting to the dataviewers.<br>
+If the developer want to use this new feature, he has to create an
+instance of the interface</small><span style="font-weight: bold;"> I</span><span
+ style="font-weight: bold;">STFindReplaceTarget</span><small>.<br>
+The interface </small><big><small><span style="font-weight: bold;">I</span><span
+ style="font-weight: bold;">STFindReplaceTarget</span></small><small><small>&nbsp;
+adapts&nbsp; the original IFindReplaceTarget to the dataviewers. In
+particular way, it uses&nbsp; the class&nbsp; </small><big><small><span
+ style="font-weight: bold;">ViewerCell</span><small> to get the
+searched string position into the dataviewer.</small><br>
+<br>
+<small>There are two classes that implement ISTFindReplaceTarget:<br>
+</small></small></big></small></big>
+<ul>
+ <li><small>STTableFindReplaceTarget and extends AbstractSTTableViewer<br>
+ </small></li>
+ <li><small>STTreeFindReplaceTarget and extends AbstractSTTreeViewer</small></li>
+</ul>
+</div>
+<div style="text-align: left;"><small>Both have to extend an
+AbstractSTViewer because the "FIND" targert work on a viewer.<br>
+When a developer want to use the "FIND", he has to create your customer
+data viewer extending:<br>
+</small>
+<ul>
+ <li><small>&nbsp;STTableFindReplaceTarget for the
+AbstractSTTableViewer</small><br>
+ </li>
+</ul>
+<small>or<br>
+</small>
+<ul>
+ <li><small>STTreeFindReplaceTarget for the AbstractSTTreeViewer</small><br>
+ </li>
+</ul>
+<div style="text-align: center;">
+<h3><span style="color: rgb(204, 0, 0);">Briefly</span></h3>
+<div style="text-align: left;"><small>In order to enable the "FIND"
+action, the developer has to:<br>
+</small>
+<ul>
+ <li><small><small><span style="font-weight: bold; font-style: italic;">create
+an instance of&nbsp; ISTFindReplaceTarget doing the overrideing of
+createSTFindReplaceTarget() into the AbstractSTDataView</span></small></small></li>
+ <li><small><small><span style="font-weight: bold; font-style: italic;">extend
+your custom viewer with STTableFindReplaceTarget or
+STTreeFindReplaceTargert</span></small></small></li>
+</ul>
+</div>
+<br>
+</div>
+</div>
+</div>
+</body>
+</html>
diff --git a/org.eclipse.linuxtools.dataviewers/icons/backward_nav.gif b/org.eclipse.linuxtools.dataviewers/icons/backward_nav.gif
new file mode 100644
index 0000000..4fb4150
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/backward_nav.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/bin_obj.gif b/org.eclipse.linuxtools.dataviewers/icons/bin_obj.gif
new file mode 100644
index 0000000..ada4bb9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/bin_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/collapse_all.gif b/org.eclipse.linuxtools.dataviewers/icons/collapse_all.gif
new file mode 100644
index 0000000..a2d80a9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/collapse_all.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/exec_obj.gif b/org.eclipse.linuxtools.dataviewers/icons/exec_obj.gif
new file mode 100644
index 0000000..8174dad
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/exec_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/expand_all.gif b/org.eclipse.linuxtools.dataviewers/icons/expand_all.gif
new file mode 100644
index 0000000..c4a67bb
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/expand_all.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/export.gif b/org.eclipse.linuxtools.dataviewers/icons/export.gif
new file mode 100644
index 0000000..5a0837d
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/export.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/filter_ps.gif b/org.eclipse.linuxtools.dataviewers/icons/filter_ps.gif
new file mode 100644
index 0000000..6fe6f0e
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/filter_ps.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/flexperf.gif b/org.eclipse.linuxtools.dataviewers/icons/flexperf.gif
new file mode 100644
index 0000000..80b4c7c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/flexperf.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/forward_nav.gif b/org.eclipse.linuxtools.dataviewers/icons/forward_nav.gif
new file mode 100644
index 0000000..1d3bafb
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/forward_nav.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/function_obj.gif b/org.eclipse.linuxtools.dataviewers/icons/function_obj.gif
new file mode 100644
index 0000000..18103b1
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/function_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/info_obj.gif b/org.eclipse.linuxtools.dataviewers/icons/info_obj.gif
new file mode 100644
index 0000000..2da001e
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/info_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/left-end.gif b/org.eclipse.linuxtools.dataviewers/icons/left-end.gif
new file mode 100644
index 0000000..86429e8
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/left-end.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/left.gif b/org.eclipse.linuxtools.dataviewers/icons/left.gif
new file mode 100644
index 0000000..683b7e4
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/left.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/percentage.gif b/org.eclipse.linuxtools.dataviewers/icons/percentage.gif
new file mode 100644
index 0000000..ea7bd28
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/percentage.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/pie.gif b/org.eclipse.linuxtools.dataviewers/icons/pie.gif
new file mode 100644
index 0000000..d7d93db
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/pie.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/printer.gif b/org.eclipse.linuxtools.dataviewers/icons/printer.gif
new file mode 100644
index 0000000..9fefaab
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/printer.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/prop_edt.gif b/org.eclipse.linuxtools.dataviewers/icons/prop_edt.gif
new file mode 100644
index 0000000..9d5a508
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/prop_edt.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/right-end.gif b/org.eclipse.linuxtools.dataviewers/icons/right-end.gif
new file mode 100644
index 0000000..36979ea
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/right-end.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/right.gif b/org.eclipse.linuxtools.dataviewers/icons/right.gif
new file mode 100644
index 0000000..48a46ee
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/right.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/sample.gif b/org.eclipse.linuxtools.dataviewers/icons/sample.gif
new file mode 100644
index 0000000..34fb3c9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/sample.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/search.gif b/org.eclipse.linuxtools.dataviewers/icons/search.gif
new file mode 100644
index 0000000..d540a01
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/search.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/sort.gif b/org.eclipse.linuxtools.dataviewers/icons/sort.gif
new file mode 100644
index 0000000..fd74778
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/sort.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/st.gif b/org.eclipse.linuxtools.dataviewers/icons/st.gif
new file mode 100644
index 0000000..fa6dbea
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/st.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/toggle.gif b/org.eclipse.linuxtools.dataviewers/icons/toggle.gif
new file mode 100644
index 0000000..62a7d86
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/toggle.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/icons/variable_obj.gif b/org.eclipse.linuxtools.dataviewers/icons/variable_obj.gif
new file mode 100644
index 0000000..9fa6383
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/icons/variable_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.dataviewers/plugin.properties b/org.eclipse.linuxtools.dataviewers/plugin.properties
new file mode 100644
index 0000000..b296a4a
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/plugin.properties
@@ -0,0 +1,12 @@
+#******************************************************************************
+# Copyright (c) 2009 STMicroelectronics.
+# 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:
+# STMicroelectronics - initial API and implementation
+#*******************************************************************************
+bundleProvider = Eclipse Linux Tools
+bundleName = Data Viewers Plug-in (Incubation) \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/STDataViewersActivator.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/STDataViewersActivator.java
new file mode 100644
index 0000000..c538b63
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/STDataViewersActivator.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class STDataViewersActivator extends AbstractUIPlugin {
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.dataviewers";
+
+
+ // The shared instance
+ private static STDataViewersActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public STDataViewersActivator() {
+ }
+
+ /*
+ * (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;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static STDataViewersActivator getDefault() {
+ return plugin;
+ }
+
+ /** Gets the Plugin ID
+ *
+ * @return "org.eclipse.linuxtools.dataviewers"
+ */
+ public static String getUniqueIdentifier()
+ {
+ return PLUGIN_ID;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractview/AbstractSTDataView.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractview/AbstractSTDataView.java
new file mode 100644
index 0000000..05587b5
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractview/AbstractSTDataView.java
@@ -0,0 +1,506 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.abstractview;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.actions.STCollapseAllTreeAction;
+import org.eclipse.linuxtools.dataviewers.actions.STCollapseSelectionAction;
+import org.eclipse.linuxtools.dataviewers.actions.STCopyAction;
+import org.eclipse.linuxtools.dataviewers.actions.STDataViewersSortAction;
+import org.eclipse.linuxtools.dataviewers.actions.STExpandAllTreeAction;
+import org.eclipse.linuxtools.dataviewers.actions.STExpandSelectionAction;
+import org.eclipse.linuxtools.dataviewers.actions.STExportToCSVAction;
+import org.eclipse.linuxtools.dataviewers.actions.STHideShowColAction;
+import org.eclipse.linuxtools.dataviewers.findreplace.ISTFindReplaceTarget;
+import org.eclipse.linuxtools.dataviewers.findreplace.STFindReplaceAction;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.preferences.ViewPreferencesAction;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+
+
+
+/**
+ * The AbstractSTDataView is a view that generically implements data result views.
+ */
+public abstract class AbstractSTDataView extends ViewPart {
+
+ private AbstractSTViewer stViewer = null;
+
+ private IAction sortAction = null;
+
+ private IAction preferencesAction = null;
+
+ private IAction hideShowColAction = null;
+
+ private IAction expandAllAction = null;
+
+ private IAction collapseAllAction = null;
+
+ private IAction expandSelectionAction = null;
+
+ private IAction collapseSelectionAction = null;
+
+ private IAction exportToCSVAction = null;
+
+ private IAction copyToAction = null;
+
+ private ISTFindReplaceTarget fTarget = null;
+
+
+ /*
+ * (non-Javadoc) Method declared on IViewPart.
+ */
+ public void init(IViewSite site, IMemento memento) throws PartInitException {
+ super.init(site, memento);
+ }
+
+ /**
+ * Create optional arbitrary Controls, on top of viewer.
+ * Does nothing by default.
+ * Can be used to display a title, or some other informations.
+ * @param parent the parent composite, with a gridlayout (1 column)
+ */
+ protected void createTitle(Composite parent) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl(Composite parent) {
+ GridLayout gridLayout = new GridLayout(1,true);
+ parent.setLayout(gridLayout);
+ createTitle(parent);
+ stViewer = createAbstractSTViewer(parent);
+
+ // create the actions before the input is set on the viewer but after
+ // the sorter and filter are set so the actions will be enabled correctly.
+ createActions();
+
+ final MenuManager mgr = initContextMenu();
+ final Menu menu = mgr.createContextMenu(parent);
+ stViewer.getViewer().getControl().setMenu(menu);
+
+ getSite().registerContextMenu(mgr, getSelectionProvider());
+
+ //the selection provider registered
+ getSite().setSelectionProvider(getSelectionProvider());
+
+ IActionBars actionBars = getViewSite().getActionBars();
+
+ initMenu(actionBars.getMenuManager());
+ initToolBar(actionBars.getToolBarManager());
+
+ registerGlobalActions(getViewSite().getActionBars());
+ }
+ /**
+ * Creates the actions for the receiver.
+ */
+ protected void createActions() {
+ // menu bar
+ expandAllAction = createExpandAllAction();
+ collapseAllAction = createCollapseAllAction();
+
+ sortAction = createSortAction();
+
+ hideShowColAction = createHideShowColumnAction();
+
+ exportToCSVAction = createExportToCSVAction();
+
+ // context menu (right-click)
+ expandSelectionAction = createExpandSelectionAction();
+ collapseSelectionAction = createCollapseSelectionAction();
+ copyToAction = createCopyToAction();
+ }
+
+ /**
+ * Creates the copy actions.
+ * @return IAction
+ */
+ protected IAction createCopyToAction() {
+ return new STCopyAction(getSTViewer());
+ }
+
+ /**
+ * Creates the export To CSV actions.
+ * @return IAction
+ */
+ protected IAction createExportToCSVAction() {
+ return new STExportToCSVAction(getSTViewer());
+ }
+
+ /**
+ * Creates the collapse selection actions.
+ * @return IAction
+ */
+ protected IAction createCollapseSelectionAction() {
+ if (getSTViewer() instanceof AbstractSTTreeViewer) {
+ AbstractSTTreeViewer stTreeViewer =
+ (AbstractSTTreeViewer)getSTViewer();
+ return new STCollapseSelectionAction(stTreeViewer);
+ }
+ return null;
+ }
+
+ /**
+ * Creates the expand selection actions.
+ * @return IAction
+ */
+ protected IAction createExpandSelectionAction() {
+ if (getSTViewer() instanceof AbstractSTTreeViewer) {
+ AbstractSTTreeViewer stTreeViewer =
+ (AbstractSTTreeViewer)getSTViewer();
+ return new STExpandSelectionAction(stTreeViewer);
+ }
+ return null;
+ }
+
+ /**
+ * Creates the Hide and/or Show action.
+ * @return IAction
+ */
+ protected IAction createHideShowColumnAction() {
+ return new STHideShowColAction(getSTViewer());
+ }
+
+ /**
+ * Creates the sort action.
+ * @return IAction
+ */
+ protected IAction createSortAction() {
+ return new STDataViewersSortAction(getSTViewer());
+ }
+
+ /**
+ * Creates the collapse all action.
+ * @return IAction
+ */
+ protected IAction createCollapseAllAction() {
+ if (getSTViewer() instanceof AbstractSTTreeViewer) {
+ AbstractSTTreeViewer stTreeViewer =
+ (AbstractSTTreeViewer)getSTViewer();
+ return new STCollapseAllTreeAction(stTreeViewer);
+ }
+ return null;
+ }
+
+ /**
+ * Creates the expand all action.
+ * @return IAction
+ */
+ protected IAction createExpandAllAction() {
+ if (getSTViewer() instanceof AbstractSTTreeViewer) {
+ AbstractSTTreeViewer stTreeViewer =
+ (AbstractSTTreeViewer)getSTViewer();
+ return new STExpandAllTreeAction(stTreeViewer);
+ }
+ return null;
+ }
+
+ /**
+ * Init the context menu
+ * <p>
+ * If you intend to add an action in the context menu
+ * you may override the <code>fillContextMenu</code> method.
+ * </p>
+ *
+ * @see #fillContextMenu(IMenuManager manager)
+ */
+ protected MenuManager initContextMenu() {
+ MenuManager mgr = new MenuManager();
+ mgr.setRemoveAllWhenShown(true);
+ mgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager mgr) {
+ getSTViewer().getViewer().cancelEditing();
+ fillContextMenu(mgr);
+ }
+ });
+ return mgr;
+ }
+
+ /**
+ * Init the toolbar for the receiver
+ * <p>
+ * You can override this method if you want - but remember to call <code>super.initToolBar()</code>.
+ * </p>
+ * @param manager the tool bar manager of this view
+ */
+ protected void initToolBar(IToolBarManager manager) {
+ if (expandAllAction != null) manager.add(expandAllAction);
+ if (collapseAllAction != null) manager.add(collapseAllAction);
+ if (hideShowColAction != null) manager.add(hideShowColAction);
+ if (exportToCSVAction != null) manager.add(exportToCSVAction);
+ if (sortAction != null) manager.add(sortAction);
+ contributeToToolbar(manager);
+ manager.update(true);
+ }
+
+ /**
+ * Init the menu for the receiver.
+ *
+ * @param menu
+ */
+ protected void initMenu(IMenuManager menu) {
+ if (sortAction != null) {
+ menu.add(sortAction);
+ }
+ if (hideShowColAction != null) {
+ menu.add(hideShowColAction);
+ }
+ if (preferencesAction != null) {
+ menu.add(preferencesAction);
+ }
+ if (exportToCSVAction != null){
+ menu.add(exportToCSVAction);
+ }
+
+ contributeToDropDownMenu(menu);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ public void setFocus() {
+ Viewer viewer = getSTViewer().getViewer();
+ if (viewer != null && !viewer.getControl().isDisposed()) {
+ viewer.getControl().setFocus();
+ }
+ }
+
+ /**
+ * Return the viewer.
+ *
+ * @return AbstractSTViewer
+ */
+ public AbstractSTViewer getSTViewer() {
+ return stViewer;
+ }
+
+ /**
+ * Return the tree for the receiver.
+ *
+ * @return Control
+ */
+ public Control getControl() {
+ return stViewer.getViewer().getControl();
+ }
+
+ /**
+ * Shortcut for getViewer().setInput(input)
+ * See {@link TreeViewer#setInput(Object)}
+ * @param input
+ */
+ public void setInput(Object input) {
+ stViewer.getViewer().setInput(input);
+ }
+
+ /**
+ * Get the IWorkbenchSiteProgressService for the receiver.
+ *
+ * @return IWorkbenchSiteProgressService or <code>null</code>.
+ */
+ protected IWorkbenchSiteProgressService getProgressService() {
+ IWorkbenchSiteProgressService service = null;
+ Object siteService = getSite().getAdapter(
+ IWorkbenchSiteProgressService.class);
+ if (siteService != null) {
+ service = (IWorkbenchSiteProgressService) siteService;
+ }
+ return service;
+ }
+
+ /**
+ * Return the preferences action.
+ *
+ * @return IAction
+ */
+ protected IAction getPreferencesAction() {
+ return preferencesAction;
+ }
+
+ /**
+ * Set the preferences action.
+ *
+ * @param preferencesAction
+ */
+ protected void setPreferencesAction(ViewPreferencesAction preferencesAction) {
+ this.preferencesAction = preferencesAction;
+ }
+
+ /**
+ * Gets the selection provider.
+ *
+ * @return the selection provider
+ */
+ protected ISelectionProvider getSelectionProvider() {
+ return stViewer.getViewer();
+ }
+
+ /**
+ * Return the input of the viewer.
+ *
+ * @return Object
+ */
+ public Object getViewerInput() {
+ return stViewer.getViewer().getInput();
+ }
+
+ /**
+ * Set the selection of the receiver.
+ *
+ * @param selection
+ */
+ protected void setSelection(IStructuredSelection selection) {
+ getSelectionProvider().setSelection(selection);
+ }
+
+
+ /**
+ * Fills the context menu
+ * (mouse right-click)
+ * <p>
+ * Subclasses may extend it. don't forget to call
+ * <code>super.fillContextMenu(...)</code>
+ * </p>
+ *
+ * @param manager
+ */
+ protected void fillContextMenu(IMenuManager manager) {
+ if (getControl() != null
+ && getControl() instanceof Tree) {
+ Tree tree = (Tree)getControl();
+ TreeItem[] selection = tree.getSelection();
+ if (selection != null
+ && selection.length > 0) {
+ if (collapseSelectionAction != null) manager.add(collapseSelectionAction);
+ if (expandSelectionAction != null) manager.add(expandSelectionAction);
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ if (copyToAction != null) manager.add(copyToAction);
+ }
+ }
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ /**
+ * Add actions to the drop down menu.
+ * (top-right corner drop down menu)
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ *
+ * @param menu
+ */
+ protected void contributeToDropDownMenu(IMenuManager menu) {
+ //nothing, intended to be overridden
+ }
+
+ /**
+ * Add actions to the toolbar
+ * (top-right toolbar)
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ *
+ * @param manager
+ */
+ protected void contributeToToolbar(IToolBarManager manager){
+ //nothing, intended to be overridden
+ }
+
+ /**
+ * Register contributions to the global actions bar.
+ * (global actions toolbar)
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ *
+ * @param actionBars
+ */
+ protected void registerGlobalActions(IActionBars actionBars) {
+ fTarget = createSTFindReplaceTarget();
+ if (fTarget == null) return;
+ STFindReplaceAction action= new STFindReplaceAction(getSite().getShell(),fTarget); //$NON-NLS-1$
+ actionBars.setGlobalActionHandler(ITextEditorActionConstants.FIND, action);
+ }
+
+ /**
+ * Creates an instance of ISTFindReplaceTarget. It has to return an object not null
+ * when the Find action is enabled
+ * @return ISTFindReplaceTarget
+ */
+ public ISTFindReplaceTarget createSTFindReplaceTarget(){
+ return null;
+ }
+
+
+
+ /**
+ * Gets the fields that are able to be sorted
+ * <p>
+ * By default it returns
+ * <code>getAllFields()</code>. If you want to
+ * change that behavior you'll have to override
+ * this method.
+ * </p>
+ *
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ * @return the fields that are able to be sorted
+ */
+ protected ISTDataViewersField[] getSortingFields() {
+ return null;
+ }
+
+ /**
+ * Creates a wrapper handling a TreeTable or Table Viewer
+ *
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ *
+ * @param parent
+ * @return an AbstractSTViewer
+ */
+ abstract protected AbstractSTViewer createAbstractSTViewer(Composite parent);
+
+ public void dispose(){
+ super.dispose();
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractPercentageDrawerField.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractPercentageDrawerField.java
new file mode 100644
index 0000000..ece29aa
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractPercentageDrawerField.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import java.text.NumberFormat;
+
+import org.eclipse.linuxtools.dataviewers.listeners.ISpecialDrawerListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
+
+
+
+
+/**
+ * A field that implements a percentage drawer
+ */
+public abstract class AbstractPercentageDrawerField extends AbstractSTDataViewersField implements ISpecialDrawerListener {
+
+ @Override
+ public ISpecialDrawerListener getSpecialDrawer(Object obj) {
+ return this;
+ }
+
+ public String getValue(Object obj) {
+ return getPercentage(obj)+"";
+ }
+
+ /**
+ * Gets the percentage value for the given object, as a float
+ * @param obj
+ * @return a float value, between 0 and 100, please !
+ */
+ public abstract float getPercentage(Object obj);
+
+ /**
+ * Percentage drawer
+ */
+ public void handleEvent(Event event) {
+ Item item = (Item)event.item;
+ Display display = event.widget.getDisplay();
+ int index = event.index;
+ int widthcol = 0;
+
+ if (event.widget instanceof Tree) {
+ Tree tree =
+ (Tree)event.widget;
+ widthcol =
+ tree.getColumn(index).getWidth();
+ } else { //event.widget instanceof Table
+ Table table =
+ (Table)event.widget;
+ widthcol =
+ table.getColumn(index).getWidth();
+ }
+
+ float d = getPercentage(item.getData());
+ int percent = (int) (d + 0.5);
+ GC gc = event.gc;
+ Color foreground = gc.getForeground();
+ Color background = gc.getBackground();
+ gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
+ gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+ int width = (widthcol - 1) * percent / 100;
+ if (width > 0){
+ gc.fillGradientRectangle(event.x, event.y, width, event.height, true);
+ Rectangle rect = new Rectangle(event.x, event.y, width-1, event.height-1);
+ gc.drawRectangle(rect);
+ }
+ gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ String text = "%";
+ text = (isSettedNumberFormat()?getNumberFormat().format(d):d) + text;
+ Point size = gc.textExtent(text);
+ int offset = Math.max(0, (event.height - size.y) / 2);
+ gc.drawText(text, event.x+2, event.y+offset, true);
+ gc.setForeground(foreground);
+ gc.setBackground(background);
+ }
+
+ public abstract NumberFormat getNumberFormat();
+
+ public abstract boolean isSettedNumberFormat();
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTDataViewersField.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTDataViewersField.java
new file mode 100644
index 0000000..3705dbb
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTDataViewersField.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.linuxtools.dataviewers.listeners.ISpecialDrawerListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+
+
+/**
+ * Simple implementation of ISTField
+ */
+public abstract class AbstractSTDataViewersField implements ISTDataViewersField {
+
+ private boolean showing = true;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderImage()
+ */
+ public Image getColumnHeaderImage() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getDefaultDirection()
+ */
+ public int getDefaultDirection() {
+ return STDataViewersComparator.ASCENDING;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getDescription()
+ */
+ public String getDescription() {
+ return getColumnHeaderText();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getDescriptionImage()
+ */
+ public Image getDescriptionImage() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getImage(java.lang.Object)
+ */
+ public Image getImage(Object obj) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getPreferredWidth()
+ */
+ public int getPreferredWidth() {
+ return 100;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#isShowing()
+ */
+ public boolean isShowing() {
+ return this.showing;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#setShowing(boolean)
+ */
+ public void setShowing(boolean showing) {
+ this.showing = showing;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getSpecialDrawer(java.lang.Object)
+ */
+ public ISpecialDrawerListener getSpecialDrawer(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getBackground(java.lang.Object)
+ */
+ public Color getBackground(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getToolTipText(java.lang.Object)
+ */
+ public String getToolTipText(Object element) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderTooltip()
+ */
+ public String getColumnHeaderTooltip() {
+ return getColumnHeaderText();
+ }
+
+ @Override
+ public String toString() {
+ return getColumnHeaderText();
+ }
+
+ public int getAlignment(){
+ return SWT.NONE;
+ }
+
+ public boolean isHyperLink(Object element){
+ return false;
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTableViewer.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTableViewer.java
new file mode 100644
index 0000000..2e910ba
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTableViewer.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * This wrapper extends AbstractSTViewer {@link AbstractSTViewer}
+ * It is designed to be instantiated with a TableViewer JFace control
+ *
+ */
+public abstract class AbstractSTTableViewer extends AbstractSTViewer {
+
+ public AbstractSTTableViewer(Composite parent) {
+ super(parent, SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION);
+ }
+
+
+ public AbstractSTTableViewer(Composite parent,boolean init) {
+ super(parent,SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION,init);
+ }
+
+ public AbstractSTTableViewer(Composite parent, int style) {
+ super(parent,style,true);
+ }
+
+ public AbstractSTTableViewer(Composite parent, int style,boolean init) {
+ super(parent,style,init);
+ }
+
+ @Override
+ /*
+ * It creates the TableViewer wrapped
+ * @param parent
+ * @param style
+ * @return ColumnViewer
+ */
+ protected ColumnViewer createViewer(Composite parent, int style) {
+ return new TableViewer(
+ createTable(parent, style));
+ }
+
+ /**
+ * Create the main table control
+ *
+ * @param parent
+ * @return Table
+ */
+ protected Table createTable(Composite parent, int style) {
+ Table table = new Table(parent, style);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+ return table;
+ }
+
+ @Override
+ /**
+ * Create the columns in the table.
+ *
+ */
+ protected void createColumns() {
+ Table table = getViewer().getTable();
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ for (int i = 0; i < getAllFields().length; i++) {
+ ISTDataViewersField field = getAllFields()[i];
+ TableColumn tc = new TableColumn(table, field.getAlignment(), i);
+ tc.setText(field.getColumnHeaderText());
+ tc.setToolTipText(field.getColumnHeaderTooltip());
+ tc.setImage(field.getColumnHeaderImage());
+ tc.setWidth(field.getPreferredWidth());
+ tc.setResizable(true);
+ tc.setMoveable(true);
+
+ tc.addSelectionListener(createHeaderListener());
+ tc.setData(field);
+
+ // defining the column label provider.
+ // this has to be done after setting the column's data.
+ TableViewerColumn viewerColumn =
+ new TableViewerColumn(getViewer(), tc);
+ viewerColumn.setLabelProvider(createColumnLabelProvider(tc));
+ }
+
+
+ table.addMouseListener(new MouseAdapter(){
+ public void mouseDoubleClick(MouseEvent e) {
+ Table table = (Table)e.widget;
+ TableItem item = table.getItem(new Point(e.x,e.y));
+ if (item != null){
+ for(int i=0;i<table.getColumnCount();i++){
+ ISTDataViewersField field = getAllFields()[i];
+ if (field.isHyperLink(item.getData())){
+ Rectangle bounds = item.getBounds(i);
+ if (bounds.contains(e.x,e.y)){
+ handleHyperlink(field,item.getData());
+ }
+ }
+ }
+ }
+ }
+ });
+
+ table.addMouseMoveListener(new MouseMoveListener(){
+
+ @Override
+ public void mouseMove(MouseEvent e) {
+ Table table = (Table)e.widget;
+ TableItem item = table.getItem(new Point(e.x,e.y));
+ if (item == null) return;
+
+ for(int i=0;i<table.getColumnCount();i++){
+ ISTDataViewersField field = getAllFields()[i];
+ Cursor cursor = null ;
+ if (field.isHyperLink(item.getData())){
+ Rectangle bounds = item.getBounds(i);
+ if (bounds.contains(e.x,e.y)){
+ cursor = new Cursor(e.display,SWT.CURSOR_HAND);
+ table.setCursor(cursor);
+ return;
+ }
+ }
+ cursor = new Cursor(e.display,SWT.CURSOR_ARROW);
+ table.setCursor(cursor);
+ }
+
+ }
+
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumns()
+ */
+ @Override
+ public Item[] getColumns() {
+ return getViewer().getTable().getColumns();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#updateDirectionIndicator(org.eclipse.swt.widgets.Item)
+ */
+ @Override
+ public void updateDirectionIndicator(Item column) {
+ getViewer().getTable().setSortColumn((TableColumn)column);
+ if (getTableSorter().getTopPriorityDirection() == STDataViewersComparator.ASCENDING)
+ getViewer().getTable().setSortDirection(SWT.UP);
+ else
+ getViewer().getTable().setSortDirection(SWT.DOWN);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumnOrder()
+ */
+ public int[] getColumnOrder() {
+ return getViewer().getTable().getColumnOrder();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#setColumnOrder(int[])
+ */
+ protected void setColumnOrder(int[] order) {
+ getViewer().getTable().setColumnOrder(order);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumnIndex(org.eclipse.swt.widgets.Item)
+ */
+ public int getColumnIndex(Item column) {
+ return getViewer().getTable().indexOf((TableColumn)column);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumnWidth(org.eclipse.swt.widgets.Item)
+ */
+ @Override
+ public int getColumnWidth(Item column) {
+ return ((TableColumn)column).getWidth();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#setColumnResizable(org.eclipse.swt.widgets.Item, boolean)
+ */
+ @Override
+ public void setColumnResizable(Item column, boolean resizable) {
+ ((TableColumn)column).setResizable(resizable);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#setColumnWidth(org.eclipse.swt.widgets.Item, int)
+ */
+ @Override
+ public void setColumnWidth(Item column, int width) {
+ ((TableColumn)column).setWidth(width);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getViewer()
+ */
+ public TableViewer getViewer() {
+ return (TableViewer)super.getViewer();
+ }
+
+
+ public void handleHyperlink(ISTDataViewersField field,Object data){};
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTreeViewer.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTreeViewer.java
new file mode 100644
index 0000000..1b38a6a
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTTreeViewer.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * This wrapper extends AbstractSTViewer {@link AbstractSTViewer}
+ * It is designed to be instantiated with a TreeViewer JFace control
+ *
+ */
+public abstract class AbstractSTTreeViewer extends AbstractSTViewer {
+
+
+ public AbstractSTTreeViewer(Composite parent) {
+ super(parent, SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION);
+ }
+
+
+ public AbstractSTTreeViewer(Composite parent,boolean init) {
+ super(parent,SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION,init);
+ }
+
+ public AbstractSTTreeViewer(Composite parent, int style) {
+ super(parent,style,true);
+ }
+
+ public AbstractSTTreeViewer(Composite parent, int style,boolean init) {
+ super(parent,style,init);
+ }
+
+
+ /*
+ * It creates the TreeViewer wrapped
+ * @param parent
+ * @param style
+ * @return ColumnViewer
+ */
+ @Override
+ protected ColumnViewer createViewer(Composite parent, int style) {
+ return new TreeViewer(createTree(parent, style)) {
+ @Override
+ // FIXME Temporary fix for eclipse bug #170521
+ // (bug in the refresh() method)
+ // Saves the expanded elements in order to correctly restore
+ // the expanded state of the tree.
+ public void refresh(Object element) {
+ getTree().setRedraw(false);
+ Object[] elements = this.getExpandedElements();
+ super.refresh(element);
+ this.setExpandedElements(elements);
+ getTree().setRedraw(true);
+ }
+ };
+ }
+
+ /**
+ * Create the main tree control
+ *
+ * @param parent
+ * @param style
+ * @return Tree
+ */
+ protected Tree createTree(Composite parent, int style) {
+ Tree tree = new Tree(parent, style);
+ tree.setLinesVisible(true);
+ tree.setHeaderVisible(true);
+
+ return tree;
+ }
+
+ @Override
+ /**
+ * Create the columns in the tree.
+ *
+ */
+ protected void createColumns() {
+ Tree tree = getViewer().getTree();
+ TableLayout layout = new TableLayout();
+ tree.setLayout(layout);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ for (int i = 0; i < getAllFields().length; i++) {
+ ISTDataViewersField field = getAllFields()[i];
+ TreeColumn tc = new TreeColumn(tree, field.getAlignment(), i);
+ tc.setText(field.getColumnHeaderText());
+ tc.setToolTipText(field.getColumnHeaderTooltip());
+ tc.setImage(field.getColumnHeaderImage());
+ tc.setWidth(field.getPreferredWidth());
+ tc.setResizable(true);
+ tc.setMoveable(true);
+
+ tc.addSelectionListener(createHeaderListener());
+ tc.setData(field);
+
+ // defining the column label provider.
+ // this has to be done after setting the column's data.
+ TreeViewerColumn viewerColumn =
+ new TreeViewerColumn(getViewer(), tc);
+ viewerColumn.setLabelProvider(createColumnLabelProvider(tc));
+ }
+
+ tree.addMouseListener(new MouseAdapter(){
+ public void mouseDoubleClick(MouseEvent e) {
+ Tree tree = (Tree)e.widget;
+ TreeItem item = tree.getItem(new Point(e.x,e.y));
+ if (item != null){
+ for(int i=0;i<tree.getColumnCount();i++){
+ ISTDataViewersField field = getAllFields()[i];
+ if (field.isHyperLink(item.getData())){
+ Rectangle bounds = item.getBounds(i);
+ if (bounds.contains(e.x,e.y)){
+ handleHyperlink(field,item.getData());
+ }
+ }
+ }
+ }
+ }
+ });
+
+ tree.addMouseMoveListener(new MouseMoveListener(){
+ @Override
+ public void mouseMove(MouseEvent e) {
+ Tree tree = (Tree)e.widget;
+ TreeItem item = tree.getItem(new Point(e.x,e.y));
+ if (item == null) return;
+
+ for(int i=0;i<tree.getColumnCount();i++){
+ ISTDataViewersField field = getAllFields()[i];
+ Cursor cursor = null ;
+ if (field.isHyperLink(item.getData())){
+ Rectangle bounds = item.getBounds(i);
+ if (bounds.contains(e.x,e.y)){
+ cursor = new Cursor(e.display,SWT.CURSOR_HAND);
+ tree.setCursor(cursor);
+ return;
+ }
+ }
+ cursor = new Cursor(e.display,SWT.CURSOR_ARROW);
+ tree.setCursor(cursor);
+ }
+ }
+
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumns()
+ */
+ public Item[] getColumns() {
+ return getViewer().getTree().getColumns();
+ }
+
+ @Override
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#updateDirectionIndicator(org.eclipse.swt.widgets.Item)
+ */
+ public void updateDirectionIndicator(Item column) {
+ getViewer().getTree().setSortColumn((TreeColumn)column);
+ if (getTableSorter().getTopPriorityDirection() == STDataViewersComparator.ASCENDING)
+ getViewer().getTree().setSortDirection(SWT.UP);
+ else
+ getViewer().getTree().setSortDirection(SWT.DOWN);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumnOrder()
+ */
+ public int[] getColumnOrder() {
+ return getViewer().getTree().getColumnOrder();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#setColumnOrder(int[])
+ */
+ protected void setColumnOrder(int[] order) {
+ getViewer().getTree().setColumnOrder(order);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumnIndex(org.eclipse.swt.widgets.Item)
+ */
+ public int getColumnIndex(Item column) {
+ return getViewer().getTree().indexOf((TreeColumn)column);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getColumnWidth(org.eclipse.swt.widgets.Item)
+ */
+ @Override
+ public int getColumnWidth(Item column) {
+ return ((TreeColumn)column).getWidth();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#setColumnResizable(org.eclipse.swt.widgets.Item, boolean)
+ */
+ @Override
+ public void setColumnResizable(Item column, boolean resizable) {
+ ((TreeColumn)column).setResizable(resizable);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#setColumnWidth(org.eclipse.swt.widgets.Item, int)
+ */
+ @Override
+ public void setColumnWidth(Item column, int width) {
+ ((TreeColumn)column).setWidth(width);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getViewer()
+ */
+ public TreeViewer getViewer() {
+ return (TreeViewer)super.getViewer();
+ }
+
+ public void handleHyperlink(ISTDataViewersField field,Object data){}
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTViewer.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTViewer.java
new file mode 100644
index 0000000..5e5d8e5
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/AbstractSTViewer.java
@@ -0,0 +1,740 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.linuxtools.dataviewers.listeners.STDisposeListener;
+import org.eclipse.linuxtools.dataviewers.listeners.STHeaderListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Scrollable;
+
+
+/**
+ * The AbstractSTViewer is a wrapper handling a viewer like TreeTable or Table.
+ */
+public abstract class AbstractSTViewer {
+
+ private IDialogSettings viewerSettings = null;
+
+ private ISTDataViewersField[] fields = null;
+
+ private ColumnViewer viewer;
+
+ private STDataViewersComparator comparator;
+
+ private STDataViewersHideShowManager hideShowManager;
+
+
+
+ /**
+ * Creates a new instance of the receiver under the given parent.
+ * The viewer is created using the SWT style bits <code>VIRTUAL</code>,
+ * <code>MULTI, H_SCROLL, V_SCROLL,</code> and <code>BORDER</code>.
+ *
+ * @param parent is the parent control
+ */
+ public AbstractSTViewer(Composite parent) {
+ this(parent, SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION);
+ }
+
+
+ /**
+ * Creates a new instance of the receiver under the given parent.
+ * The viewer is created using the SWT style bits <code>VIRTUAL</code>,
+ * <code>MULTI, H_SCROLL, V_SCROLL,</code> and <code>BORDER</code>.
+ *
+ * @param parent is the parent control
+ */
+ public AbstractSTViewer(Composite parent,boolean init) {
+ this(parent,SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION,init);
+ }
+
+ /**
+ * Creates a new instance of the receiver under the given parent.
+ *
+ * @param parent is the parent control
+ * @style is the SWT style bits to customize the style of the tree/table
+ *
+ */
+ public AbstractSTViewer(Composite parent, int style) {
+ this(parent,style,true);
+ }
+
+ /**
+ * Creates a new instance of the receiver under the given parent.
+ *
+ * @param parent is the parent control
+ * @style is the SWT style bits to customize the style of the tree/table
+ * @setup is a flag indicating when a customization of AbstractSTViewer needs to set up
+ * additional information useful to create the Viewer
+ *
+ */
+ public AbstractSTViewer(Composite parent, int style,boolean init) {
+ if (init) init(parent,style);
+ }
+
+ /*
+ * Initializes this view with the given view site. A memento is passed to
+ * the view which contains a snapshot of the views state from a previous
+ * session. Where possible, the view should try to recreate that state
+ * within the part controls.
+ * <p>
+ * This implementation will ignore the memento and initialize the view in
+ * a fresh state. Subclasses may override the implementation to perform any
+ * state restoration as needed.
+ */
+
+ /**
+ * Initializes the viewers. It sets:
+ * the columns of the viewers,
+ * a viewer setting (similar to memento)
+ * a column manager
+ * a viewer comparator
+ * ColumnViewerToolTipSupport
+ * an OpenListener
+ * a KeyListener
+ * a PaintListener
+ * a DisposeListener
+ * the input
+ * the content provider
+ *
+ *
+ */
+ protected void init(Composite parent,int style) {
+ viewer = createViewer(parent, style);
+ viewerSettings = createSTAbstractDataViewersSettings();
+
+ fields = getAllFields();
+
+ createColumns();
+ restoreColumnOrder();
+
+ // building columns manager
+ // (needs the columns to be created first)
+ STDataViewersHideShowManager manager =
+ buildHideShowManager();
+ manager.restoreState(viewerSettings);
+ setHideShowManager(manager);
+
+
+ // building the column comparator
+ // (needs the columns to be created first)
+ STDataViewersComparator comparator = buildComparator();
+ comparator.restoreState(viewerSettings);
+ setComparator(comparator);
+ setSortIndicators();
+
+ IContentProvider cp =
+ createContentProvider();
+
+ viewer.setContentProvider(cp);
+
+ STOwnerDrawLabelProvider.setUpOwnerDraw(viewer);
+
+ viewer.setUseHashlookup(true);
+
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ viewer.getControl().setLayoutData(data);
+
+ viewer.setInput(createDefaultViewerInput());
+
+ ColumnViewerToolTipSupport.enableFor(viewer);
+
+ Scrollable scrollable = (Scrollable) viewer.getControl();
+ ScrollBar bar = scrollable.getVerticalBar();
+ if (bar != null) {
+ bar.setSelection(restoreVerticalScrollBarPosition());
+ }
+ bar = scrollable.getHorizontalBar();
+ if (bar != null) {
+ bar.setSelection(restoreHorizontalScrollBarPosition());
+ }
+
+ viewer.addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ handleOpenEvent(event);
+ }
+ });
+
+ viewer.getControl().addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ handleKeyPressed(e);
+ }
+ });
+
+ viewer.getControl().addDisposeListener(
+ createDisposeListener());
+
+ }
+
+ ////////////////////////////
+ // Columns manager utilities
+ ////////////////////////////
+
+ /**
+ * Build a hide/show manager from the default settings.
+ * It is different if it is for a TreeViewer or a TableViewer.
+ *
+ * @return AbstractSTViewerHideShowManager
+ */
+ protected STDataViewersHideShowManager buildHideShowManager() {
+ return new STDataViewersHideShowManager(this);
+ }
+
+
+ /**
+ * Set this manager to be the new hide/show manager. This should only
+ * be called if the columns have been created.
+ * This method should not be called by customers, it is used by the
+ * hide/show action to update the viewer.
+ *
+ * @param manager
+ */
+ public void setHideShowManager(STDataViewersHideShowManager manager) {
+ this.hideShowManager = manager;
+ updateForNewHideShowManager(hideShowManager);
+ }
+
+ /**
+ * Update the viewer for hide/show manager updates
+ *
+ * @param manager
+ */
+ protected void updateForNewHideShowManager(STDataViewersHideShowManager manager) {
+ manager.updateColumns(getColumns());
+ }
+
+
+ ////////////////////
+ // Sorting utilities
+ ////////////////////
+
+ /**
+ * Build a comparator from the default settings.
+ *
+ * @return STProfTableComparator
+ */
+ protected STDataViewersComparator buildComparator() {
+ return new STDataViewersComparator(getColumns());
+ }
+
+ /**
+ * Return the table sorter portion of the sorter.
+ *
+ * @return TableSorter
+ */
+ public STDataViewersComparator getTableSorter() {
+ return comparator;
+ }
+
+ /**
+ * Set the comparator to be the new comparator. This should only
+ * be called if the viewer has been created.
+ *
+ * @param comparator
+ */
+ public void setComparator(STDataViewersComparator comparator) {
+ this.comparator = comparator;
+ viewer.setComparator(comparator);
+ updateForNewComparator(comparator);
+ }
+
+ /**
+ * Update the viewer for comparator updates
+ *
+ * @param comparator
+ */
+ protected void updateForNewComparator(STDataViewersComparator comparator) {
+ comparator.saveState(viewerSettings);
+ viewer.refresh();
+ setSortIndicators();
+ }
+
+ /**
+ * Sets the sort indicator on top of target column
+ */
+ protected void setSortIndicators() {
+ Item topc = getTableSorter().getTopColumn();
+ updateDirectionIndicator(topc);
+ }
+
+
+ /////////////////////////
+ // Save/restore utilities
+ /////////////////////////
+
+ /**
+ * Creates the container for the settings of this viewer
+ *
+ * @param viewer
+ * @return
+ */
+ protected IDialogSettings createSTAbstractDataViewersSettings(){
+ IDialogSettings settings =
+ getDialogSettings().getSection(STDataViewersSettings.TAG_SECTION_VIEWER_STATE);
+ if (settings == null) {
+ settings = getDialogSettings().addNewSection(STDataViewersSettings.TAG_SECTION_VIEWER_STATE);
+ }
+ return settings;
+ }
+
+ /**
+ * Restores the viewer's column order.
+ * Called just after the columns are created.
+ */
+ public void restoreColumnOrder(){
+ int[] order = restoreColumnOrderSetting();
+ if (order != null && order.length == fields.length) {
+ setColumnOrder(order);
+ }
+ }
+
+ /**
+ * Restores the vertical scrollbar position
+ * @param settings
+ * @return the position
+ */
+ public int restoreVerticalScrollBarPosition() {
+ if (viewerSettings == null)
+ // no settings saved
+ return 0;
+
+ String position = viewerSettings.get(STDataViewersSettings.TAG_VIEWER_STATE_VERTICAL_POSITION);
+ if (position == null)
+ // no vertical position saved
+ return 0;
+
+ try {
+ return Integer.parseInt(position);
+ } catch (NumberFormatException nfe) {
+ // invalid entry
+ return 0;
+ }
+ }
+
+ /**
+ * Restores the horizontal scrollbar position
+ * @param settings
+ * @return the position
+ */
+ public int restoreHorizontalScrollBarPosition() {
+ if (viewerSettings == null)
+ // no settings saved
+ return 0;
+
+ String position = viewerSettings.get(STDataViewersSettings.TAG_VIEWER_STATE_HORIZONTAL_POSITION);
+ if (position == null)
+ // no horizontal position saved
+ return 0;
+
+ try {
+ return Integer.parseInt(position);
+ } catch (NumberFormatException nfe) {
+ // invalid entry
+ return 0;
+ }
+ }
+
+ /**
+ * Restore the order of the columns using the dialog settings
+ *
+ * @param settings
+ * @return column order
+ */
+ public int[] restoreColumnOrderSetting() {
+ if (viewerSettings == null)
+ // no settings saved
+ return null;
+
+ String[] columnOrder = viewerSettings.getArray(STDataViewersSettings.TAG_VIEWER_STATE_COLUMN_ORDER);
+ if (columnOrder == null)
+ // no column order saved
+ return null;
+
+ int n = columnOrder.length;
+ if (n != getAllFields().length)
+ // bad column count
+ return null;
+
+ try {
+ int[] values = new int[n];
+ for (int i = 0; i < n; i++) {
+ int val = Integer.parseInt(columnOrder[i]);
+ values[i] = val;
+ }
+ return values;
+ } catch (NumberFormatException nfe) {
+ // invalid entry
+ return null;
+ }
+ }
+
+ /**
+ * Used to save the state of the viewer before its disposal
+ *
+ */
+ public void saveState() {
+ if (viewerSettings == null)
+ viewerSettings = getDialogSettings().getSection(STDataViewersSettings.TAG_SECTION_VIEWER_STATE);
+ if (viewerSettings == null)
+ viewerSettings = getDialogSettings().addNewSection(STDataViewersSettings.TAG_SECTION_VIEWER_STATE);
+
+ // save column order
+ int[] columnOrder = getColumnOrder();
+ String[] columnOrderStrings = new String[columnOrder.length];
+ for (int i = 0; i < columnOrder.length; i++) {
+ columnOrderStrings[i]=columnOrder[i]+"";
+ }
+ viewerSettings.put(STDataViewersSettings.TAG_VIEWER_STATE_COLUMN_ORDER, columnOrderStrings);
+
+ // save hide show manager
+ if (getHideShowManager() != null)
+ getHideShowManager().saveState(viewerSettings);
+
+ // save sort
+ if (getTableSorter() != null)
+ getTableSorter().saveState(viewerSettings);
+
+ // save vertical position
+ Scrollable scrollable = (Scrollable)viewer.getControl();
+ ScrollBar bar = scrollable.getVerticalBar();
+ int position = (bar != null) ? bar.getSelection() : 0;
+ viewerSettings.put(STDataViewersSettings.TAG_VIEWER_STATE_VERTICAL_POSITION, position);
+
+ // save horizontal position
+ bar = scrollable.getHorizontalBar();
+ position = (bar != null) ? bar.getSelection() : 0;
+ viewerSettings.put(STDataViewersSettings.TAG_VIEWER_STATE_HORIZONTAL_POSITION, position);
+ }
+
+
+ ////////////////////////////
+ // Listeners for this viewer
+ ////////////////////////////
+
+
+
+ /**
+ * Creates the dispose listener used by the viewer
+ * to save its state when it is closed.
+ * This method is called at the end of the viewer
+ * initialization (init() method).
+ *
+ * @return the new header listener
+ */
+ protected DisposeListener createDisposeListener() {
+ return new STDisposeListener(this);
+ }
+
+ /**
+ * Creates the header listener used by the columns
+ * to check when their header is selected (used by sorting).
+ * This method is called at column creation.
+ *
+ * @return the new header listener
+ */
+ protected SelectionListener createHeaderListener() {
+ return new STHeaderListener(this);
+ }
+
+
+ //////////////////////////
+ // Getters for this viewer
+ //////////////////////////
+
+ /**
+ * Get the viewer's settings
+ *
+ * @return the IDialogSettings used to save the viewer's settings
+ */
+ public IDialogSettings getViewerSettings(){
+ return viewerSettings;
+ }
+
+ /**
+ * Get the wrapped viewer
+ *
+ * @return the JFace viewer wrapped in this ST viewer
+ */
+ public ColumnViewer getViewer() {
+ return viewer;
+ }
+
+ /**
+ * Get the input of the viewer
+ *
+ * @return the inputed object
+ */
+ public Object getInput() {
+ return viewer.getInput();
+ }
+
+ /**
+ * Get the hideShowManager that manages the columns
+ * hiding and width.
+ *
+ * @return the hideShowManager
+ */
+ public STDataViewersHideShowManager getHideShowManager() {
+ return hideShowManager;
+ }
+
+
+ /////////////////////////////////////////////////////////////
+ // Methods that can be overridden by customers when
+ // subclassing AbstractSTTreeViewer and AbstractSTTableViewer
+ /////////////////////////////////////////////////////////////
+
+ /**
+ * Create the default viewer input for the receiver.
+ * Note that you can input data to the viewer using
+ * the <code>setInput()</code> method.
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ *
+ * @return the inputed Object
+ */
+ protected Object createDefaultViewerInput() {
+ return null;
+ }
+
+ /**
+ * Handle key pressed events, called each time a key pressed event is detected in the viewer
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ *
+ * @param event
+ */
+ protected void handleKeyPressed(KeyEvent event) {
+ //nothing, intended to be overridden
+ }
+
+ /**
+ * Handle the open event, called each time the viewer is opened
+ * <p>
+ * Subclasses may override it.
+ * </p>
+ *
+ * @param event
+ */
+ protected void handleOpenEvent(OpenEvent event) {
+ //nothing, intended to be overridden
+ }
+
+
+ /////////////////////////////////////////////////
+ // Abstract methods to implement when subclassing
+ // AbstractSTTreeViewer or AbstractSTTableViewer
+ /////////////////////////////////////////////////
+
+ /**
+ * Gets the fields (e.g. the columns description) of that viewer
+ *
+ * <p>
+ * This is where you should define the columns of your viewers
+ * and the data they are going to display (label provider).
+ *</p>
+ *
+ * @return the fields of that viewer
+ */
+ abstract public ISTDataViewersField[] getAllFields();
+
+ /**
+ * Creates the content provider used by the viewer.
+ * This method is called once at viewer initialization.
+ *
+ * @return a new content provider
+ */
+ abstract protected IContentProvider createContentProvider();
+
+ /**
+ * Permit to provide the sort dialog dialogSettings
+ * (used to persist the state of the sort dialog)
+ * <p>
+ * This implementation is generally like:
+ * </p><p>
+ * <code>protected IDialogSettings getDialogSettings() {<br/>
+ * return </code>PLUGINActivator<code>.getDefault().getDialogSettings();<br/>
+ * } </code>
+ * </p><p>
+ * Note that your plugin has to be an <code>AbstractUIPlugin</code>
+ * in order to provide the <code>getDialogSettings()</code> method.
+ * </p><p>
+ * If your plugin implements MANY view or viewers, this method should return a
+ * particular section of the plugin dialog setting:
+ * </p><p>
+ * <code>
+ * protected IDialogSettings getDialogSettings() <br/>
+ * IDialogSettings settings = </code>PLUGINActivator<code>.getDefault().getDialogSettings().getSection(</code>SECTION_NAME<code>); <br/>
+ * if (settings == null) { <br/>
+ * settings = </code>PLUGINActivator<code>.getDefault().getDialogSettings().addNewSection(</code>SECTION_NAME<code>);<br/>
+ * }<br/>
+ * return settings;
+ * </code>
+ * </p><p>
+ * Note that if you use multiple instantiated views (not singleton) or many
+ * views with the same viewer, using the code above they will all have the
+ * same dialog settings thus the last one which is closed will save the state
+ * for all the others.<br/>
+ * If you want to avoid that you can add a view-dependent SECTION_NAME
+ * parameter to the constructor of the VIEWER in the VIEW class and then
+ * use it in the <code>getDialogSettings()</code> method. Here is an example:
+ * </p><p>
+ * In the view class (extending <code>AbstractSTDataView</code>):
+ * </p><p>
+ * <code>
+ * private static final String SETTINGS_SECTION = </code>SECTION_NAME<code>;<br/>
+ * <br/>
+ * protected AbstractSTViewer createAbstractSTViewer(Composite parent) {<br/>
+ * return new MyViewer(parent, SETTINGS_SECTION);<br/>
+ * }
+ * </code>
+ * </p><p>
+ * In the viewer class (extending <code>AbstractST{Tree|Table}Viewer</code>):
+ * </p><p>
+ * <code>
+ * private final String settingsSection;<br/>
+ * <br/>
+ * public CallHierarchyViewer(Composite parent, String settingsSection) {<br/>
+ * super(parent);<br/>
+ * this.settingsSection = settingsSection;<br/>
+ * }<br/>
+ * <br/>
+ * protected IDialogSettings getDialogSettings() <br/>
+ * IDialogSettings settings = </code>PLUGINActivator<code>.getDefault().getDialogSettings().getSection(</code>this.settingsSection<code>); <br/>
+ * if (settings == null) { <br/>
+ * settings = </code>PLUGINActivator<code>.getDefault().getDialogSettings().addNewSection(</code>this.settingsSection<code>);<br/>
+ * }<br/>
+ * return settings;
+ * </code>
+ * </p>
+ *
+ * @return the IDialogSettings used to store/load the dialog state
+ */
+ abstract public IDialogSettings getDialogSettings();
+
+
+ ////////////////////////////////////////////////////////////////
+ // These following methods are intended to be implemented in
+ // AbstractSTTreeViewer and AbstractSTTableViewer because
+ // they are different for the two types of viewers.
+ // They are not intended to be implemented by customer.
+ ////////////////////////////////////////////////////////////////
+
+ // Viewer creation utilities
+
+ /**
+ * The method called to create the wrapped control (TreeViewer, TableViewer)
+ *
+ */
+ abstract protected ColumnViewer createViewer(Composite parent, int style);
+
+ /**
+ * Creates the columns in the control.
+ *
+ */
+ abstract protected void createColumns();
+
+
+ protected CellLabelProvider createColumnLabelProvider(Item column){
+ return new STOwnerDrawLabelProvider(column);
+ }
+
+ // Columns utilities
+
+ /**
+ * Update the direction indicator as column is now the primary column.
+ *
+ * @param column the column that has to be the sorted column
+ */
+ abstract public void updateDirectionIndicator(Item column);
+
+ /**
+ * Get the wrapped viewer's columns order.
+ * Used to get the columns order since the TreeViewer
+ * and the TableViewer don't share the same API
+ * to get the columns.
+ *
+ * @return the columns order of the viewer
+ */
+ abstract public int[] getColumnOrder();
+
+ /**
+ * Set the wrapped viewer's columns order.
+ * Used to set the columns order since the TreeViewer
+ * and the TableViewer don't share the same API
+ * to get the columns.
+ *
+ */
+ abstract protected void setColumnOrder(int[] order);
+
+ /**
+ * Get the wrapped viewer's columns.
+ * Used get the columns list since the TreeViewer
+ * and the TableViewer don't share the same API
+ * to get the columns.
+ *
+ * @return the columns of the viewer
+ */
+ abstract public Item[] getColumns();
+
+ /**
+ * Get the wrapped viewer's column index for a given column.
+ * Used get the columns list since the TreeViewer
+ * and the TableViewer don't share the same API
+ * to get the columns.
+ *
+ * @return the index of the column in the viewer
+ */
+ abstract public int getColumnIndex(Item column);
+
+ /**
+ * Get the width of the target column of the viewer
+ *
+ * @param column A column under the form of an Item object which is the common superclass of TreeColumn and TableColumn
+ *
+ * @return The width of the column
+ */
+ abstract public int getColumnWidth(Item column);
+
+ /**
+ * Set the width of the target column of the viewer
+ *
+ * @param column A column under the form of an Item object which is the common superclass of TreeColumn and TableColumn
+ * @param width The new width
+ */
+ abstract public void setColumnWidth(Item column, int width);
+
+ /**
+ * Set the resizable state of the target column of the viewer
+ *
+ * @param column A column under the form of an Item object which is the common superclass of TreeColumn and TableColumn
+ * @param resizable The new resizable state
+ */
+ abstract public void setColumnResizable(Item column, boolean resizable);
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/ISTDataViewersField.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/ISTDataViewersField.java
new file mode 100644
index 0000000..5350b2f
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/ISTDataViewersField.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.linuxtools.dataviewers.listeners.ISpecialDrawerListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+
+
+/**
+ * This class defines how the data is displayed for a given column.
+ * This renderer is on charge of providing several things:
+ * <ul>
+ * <li>the name of the column header
+ * <li>the tooltip of the column header
+ * <li>It computes the label to display for each object given by the {@link ITreeContentProvider}
+ * <li>It computes the tooltip to display for each object given by the {@link ITreeContentProvider}
+ * <li>It computes the background & foreground color to display for each object given by the {@link ITreeContentProvider}
+ * <li>It computes the image to display for each object given by the {@link ITreeContentProvider}
+ * <li>It provides a comparator, used to compare objects given by the {@link ITreeContentProvider}
+ * <li>It allows a "custom rendering", for example if you want to display percentages as progress bars or to display hyperlink as underlined text
+ * </ul>
+ *
+ * Three abstract implementations are available:
+ * {@link AbstractSTDataViewersField} for default rendering
+ * {@link STAbstractPercentageDrawerField} for displaying percentages as progress bars
+ * {@link STDataViewersHyperLinkDrawerField} for displaying hyperlinks as underlined text
+ */
+public interface ISTDataViewersField {
+ /**
+ * @return String the description of the field.
+ */
+ public String getDescription();
+
+ /**
+ * @return the image associated with the description of the field or <code>null<code>.
+ */
+ public Image getDescriptionImage();
+
+ /**
+ * @return The text to be displayed in the column header for this field.
+ */
+ public String getColumnHeaderText();
+
+ /**
+ * @return The tooltip to be displayed in the column header for this field.
+ */
+ public String getColumnHeaderTooltip();
+
+ /**
+ * @return The image to be displayed in the column header for this field or <code>null<code>.
+ */
+ public Image getColumnHeaderImage();
+
+ /**
+ * @param obj
+ * @return The String value of the object for this particular field displayed to the user.
+ */
+ public String getValue(Object obj);
+
+ /**
+ * @param obj
+ * @return The image value of the object for this particular field displayed to the user
+ * or <code>null<code>.
+ */
+ public Image getImage(Object obj);
+
+ /**
+ * @param obj1
+ * @param obj2
+ * @return Either:
+ * <li>a negative number if the value of obj1 is less than the value of obj2 for this field.
+ * <li><code>0</code> if the value of obj1 and the value of obj2 are equal for this field.
+ * <li>a positive number if the value of obj1 is greater than the value of obj2 for this field.
+ */
+ public int compare(Object obj1, Object obj2);
+
+ /**
+ * Get the default direction for the receiver. Return either
+ * {@link TableComparator#ASCENDING } or {@link TableComparator#DESCENDING }
+ * @return int
+ */
+ public int getDefaultDirection();
+
+ /**
+ * Get the preferred width of the receiver.
+ * @return int
+ */
+ public int getPreferredWidth();
+
+ /**
+ * Return whether the receiver is showing or not.
+ * @return boolean
+ */
+ public boolean isShowing();
+
+ /**
+ * Set whether or not the receiver is showing.
+ * @param showing
+ */
+ public void setShowing(boolean showing);
+
+ /**
+ * Returns special drawer, typically used to:
+ * paint percentages
+ * paint hyperlink
+ * @return a special drawer
+ */
+ public ISpecialDrawerListener getSpecialDrawer(Object element);
+
+ /**
+ * @param element
+ * @return the tooltip to display this particular element.
+ */
+ public String getToolTipText(Object element);
+
+ /**
+ * @param element
+ * @return the background color for the given element
+ */
+ public Color getBackground(Object element);
+
+ /**
+ * @param element
+ * @return the foreground color for the given element
+ */
+ public Color getForeground(Object element);
+
+ /**
+ * Customize the horizontal alignment of the columns.
+ * @return one of: SWT.LEFT, SWT.RIGHT, SWT.CENTER, SWT.NONE
+ * Note that SWT.NONE is equivalent to SWT.LEFT
+ *
+ */
+ public int getAlignment();
+
+ /**
+ * Indicates if the given element is a hyperlink to something as a view, editor, dialog,etc...
+ *
+ */
+ public boolean isHyperLink(Object element);
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java
new file mode 100644
index 0000000..2851902
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporter.java
@@ -0,0 +1,778 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.dataviewers.STDataViewersActivator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Item;
+
+
+/**
+ * This comparator is used to export the data of a STViewer to CSV format file
+ */
+
+public class STDataViewersCSVExporter {
+
+ private final AbstractSTViewer stViewer;
+
+ private PrintStream ps = null;
+
+ private ISTDataViewersField[] fields = null;
+
+ private List<Object> expandedElts = null;
+
+ private Comparator<Object> comparator;
+
+ private Object input = null;
+
+ private IContentProvider contentProvider = null;
+
+ private IDialogSettings state = null;
+
+ private IProgressMonitor monitor;
+
+ private String filePath = null;
+
+ private String CSVSeparator = null;
+
+ private String CSVChildMarker = null;
+
+ private String CSVLastChildMarker = null;
+
+ private String CSVChildLink = null;
+
+ private String CSVNoChildLink = null;
+
+ private String CSVLeafMarker = null;
+
+ private String CSVNodeMarker = null;
+
+ private boolean expandAll = false;
+
+ private boolean showHiddenColumns = false;
+
+ private boolean exportTreePrefix = false;
+
+ /* It creates a new instance of exporter
+ *
+ * @param stViewer
+ */
+ public STDataViewersCSVExporter(AbstractSTViewer stViewer) {
+ this.stViewer = stViewer;
+ this.ps = System.out;
+ this.state = stViewer.getViewerSettings()
+ .getSection(STDataViewersCSVExporterConstants.TAG_SECTION_CSV_EXPORTER);
+ restoreState();
+ }
+
+ /*
+ * Gets from the .setting the export parameters
+ */
+ public void restoreState() {
+ if (state == null) {
+ resetState();
+ return;
+ }
+
+ try {
+ filePath = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_OUTPUT_FILE_PATH);
+ if (filePath == null) {
+ resetState();
+ return;
+ }
+
+ CSVSeparator = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_SEPARATOR);
+ if (CSVSeparator == null) {
+ resetState();
+ return;
+ }
+
+ CSVChildMarker = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_CHILD_MARKER);
+ if (CSVChildMarker == null) {
+ resetState();
+ return;
+ }
+
+ CSVLastChildMarker = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_LAST_CHILD_MARKER);
+ if (CSVLastChildMarker == null) {
+ resetState();
+ return;
+ }
+
+ CSVChildLink = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_CHILD_LINK);
+ if (CSVChildLink == null) {
+ resetState();
+ return;
+ }
+
+ CSVNoChildLink = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_NO_CHILD_LINK);
+ if (CSVNoChildLink == null) {
+ resetState();
+ return;
+ }
+
+ CSVLeafMarker = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_LEAF_MARKER);
+ if (CSVLeafMarker == null) {
+ resetState();
+ return;
+ }
+
+ CSVNodeMarker = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_NODE_MARKER);
+ if (CSVNodeMarker == null) {
+ resetState();
+ return;
+ }
+
+ String temp = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_EXPAND_ALL);
+ if (temp == null) {
+ resetState();
+ return;
+ } else {
+ expandAll = Boolean.parseBoolean(temp);
+ }
+
+ temp = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_SHOW_HIDDEN_COLUMNS);
+ if (temp == null) {
+ resetState();
+ return;
+ } else {
+ showHiddenColumns = Boolean.parseBoolean(temp);
+ }
+
+ if (isTreeViewerExporter()) {
+ temp = state.get(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_TREE_PREFIX);
+ if (temp == null) {
+ resetState();
+ return;
+ } else {
+ exportTreePrefix = Boolean.parseBoolean(temp);
+ }
+ } else {
+ exportTreePrefix = false;
+ }
+
+
+ } catch (NumberFormatException nfe) {
+ IStatus s =
+ new Status(
+ IStatus.WARNING,
+ STDataViewersActivator.PLUGIN_ID,
+ "Invalid parameter, resetting configuration!\n"+nfe.getMessage(),
+ nfe
+ );
+ logStatus(s);
+ resetState();
+ }
+
+ }
+
+ /*
+ * Save into the .setting the export parameters
+ */
+ public void saveState() {
+ if (state == null) {
+ state =
+ stViewer
+ .getViewerSettings()
+ .addNewSection(STDataViewersCSVExporterConstants.TAG_SECTION_CSV_EXPORTER);
+ }
+
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_OUTPUT_FILE_PATH,
+ filePath);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_SEPARATOR,
+ CSVSeparator);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_CHILD_MARKER,
+ CSVChildMarker);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_LAST_CHILD_MARKER,
+ CSVLastChildMarker);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_CHILD_LINK,
+ CSVChildLink);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_NO_CHILD_LINK,
+ CSVNoChildLink);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_LEAF_MARKER,
+ CSVLeafMarker);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_NODE_MARKER,
+ CSVNodeMarker);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_EXPAND_ALL,
+ expandAll);
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_SHOW_HIDDEN_COLUMNS,
+ showHiddenColumns);
+ if (isTreeViewerExporter()) {
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_TREE_PREFIX,
+ exportTreePrefix);
+ } else {
+ state.put(
+ STDataViewersCSVExporterConstants
+ .TAG_EXPORTER_TREE_PREFIX,
+ false);
+ }
+ }
+
+ /*
+ * Sets to default the parameters used during the export
+ */
+ public void resetState() {
+ filePath = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_OUTPUT_FILE_PATH;
+ CSVSeparator = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_SEPARATOR;
+ CSVChildMarker = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_CHILD_MARKER;
+ CSVLastChildMarker = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_LAST_CHILD_MARKER;
+ CSVChildLink = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_CHILD_LINK;
+ CSVNoChildLink = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_NO_CHILD_LINK;
+ CSVLeafMarker = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_LEAF_MARKER;
+ CSVNodeMarker = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_NODE_MARKER;
+ expandAll = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_EXPAND_ALL;
+ showHiddenColumns = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_SHOW_HIDDEN_COLUMNS;
+
+ if (isTreeViewerExporter()) {
+ exportTreePrefix = STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_TREE_PREFIX;
+ } else {
+ exportTreePrefix = false;
+ }
+ }
+
+ private void logStatus(IStatus s) {
+ STDataViewersActivator.getDefault().getLog().log(s);
+ }
+
+ public void exportTo(String filePath) {
+ setFilePath(filePath);
+ export();
+ }
+
+ public void exportTo(String filePath, IProgressMonitor monitor) {
+ setFilePath(filePath);
+ export(monitor);
+ }
+
+ public void export() {
+ export(new NullProgressMonitor());
+ }
+
+ public void export(IProgressMonitor monitor) {
+
+ // monitoring
+ this.monitor = monitor;
+
+ monitor.beginTask(
+ "Exporting to CSV (file: "+ getFilePath()+")",
+ IProgressMonitor.UNKNOWN);
+
+ // save this configuration
+ saveState();
+
+ // init the printStream
+ initPrintStream(filePath);
+
+ // get the viewer's parameters
+ if (monitor != null) {
+ monitor.subTask("collecting viewer's parameters...");
+ }
+ collectViewerParameters();
+
+ // start dumping to csv file
+ dumpColumnHeaders();
+
+ if (input != null) {
+ if (contentProvider instanceof ITreeContentProvider) {
+ ITreeContentProvider treeContentProvider =
+ (ITreeContentProvider)contentProvider;
+ Object[] topElements =
+ treeContentProvider.getElements(input);
+
+ if (topElements != null) {
+
+ // monitoring
+ int work = topElements.length;
+ for (Object element : topElements) {
+ if (treeContentProvider.hasChildren(element)) {
+ work += treeContentProvider.getChildren(element).length;
+ }
+ }
+ if (monitor != null) {
+ monitor.beginTask(
+ "Exporting to CSV (file: "+ getFilePath()+")",
+ work);
+ monitor.subTask("exporting tree data...");
+ }
+
+ // monitoring stuff
+ int tempWork = 0;
+ int workFloor = topElements.length/100;
+ if (workFloor == 0) {
+ workFloor = 1;
+ }
+
+ // exporting tree
+ Arrays.sort(topElements, comparator);
+ for (int i = 0; i < topElements.length; i++) {
+ dumpTreeData(
+ treeContentProvider,
+ topElements[i],
+ "",
+ i==topElements.length-1,
+ true);
+
+ // monitoring
+ if (monitor != null) {
+ tempWork++;
+ if (tempWork >= workFloor) {
+ if (monitor.isCanceled()){
+ ps.close();
+ return;
+ }
+ monitor.worked(tempWork);
+ tempWork = 0;
+ }
+ }
+ }
+
+ //monitoring
+ if (monitor != null && tempWork > 0) {
+ monitor.worked(tempWork);
+ }
+ }
+
+ } else if (contentProvider instanceof IStructuredContentProvider) {
+ IStructuredContentProvider structContentProvider =
+ (IStructuredContentProvider)contentProvider;
+ Object[] topElements =
+ structContentProvider.getElements(input);
+
+ if (topElements != null) {
+
+ // monitoring
+ if (monitor != null) {
+ monitor.beginTask(
+ "Exporting to CSV (file: "+ getFilePath()+")",
+ topElements.length);
+ monitor.subTask("exporting table data...");
+ }
+
+ // monitoring stuff
+ int tempWork = 0;
+ int workFloor = topElements.length/100;
+ if (workFloor == 0) {
+ workFloor = 1;
+ }
+
+ // exporting table
+ Arrays.sort(topElements, comparator);
+ for (int n = 0; n < topElements.length; n++) {
+ if (n < topElements.length -1) {
+ dumpNodeData(topElements[n], CSVChildMarker);
+ } else {
+ dumpNodeData(topElements[n], CSVLastChildMarker);
+ }
+
+ // monitoring
+ if (monitor != null) {
+ tempWork++;
+ if (tempWork >= workFloor) {
+ if (monitor.isCanceled()){
+ ps.close();
+ return;
+ }
+ monitor.worked(tempWork);
+ tempWork = 0;
+ }
+ }
+ }
+
+ //monitoring
+ if (monitor != null && tempWork > 0) {
+ monitor.worked(tempWork);
+ }
+ }
+ }
+ }
+
+ // close the stream
+ ps.close();
+
+ // end monitoring
+ monitor.done();
+
+ IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(getFilePath()));
+ if (c != null){
+ try {
+ c.refreshLocal(1, new NullProgressMonitor());
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private void initPrintStream(String filePath) {
+ try {
+ File outputFile = new File(filePath);
+
+ if (outputFile.exists())
+ outputFile.delete();
+
+ outputFile.createNewFile();
+
+ this.ps = new PrintStream(outputFile);
+
+ } catch (IOException e) {
+ Status s =
+ new Status(
+ IStatus.ERROR,
+ STDataViewersActivator.PLUGIN_ID,
+ "Invalid file! Dumping to stdout...\n"+e.getMessage(),
+ e);
+ logStatus(s);
+ this.ps = System.out;
+ } catch (NullPointerException e) {
+ Status s =
+ new Status(
+ IStatus.ERROR,
+ STDataViewersActivator.PLUGIN_ID,
+ "File has not been set! Dumping to stdout...\n"+e.getMessage(),
+ e);
+ logStatus(s);
+ this.ps = System.out;
+ }
+ }
+
+ private void collectViewerParameters() {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ // getting columns with the right order
+ Item[] unOrdColumns = stViewer.getColumns();
+ Item[] columns = new Item[unOrdColumns.length];
+ int[] columnOrder = stViewer.getColumnOrder();
+ for (int i = 0; i < unOrdColumns.length; i++ ) {
+ columns[i] = unOrdColumns[columnOrder[i]];
+ }
+
+ // getting fields mapping
+ // (before removing hidden columns)
+ Map<Item, ISTDataViewersField> fieldsMap =
+ new HashMap<Item, ISTDataViewersField>();
+ for (Item column : columns) {
+ fieldsMap.put(column, (ISTDataViewersField)column.getData());
+ }
+
+ // creating a GUI-thread-independent comparator
+ comparator =
+ new CSVDataComparator(
+ stViewer.getTableSorter(),
+ fieldsMap);
+
+ // getting only visible columns, using the column order
+ if (!showHiddenColumns) {
+ int[] columnsState = stViewer.getHideShowManager().getColumnsState();
+ List<Item> enabledColumns = new ArrayList<Item>();
+ for (int i = 0; i < columnsState.length; i++) {
+ if (columnsState[columnOrder[i]] == STDataViewersHideShowManager.STATE_SHOWN) {
+ enabledColumns.add(columns[i]);
+ }
+ }
+ columns = enabledColumns.toArray(new Item[enabledColumns.size()]);
+ }
+
+ // collecting fields from columns (ordered & shown)
+ fields = new ISTDataViewersField[columns.length];
+ for (int i = 0; i < columns.length; i++) {
+ fields[i] = (ISTDataViewersField)columns[i].getData();
+ }
+
+ // getting input object
+ input = stViewer.getViewer().getInput();
+
+ // getting content provider
+ contentProvider =
+ stViewer.getViewer().getContentProvider();
+
+ // getting expanded elements if necessary
+ expandedElts = new ArrayList<Object>();
+ if (!expandAll
+ && stViewer.getViewer() instanceof TreeViewer
+ ) {
+ TreeViewer tv =
+ (TreeViewer)stViewer.getViewer();
+ expandedElts =
+ Arrays.asList(tv.getExpandedElements());
+ }
+ }
+ });
+ }
+
+ private void dumpColumnHeaders() {
+ printPrefix("Hierarchy");
+ for (int i = 0; i < fields.length; i++) {
+ ps.print(fields[i].getColumnHeaderText());
+ printSeparator(i, fields.length);
+ }
+ }
+
+ private void dumpTreeData(ITreeContentProvider tcp ,Object element, String prefix, boolean isLastChild, boolean monitoring) {
+ String childMarker = isLastChild ?
+ CSVLastChildMarker
+ : CSVChildMarker;
+
+ boolean isLeaf = !tcp.hasChildren(element);
+ String leafMarker = (isLeaf?CSVLeafMarker:CSVNodeMarker);
+ dumpNodeData(element, prefix + childMarker + leafMarker);
+
+ if ( (expandAll || expandedElts.contains(element)) && !isLeaf) {
+ Object[] children = tcp.getChildren(element);
+ if (children != null) {
+
+ // monitoring stuff
+ int tempWork = 0;
+ int workFloor = children.length/100;
+ if (workFloor == 0) {
+ workFloor = 1;
+ }
+
+ // exporting children
+ Arrays.sort(children, comparator);
+ for (int i = 0; i < children.length; i++ ) {
+ String prefixAdd = isLastChild ?
+ CSVNoChildLink
+ : CSVChildLink;
+ dumpTreeData(tcp, children[i], prefix + prefixAdd, i==children.length-1, false);
+
+ // monitoring
+ if (monitor != null && monitoring) {
+ tempWork++;
+ if (tempWork >= workFloor) {
+ monitor.worked(tempWork);
+ tempWork = 0;
+ }
+ }
+ }
+
+ //monitoring
+ if (monitor != null && monitoring && tempWork > 0) {
+ monitor.worked(tempWork);
+ }
+ }
+ }
+ }
+
+ private void dumpNodeData(Object element, String prefix) {
+ for (int i = 0; i < fields.length; i++) {
+ printNode(i, prefix, getText(i, element));
+ printSeparator(i, fields.length);
+ }
+ }
+
+ private void printNode(int col, String prefix, String text) {
+ if (col == 0) {
+ printPrefix(prefix);
+ }
+ ps.print(text);
+ }
+
+ private void printPrefix(String prefix) {
+ if (exportTreePrefix) {
+ ps.print(prefix);
+ ps.print(CSVSeparator);
+ }
+ }
+
+ private void printSeparator(int i, int length) {
+ if (i == length-1) {
+ ps.print("\n");
+ } else {
+ ps.print(CSVSeparator);
+ }
+ }
+
+ private String getText(int i, Object obj) {
+ return fields[i].getValue(obj);
+ }
+
+ public String getFilePath() {
+ return filePath;
+ }
+
+ public String getCSVSeparator() {
+ return CSVSeparator;
+ }
+
+ public String getCSVChildMarker() {
+ return CSVChildMarker;
+ }
+
+ public String getCSVLastChildMarker() {
+ return CSVLastChildMarker;
+ }
+
+ public String getCSVChildLink() {
+ return CSVChildLink;
+ }
+
+ public String getCSVNoChildLink() {
+ return CSVNoChildLink;
+ }
+
+ public String getCSVLeafMarker() {
+ return CSVLeafMarker;
+ }
+
+ public String getCSVNodeMarker() {
+ return CSVNodeMarker;
+ }
+
+ public boolean getExpandAll() {
+ return expandAll;
+ }
+
+ public boolean getShowHiddenColumns() {
+ return showHiddenColumns;
+ }
+
+ public boolean getExportTreePrefix() {
+ return exportTreePrefix;
+ }
+
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
+
+ public void setCSVSeparator(String separator) {
+ CSVSeparator = separator;
+ }
+
+ public void setCSVChildMarker(String childMarker) {
+ CSVChildMarker = childMarker;
+ }
+
+ public void setCSVLastChildMarker(String lastChildMarker) {
+ CSVLastChildMarker = lastChildMarker;
+ }
+
+ public void setCSVChildLink(String childLink) {
+ CSVChildLink = childLink;
+ }
+
+ public void setCSVNoChildLink(String noChildLink) {
+ CSVNoChildLink = noChildLink;
+ }
+
+ public void setCSVLeafMarker(String leafMarker) {
+ CSVLeafMarker = leafMarker;
+ }
+
+ public void setCSVNodeMarker(String nodeMarker) {
+ CSVNodeMarker = nodeMarker;
+ }
+
+ public void setExpandAll(boolean expandAll) {
+ this.expandAll = expandAll;
+ }
+
+ public void setShowHiddenColumns(boolean showHiddenColumns) {
+ this.showHiddenColumns = showHiddenColumns;
+ }
+
+ public void setExportTreePrefix(boolean exportTreePrefix) {
+ if (isTreeViewerExporter()) {
+ this.exportTreePrefix = exportTreePrefix;
+ } else {
+ this.exportTreePrefix = false;
+ }
+ }
+
+ private class CSVDataComparator extends STDataViewersComparator {
+
+ private Map<Item, ISTDataViewersField> fieldsMap;
+
+ public CSVDataComparator(
+ STDataViewersComparator other,
+ Map<Item, ISTDataViewersField> fieldsMap) {
+ super(other);
+ this.fieldsMap =
+ fieldsMap;
+ }
+
+ protected ISTDataViewersField getField(Item column) {
+ return fieldsMap.get(column);
+ }
+
+ }
+
+ public boolean isTreeViewerExporter() {
+ return stViewer instanceof AbstractSTTreeViewer;
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporterConstants.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporterConstants.java
new file mode 100644
index 0000000..f9ed0fc
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersCSVExporterConstants.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+/*
+ * This interface contains the constants used during an export action
+ */
+public interface STDataViewersCSVExporterConstants {
+ public static final String TAG_SECTION_CSV_EXPORTER = "csv_exporter_section";
+ public static final String TAG_EXPORTER_SEPARATOR = "csv_exporter_separator";
+ public static final String TAG_EXPORTER_CHILD_MARKER = "csv_exporter_child_marker";
+ public static final String TAG_EXPORTER_LAST_CHILD_MARKER = "csv_exporter_last_child_marker";
+ public static final String TAG_EXPORTER_CHILD_LINK = "csv_exporter_child_link";
+ public static final String TAG_EXPORTER_NO_CHILD_LINK = "csv_exporter_no_child_link";
+ public static final String TAG_EXPORTER_OUTPUT_FILE_PATH = "csv_exporter_output_file_path";
+ public static final String TAG_EXPORTER_LEAF_MARKER = "csv_exporter_leaf_marker";
+ public static final String TAG_EXPORTER_NODE_MARKER = "csv_exporter_node_marker";
+ public static final String TAG_EXPORTER_EXPAND_ALL = "csv_exporter_expand_all";
+ public static final String TAG_EXPORTER_SHOW_HIDDEN_COLUMNS = "csv_exporter_show_hidden_columns";
+ public static final String TAG_EXPORTER_TREE_PREFIX = "csv_exporter_tree_prefix";
+
+ public static final String DEFAULT_EXPORTER_SEPARATOR = ";";
+ public static final String DEFAULT_EXPORTER_CHILD_MARKER = "+-";
+ public static final String DEFAULT_EXPORTER_LAST_CHILD_MARKER = "+-";
+ public static final String DEFAULT_EXPORTER_CHILD_LINK = "| ";
+ public static final String DEFAULT_EXPORTER_NO_CHILD_LINK = " ";
+ public static final String DEFAULT_EXPORTER_OUTPUT_FILE_PATH = "./export.csv";
+ public static final String DEFAULT_EXPORTER_LEAF_MARKER = "";
+ public static final String DEFAULT_EXPORTER_NODE_MARKER = "";
+ public static final boolean DEFAULT_EXPORTER_EXPAND_ALL = true;
+ public static final boolean DEFAULT_EXPORTER_SHOW_HIDDEN_COLUMNS = true;
+ public static final boolean DEFAULT_EXPORTER_TREE_PREFIX = true;
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersColumnLabelProvider.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersColumnLabelProvider.java
new file mode 100644
index 0000000..8ef19a4
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersColumnLabelProvider.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.linuxtools.dataviewers.STDataViewersActivator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Item;
+
+
+/**
+ * Label provider, on top of {@link ISTProfField}s
+ */
+public class STDataViewersColumnLabelProvider extends ColumnLabelProvider {
+ private final ISTDataViewersField fields;
+
+ /**
+ * Create a STDataViewersColumnLabelProvider on a field
+ *
+ * @param field
+ */
+ public STDataViewersColumnLabelProvider(Item column) {
+ Object data = column.getData();
+ if (data instanceof ISTDataViewersField) {
+ fields = (ISTDataViewersField)data;
+ } else {
+ STDataViewersActivator.getDefault().getLog().log(
+ new Status(
+ IStatus.ERROR,
+ STDataViewersActivator.PLUGIN_ID,
+ "No ISTDataField associated to Column!"));
+ fields = null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object element) {
+ return fields.getValue(element);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object element) {
+ return fields.getImage(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
+ return fields.getToolTipText(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getBackground(java.lang.Object)
+ */
+ @Override
+ public Color getBackground(Object element) {
+ return fields.getBackground(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getForeground(java.lang.Object)
+ */
+ @Override
+ public Color getForeground(Object element) {
+ return fields.getForeground(element);
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.CellLabelProvider#useNativeToolTip(java.lang.Object)
+ */
+ public boolean useNativeToolTip(Object object) {
+ return true;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersComparator.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersComparator.java
new file mode 100644
index 0000000..cee539d
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersComparator.java
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import java.util.Comparator;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.linuxtools.dataviewers.STDataViewersActivator;
+import org.eclipse.swt.widgets.Item;
+
+
+/**
+ * This comparator is used to reorder the elements provided by the content provider.
+ */
+public class STDataViewersComparator extends ViewerComparator implements Comparator<Object> {
+
+ /** Maximum number of sorters */
+ public static final int MAX_DEPTH = 4;
+
+ /** Tag for ascending direction when sorting */
+ public static final int ASCENDING = 1;
+
+ /** Tag for reverse direction when sorting */
+ public static final int DESCENDING = -1;
+
+ protected final Item[] columns;
+
+ protected int[] priorities;
+
+ protected int[] directions;
+
+ /**
+ * Copy Constructor
+ * @param other
+ */
+ public STDataViewersComparator(STDataViewersComparator other) {
+ this(other.getColumns(), other.getPriorities(), other.getDirections());
+ }
+
+ /**
+ * Constructor
+ * @param properties the columns properties of the viewer
+ */
+ public STDataViewersComparator(Item[] columns) {
+ this(columns, null, null);
+ }
+
+ /**
+ * Constructor
+ * @param properties
+ * @param defaultPriorities
+ * @param defaultDirections
+ */
+ public STDataViewersComparator(Item[] columns, int[] priorities, int[] directions) {
+ this.columns = columns;
+ if (priorities == null || directions == null) {
+ this.priorities = new int[columns.length];
+ this.directions = new int[columns.length];
+ resetState();
+ } else {
+ if (priorities.length == columns.length && directions.length == columns.length) {
+ this.priorities = priorities;
+ this.directions = directions;
+ } else {
+ STDataViewersActivator.getDefault().getLog().log(
+ new Status(
+ IStatus.WARNING,
+ STDataViewersActivator.PLUGIN_ID,
+ "Invalid parameters:" +
+ " priorities and/or directions number don't match with" +
+ " viewer's columns count. Applying defaults settings."
+ ));
+ resetState();
+ }
+ }
+ }
+
+ public void setPriorities(int[] priorities){
+ this.priorities = priorities;
+ }
+
+ public void setDirections(int[] directions){
+ this.directions = directions;
+ }
+
+ /**
+ * Reset the priorities to the default ones
+ */
+ private void resetPriorites() {
+ for (int i = 0; i < this.priorities.length; i++) {
+ this.priorities[i] = i;
+ }
+ }
+
+ /**
+ * Reset the directions to the default ones
+ */
+ private void resetDirections() {
+ for (int i = 0; i < this.directions.length; i++) {
+ this.directions[i] = getField(this.columns[i]).getDefaultDirection();
+ }
+ }
+
+ /**
+ * Resets the directions and priorities of the sorters
+ */
+ public void resetState() {
+ resetDirections();
+ resetPriorites();
+ }
+
+ /**
+ * Change the direction of the first sorter
+ */
+ public void reverseTopPriority() {
+ directions[priorities[0]] *= -1;
+ }
+
+ /**
+ * Sets the top-level sorter
+ * @param property
+ */
+ public void setTopPriority(final Item column, final ISTDataViewersField field) {
+ for (int i = 0; i < columns.length; i++) {
+ if (columns[i].equals(column)) {
+ setTopPriority(i, field);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Sets the top-level sorter
+ * @param priority
+ */
+ public void setTopPriority(final int priority, final ISTDataViewersField field) {
+ if (priority < 0 || priority >= priorities.length) {
+ return;
+ }
+ int index = -1;
+ for (int i = 0; i < priorities.length; i++) {
+ if (priorities[i] == priority) {
+ index = i;
+ }
+ }
+ if (index == -1) {
+ resetState();
+ return;
+ }
+ // shift the array
+ for (int i = index; i > 0; i--) {
+ priorities[i] = priorities[i - 1];
+ }
+ priorities[0] = priority;
+ directions[priority] = field.getDefaultDirection();
+ }
+
+ /** Changes the direction of the top-priority sorter
+ *
+ * @param direction
+ */
+ public void setTopPriorityDirection(int direction) {
+ if (direction == ASCENDING || direction == DESCENDING) {
+ directions[priorities[0]] = direction;
+ }
+ }
+
+ /**
+ * @return the direction of the top-level sorter
+ */
+ public int getTopPriorityDirection() {
+ return directions[priorities[0]];
+ }
+
+ /**
+ * @return the index of the top-level sorter
+ */
+ public int getTopPriority() {
+ return priorities[0];
+ }
+
+ /**
+ * Return the field at the top priority.
+ *
+ * @return IField
+ */
+ public Item getTopColumn() {
+ return columns[getTopPriority()];
+ }
+
+ /**
+ * NOTE: defensive programming: return a copy of the array
+ * @return the current priorities
+ */
+ public int[] getPriorities() {
+ int[] copy = new int[priorities.length];
+ System.arraycopy(priorities, 0, copy, 0, copy.length);
+ return copy;
+ }
+
+ /**
+ * NOTE: defensive programming: return a copy of the array
+ * @return the current directions
+ */
+ public int[] getDirections() {
+ int[] copy = new int[directions.length];
+ System.arraycopy(directions, 0, copy, 0, copy.length);
+ return copy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object o1, Object o2) {
+ return compare(o1, o2, 0 , true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ return compare(e1, e2, 0, true);
+ }
+
+ /**
+ * Compare obj1 and obj2 at depth. If continueSearching continue searching
+ * below depth to continue the comparison.
+ *
+ * @param obj1
+ * @param obj2
+ * @param depth
+ * @param continueSearching
+ * @return int
+ */
+ protected int compare(Object obj1, Object obj2, int depth,
+ boolean continueSearching) {
+ if (depth >= priorities.length) {
+ return 0;
+ }
+
+ int column = priorities[depth];
+ ISTDataViewersField property = getField(columns[column]);
+
+ int result;
+ if (directions[column] >=0)
+ result = property.compare(obj1, obj2);
+ else
+ result = property.compare(obj2,obj1);
+
+ if (result == 0 && continueSearching)
+ return compare(obj1,obj2,depth+1,continueSearching);
+
+ return result;
+ }
+
+ protected ISTDataViewersField getField(Item column) {
+ return (ISTDataViewersField)column.getData();
+ }
+
+ /**
+ * @return IField[] an array of fields
+ */
+ public Item[] getColumns() {
+ return columns;
+ }
+
+ /**
+ * Saves the sort order preferences of the user
+ * in the given {@link IDialogSettings}
+ * @param dialogSettings
+ */
+ public void saveState(IDialogSettings dialogSettings) {
+ if (dialogSettings == null) {
+ return;
+ }
+ IDialogSettings settings = dialogSettings
+ .getSection(STDataViewersSettings.TAG_SECTION_SORTER);
+ if (settings == null) {
+ settings = dialogSettings.addNewSection(STDataViewersSettings.TAG_SECTION_SORTER);
+ }
+ for (int i = 0; i < priorities.length; i++) {
+ settings.put(STDataViewersSettings.TAG_SORTER_PRIORITY_ + i, priorities[i]);
+ settings.put(STDataViewersSettings.TAG_SORTER_DIRECTION_ + i, directions[i]);
+ }
+ }
+
+ /** Restore the sort order preferences of the user
+ * from the given {@link IDialogSettings}
+ * @param dialogSettings
+ */
+ public void restoreState(IDialogSettings dialogSettings) {
+ if (dialogSettings == null) {
+ // no settings section
+ resetState();
+ return;
+ }
+ IDialogSettings settings = dialogSettings
+ .getSection(STDataViewersSettings.TAG_SECTION_SORTER);
+ if (settings == null) {
+ // no settings saved
+ resetState();
+ return;
+ }
+ try {
+ for (int i = 0; i < priorities.length; i++) {
+ String priority = settings.get(STDataViewersSettings.TAG_SORTER_PRIORITY_ + i);
+ if (priority == null) {
+ // no priority data
+ resetState();
+ return;
+ }
+
+ int colIndex = Integer.parseInt(priority);
+ //Make sure it is not old data from a different sized array
+ if(colIndex < columns.length) {
+ priorities[i] = colIndex;
+ } else {
+ // data from a different sized array
+ resetState();
+ return;
+ }
+ String direction = settings.get(STDataViewersSettings.TAG_SORTER_DIRECTION_ + i);
+ if (direction == null) {
+ // no direction data
+ resetState();
+ return;
+ }
+ directions[i] = Integer.parseInt(direction);
+ }
+ } catch (NumberFormatException e) {
+ // invalid entry
+ resetState();
+ return;
+ }
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHideShowManager.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHideShowManager.java
new file mode 100644
index 0000000..c858de0
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHideShowManager.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import java.util.HashMap;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.linuxtools.dataviewers.listeners.STColumnSizeListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Item;
+
+
+/*
+ * This class is used to handle the hide/show column state.
+ * It also handles the save and restore into the .setting
+ */
+public class STDataViewersHideShowManager {
+
+ public static final int STATE_SHOWN = 1;
+
+ public static final int STATE_HIDDEN = 0;
+
+ private int[] defaultColumnsWidth;
+
+ private int[] columnsWidth;
+
+ private int[] columnsState;
+
+ private Item[] columns;
+
+ private AbstractSTViewer stViewer;
+
+ private HashMap<Item,STColumnSizeListener> columnsSizeListener = new HashMap<Item,STColumnSizeListener>();
+
+ /*
+ * Creates a new instance of STDataViewersHideShowManager
+ * Adding a ColumnSizeListener in order handle the column width
+ */
+ public STDataViewersHideShowManager(AbstractSTViewer stViewer) {
+ this.stViewer = stViewer;
+
+ columns = stViewer.getColumns();
+ int[] widths = new int[columns.length];
+ int[] states = new int[columns.length];
+ for (int i = 0; i < columns.length; i++) {
+ widths[i] = stViewer.getColumnWidth(columns[i]);
+ states[i] = STATE_SHOWN;
+ }
+
+ this.columnsWidth = widths;
+ this.columnsState = states;
+
+ this.defaultColumnsWidth = new int[columns.length];
+ for (int i = columns.length; i-->0;) {
+ ISTDataViewersField field = (ISTDataViewersField)columns[i].getData();
+ this.defaultColumnsWidth[i] = field.getPreferredWidth();
+ STColumnSizeListener l = new STColumnSizeListener(this);
+ columnsSizeListener.put(columns[i], l);
+ columns[i].addListener(SWT.Resize, l);
+ columns[i].addDisposeListener(new DisposeListener(){
+
+ public void widgetDisposed(DisposeEvent e) {
+ Item column = (Item)e.widget;
+ column.removeListener(SWT.Resize, columnsSizeListener.get(column));
+
+ }
+
+ });
+ }
+ }
+
+ /*
+ * It saves the hide/show column state inside the .setting
+ */
+ public void saveState(IDialogSettings dialogSettings) {
+ // delete old settings and save new ones
+ IDialogSettings settings = dialogSettings.addNewSection(STDataViewersSettings.TAG_SECTION_HIDESHOW);
+
+ for (int i = 0; i < columnsWidth.length; i++) {
+ settings.put(
+ STDataViewersSettings.TAG_HIDE_SHOW_COLUMN_WIDTH_ + i,
+ columnsWidth[i]);
+ }
+
+ for (int i = 0; i < columnsState.length; i++) {
+ settings.put(
+ STDataViewersSettings.TAG_HIDE_SHOW_COLUMN_STATE_ + i,
+ columnsState[i]);
+ }
+ }
+
+
+ /*
+ * Restores the columns width and the columns state using the columns state saved into the .setting
+ *
+ * @param dialogSettings
+ */
+ public void restoreState(IDialogSettings dialogSettings) {
+ if (dialogSettings == null) {
+ // no settings section
+ resetState();
+ return;
+ }
+
+ IDialogSettings settings = dialogSettings.getSection(STDataViewersSettings.TAG_SECTION_HIDESHOW);
+
+ if (settings == null) {
+ // no settings saved
+ resetState();
+ return;
+ }
+
+ try {
+ for (int i = 0; i < columnsWidth.length; i++) {
+ String width = settings.get(
+ STDataViewersSettings.TAG_HIDE_SHOW_COLUMN_WIDTH_ + i);
+
+ if (width == null) {
+ // no width data
+ resetState();
+ return;
+ }
+
+ columnsWidth[i] = Integer.parseInt(width);
+ }
+
+ for (int i = 0; i < columnsState.length; i++) {
+ String state = settings.get(
+ STDataViewersSettings.TAG_HIDE_SHOW_COLUMN_STATE_ + i);
+
+ if (state == null) {
+ // no state data
+ resetState();
+ return;
+ }
+
+ columnsState[i] = Integer.parseInt(state);
+ }
+ } catch (NumberFormatException nfe) {
+ // invalid entry
+ resetState();
+ return;
+ }
+ }
+
+ /*
+ * It restores the original columns width
+ */
+ private void resetState() {
+ columnsWidth = defaultColumnsWidth;
+ for (int i = 0; i < columnsState.length; i++) {
+ columnsState[i] = STATE_SHOWN;
+ }
+ }
+
+ /*
+ * It sets the column width
+ *
+ * @param index of column
+ * @param width
+ */
+ public void setWidth(int index, int width) {
+ if (columnsState[index] != STATE_HIDDEN) {
+ columnsWidth[index] = width;
+ }
+ // ignore if this column is set to hidden
+ }
+
+ /*
+ * It sets the state of column
+ *
+ * @param index of the column
+ * @state can be: STATE_SHOWN or STATE_HIDDEN
+ */
+ public void setState(int index, int state) {
+ columnsState[index] = state;
+ }
+
+ /*
+ * Gets the column width
+ * @param index of the column
+ */
+ public int getWidth(int index) {
+ return columnsWidth[index];
+ }
+
+ /*
+ * Gets the column state which can be: STATE_SHOWN or STATE_HIDDEN
+ * @param index of the column
+ */
+ public int getState(int index) {
+ return columnsState[index];
+ }
+
+ /*
+ * Gets the all columns width of the STViewer
+ * @return int[]
+ */
+ public int[] getColumnsWidth() {
+ return columnsWidth;
+ }
+
+ /*
+ * Gets the all columns state of the STViewer
+ * @return int[]
+ */
+ public int[] getColumnsState() {
+ return columnsState;
+ }
+
+ /*
+ * Updates the columns width
+ *
+ * @param column
+ */
+ public void updateColumns(Item[] columns) {
+ for (int i = columns.length; i-->0;) {
+ Item column = columns[i];
+ if (getState(i) == STDataViewersHideShowManager.STATE_HIDDEN) {
+ stViewer.setColumnWidth(column, 0);
+ stViewer.setColumnResizable(column, false);
+ } else {
+ stViewer.setColumnWidth(column, getWidth(i));
+ stViewer.setColumnResizable(column, true);
+ }
+ }
+ }
+
+ /*
+ * Gets the STViewer hooked to this Hide/Show Manager
+ * @return AbstractSTViewer
+ */
+ public AbstractSTViewer getSTViewer(){
+ return stViewer;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHyperLinkDrawerField.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHyperLinkDrawerField.java
new file mode 100644
index 0000000..3a935ce
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersHyperLinkDrawerField.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.linuxtools.dataviewers.listeners.ISpecialDrawerListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.TextLayout;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Item;
+
+
+
+/**
+ * A field that implements a hyperlink drawer
+ */
+public abstract class STDataViewersHyperLinkDrawerField extends AbstractSTDataViewersField implements ISpecialDrawerListener {
+
+ @Override
+ public ISpecialDrawerListener getSpecialDrawer(Object element) {
+ if (isHyperLink(element)) return this;
+ else return null;
+ }
+
+ /**
+ * Gets the HyperLink value for the given object, as a string
+ * @param obj
+ * @return a String value
+ */
+ public abstract String getHyperLink(Object obj);
+
+ /**
+ * HyperLink drawer
+ */
+ public void handleEvent(Event event) {
+ Item item = (Item)event.item;
+ String str = getHyperLink(item.getData());
+ final TextStyle styledString = new TextStyle(event.gc.getFont(),null,null);
+ styledString.foreground = event.display.getSystemColor(SWT.COLOR_BLUE);
+ styledString.underline = true;
+ TextLayout tl = new TextLayout(event.display);
+ tl.setText(str);
+
+ tl.setStyle(styledString, 0, str.length());
+ int y = event.y + event.height/2 - event.gc.stringExtent(str).y/2;
+ tl.draw(event.gc, event.x, y);
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersImages.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersImages.java
new file mode 100644
index 0000000..012fbcd
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersImages.java
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.linuxtools.dataviewers.STDataViewersActivator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+
+/*
+ * This class handle the registration of all images used into org.eclipse.linuxtools.dataviewers
+ */
+public class STDataViewersImages {
+ private static ImageRegistry imageRegistry;
+
+ /**
+ * A table of all the <code>ImageDescriptor</code>s.
+ */
+ private static HashMap<String,ImageDescriptor> imageDescriptors;
+
+ /* Declare Common paths */
+ private static URL ICON_BASE_URL= null;
+
+ static {
+ String pathSuffix = "icons/"; //$NON-NLS-1$
+
+ STDataViewersActivator activator = STDataViewersActivator.getDefault();
+ ICON_BASE_URL= activator.getBundle().getEntry(pathSuffix);
+ imageRegistry = activator.getImageRegistry();
+ if (imageRegistry == null)
+ imageRegistry= new ImageRegistry(PlatformUI.getWorkbench().getDisplay());
+ }
+
+ public final static String IMG_EXPORT = "export.gif";
+ public final static String IMG_EDIT_PROPERTIES = "prop_edt.gif";
+ public final static String IMG_PERCENTAGE = "percentage.gif";
+
+ public final static String IMG_SEARCH = "search.gif";
+
+ public final static String IMG_PRINT = "printer.gif";
+ public final static String IMG_LEFT = "left.gif";
+ public final static String IMG_LEFTEND = "left-end.gif";
+ public final static String IMG_RIGHT = "right.gif";
+ public final static String IMG_RIGHTEND = "right-end.gif";
+ public final static String IMG_SAVE_TXT = "IMG_SAVE_TXT";
+
+ public static final String IMG_EXPANDALL = "expand_all.gif";
+ public static final String IMG_COLLAPSEALL = "collapse_all.gif";
+
+ public static final String IMG_FILTER = "filter_ps.gif";
+
+ public static final String IMG_SORT = "sort.gif";
+
+
+ /**
+ * Declare all images
+ */
+ private static void declareImages() {
+ declareRegistryImage(IMG_EXPORT, "export.gif");
+ declareRegistryImage(IMG_EDIT_PROPERTIES, "prop_edt.gif");
+ declareRegistryImage(IMG_PERCENTAGE, "percentage.gif");
+
+ declareRegistryImage(ISharedImages.IMG_OBJS_INFO_TSK, "info_obj.gif");
+ declareRegistryImage(ISharedImages.IMG_TOOL_FORWARD, "forward_nav.gif");
+ declareRegistryImage(ISharedImages.IMG_TOOL_BACK, "backward_nav.gif");
+
+ declareRegistryImage(IMG_SEARCH, "search.gif");
+
+ declareRegistryImage(IMG_PRINT, "printer.gif");
+ declareRegistryImage(IMG_LEFT, "left.gif");
+ declareRegistryImage(IMG_LEFTEND, "left-end.gif");
+ declareRegistryImage(IMG_RIGHT, "right.gif");
+ declareRegistryImage(IMG_RIGHTEND, "right-end.gif");
+
+ declareRegistryImage(IMG_EXPANDALL, "expand_all.gif");
+ declareRegistryImage(IMG_COLLAPSEALL, "collapse_all.gif");
+
+ declareRegistryImage(IMG_FILTER, "filter_ps.gif");
+
+ declareRegistryImage(IMG_SORT, "sort.gif");
+ }
+
+ /**
+ * Declare an Image in the registry table.
+ * @param key The key to use when registering the image
+ * @param path The path where the image can be found. This path is relative to where
+ * this plugin class is found (i.e. typically the packages directory)
+ */
+ private final static void declareRegistryImage(String key, URL path) {
+ ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor();
+ desc= ImageDescriptor.createFromURL(path);
+ imageRegistry.put(key, desc);
+ imageDescriptors.put(key, desc);
+ }
+
+ /**
+ * Declare an Image in the registry table.
+ * @param key The key to use when registering the image
+ * @param path The path where the image can be found. This path is relative to where
+ * this plugin class is found (i.e. typically the packages directory)
+ */
+ private final static void declareRegistryImage(String key, String path) {
+ try {
+ URL url = makeIconFileURL(path);
+ declareRegistryImage(key, url);
+ } catch (MalformedURLException me) {
+ }
+
+ }
+
+ /**
+ * Returns the ImageRegistry.
+ */
+ public static ImageRegistry getImageRegistry() {
+ if (imageRegistry == null) {
+ initializeImageRegistry();
+ }
+ return imageRegistry;
+ }
+
+ /**
+ * Initialize the image registry by declaring all of the required
+ * graphics. This involves creating JFace image descriptors describing
+ * how to create/find the image should it be needed.
+ * The image is not actually allocated until requested.
+ *
+ * Prefix conventions
+ * Wizard Banners WIZBAN_
+ * Preference Banners PREF_BAN_
+ * Property Page Banners PROPBAN_
+ * Color toolbar CTOOL_
+ * Enable toolbar ETOOL_
+ * Disable toolbar DTOOL_
+ * Local enabled toolbar ELCL_
+ * Local Disable toolbar DLCL_
+ * Object large OBJL_
+ * Object small OBJS_
+ * View VIEW_
+ * Product images PROD_
+ * Misc images MISC_
+ *
+ * Where are the images?
+ * The images (typically gifs) are found in the same location as this plugin class.
+ * This may mean the same package directory as the package holding this class.
+ * The images are declared using this.getClass() to ensure they are looked up via
+ * this plugin class.
+ * @see org.eclipse.jface.resource.ImageRegistry
+ */
+ public static ImageRegistry initializeImageRegistry() {
+ imageDescriptors = new HashMap<String,ImageDescriptor>(30);
+ declareImages();
+ return imageRegistry;
+ }
+
+ /**
+ * Returns the <code>Image</code> identified by the given key,
+ * or <code>null</code> if it does not exist.
+ */
+ public static Image getImage(String key) {
+ if (imageDescriptors == null) initializeImageRegistry();
+ return getImageRegistry().get(key);
+ }
+
+ /**
+ * Returns the <code>ImageDescriptor</code> identified by the given key,
+ * or <code>null</code> if it does not exist.
+ */
+ public static ImageDescriptor getImageDescriptor(String key) {
+ if (imageDescriptors == null) {
+ initializeImageRegistry();
+ }
+ return imageDescriptors.get(key);
+ }
+
+ private static URL makeIconFileURL(String iconPath) throws MalformedURLException {
+ if (ICON_BASE_URL == null) {
+ throw new MalformedURLException();
+ }
+
+ return new URL(ICON_BASE_URL, iconPath);
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.java
new file mode 100644
index 0000000..90d8e7a
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.osgi.util.NLS;
+
+public class STDataViewersMessages extends NLS {
+
+ private static final String BUNDLE_NAME= "org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages";
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, STDataViewersMessages.class);
+ }
+
+ public static String exportToCSVAction_title;
+
+ public static String expandAllAction_title;
+ public static String expandSelectionAction_title;
+ public static String collapseAllAction_title;
+ public static String collapseSelectionAction_title;
+ public static String copyToAction_title;
+
+ public static String hideshowDialog_title;
+ public static String hideshowAction_title;
+
+ public static String togglegraphsAction_title;
+
+ public static String sortAction_title;
+
+ public static String filtersAction_title;
+ public static String filtersAction_tooltip;
+ public static String filtersSubMenu_title;
+
+ public static String sortAction_tooltip;
+
+ public static String sortDialog_title;
+ public static String sortDialog_label;
+ public static String sortDialog_columnLabel;
+
+ public static String sortDirectionAscending_text ;
+ public static String sortDirectionAscending_text2;
+ public static String sortDirectionAscending_text3;
+ public static String sortDirectionAscending_text4;
+
+ public static String sortDirectionDescending_text;
+ public static String sortDirectionDescending_text2;
+ public static String sortDirectionDescending_text3;
+ public static String sortDirectionDescending_text4;
+
+ public static String restoreDefaults_text;
+ public static String selectAll_text;
+ public static String deselectAll_text;
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.properties b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.properties
new file mode 100644
index 0000000..eeb78e7
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersMessages.properties
@@ -0,0 +1,37 @@
+exportToCSVAction_title = Export to CSV
+
+expandAllAction_title = Expand All
+expandSelectionAction_title = Expand Selection
+collapseAllAction_title = Collapse All
+collapseSelectionAction_title = Collapse Selection
+copyToAction_title = Copy Selection
+
+hideshowDialog_title = Show/Hide columns
+hideshowAction_title = Show/Hide columns
+
+togglegraphsAction_title = Toggling Graphs...
+
+sortAction_title = &Sorting...
+
+filtersSubMenu_title = &Filters
+filtersAction_title = &Configure Filters...
+filtersAction_tooltip = Configure the filters to be applied to this view
+
+sortAction_tooltip = Sorting
+sortDialog_title = Sorting
+sortDialog_label = Sort by:
+sortDialog_columnLabel = &{0}.
+
+sortDirectionAscending_text = &Ascending
+sortDirectionAscending_text2 = A&scending
+sortDirectionAscending_text3 = As&cending
+sortDirectionAscending_text4 = Asce&nding
+
+sortDirectionDescending_text = &Descending
+sortDirectionDescending_text2 = D&escending
+sortDirectionDescending_text3 = Descend&ing
+sortDirectionDescending_text4 = Descendin&g
+
+restoreDefaults_text = Restore De&faults
+selectAll_text = Select A&ll
+deselectAll_text = Des&elect All
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersSettings.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersSettings.java
new file mode 100644
index 0000000..f08ac23
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STDataViewersSettings.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+
+/*
+ * This class contains the setting tags used to save a STViewer section
+ */
+public class STDataViewersSettings {
+
+ // Viewer settings
+ public static final String TAG_SECTION_VIEWER_STATE = "viewer_state_section"; //$NON-NLS-1$
+ public static final String TAG_VIEWER_STATE_COLUMN_WIDTH_ = "column_width_"; //$NON-NLS-1$
+ public static final String TAG_VIEWER_STATE_COLUMN_ORDER = "column_order"; //$NON-NLS-1$
+ public static final String TAG_VIEWER_STATE_VERTICAL_POSITION = "vertical_position"; //$NON-NLS-1$
+ public static final String TAG_VIEWER_STATE_HORIZONTAL_POSITION = "horizontal_position"; //$NON-NLS-1$
+ // Hide/show columns settings
+ public static String TAG_SECTION_HIDESHOW = "hide_show_section"; //$NON-NLS-1$
+ public static String TAG_HIDE_SHOW_COLUMN_STATE_ = "column_state_"; //$NON-NLS-1$
+ public static String TAG_HIDE_SHOW_COLUMN_WIDTH_ = "column_width_"; //$NON-NLS-1$
+ // Sorter
+ public static final String TAG_SECTION_SORTER = "sorter_section"; //$NON-NLS-1$
+ public static final String TAG_SORTER_PRIORITY_ = "sort_priority_"; //$NON-NLS-1$
+ public static final String TAG_SORTER_DIRECTION_ = "sort_direction_"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STOwnerDrawLabelProvider.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STOwnerDrawLabelProvider.java
new file mode 100644
index 0000000..097c8e3
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/abstractviewers/STOwnerDrawLabelProvider.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.abstractviewers;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.OwnerDrawLabelProvider;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.linuxtools.dataviewers.STDataViewersActivator;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Item;
+
+
+public class STOwnerDrawLabelProvider extends OwnerDrawLabelProvider {
+
+ private final ISTDataViewersField fields;
+
+ public STOwnerDrawLabelProvider(final Item column) {
+ Object data = column.getData();
+
+ if (data instanceof ISTDataViewersField) {
+ fields = (ISTDataViewersField)data;
+ } else {
+ STDataViewersActivator.getDefault().getLog().log(
+ new Status(
+ IStatus.ERROR,
+ STDataViewersActivator.PLUGIN_ID,
+ "No ISTDataField associated to Column!"));
+ fields = null;
+ }
+ }
+
+ public String getText(Object element) {
+ return fields.getValue(element);
+ }
+
+ public Color getBackground(Object element) {
+ return fields.getBackground(element);
+ }
+
+ public Color getForeground(Object element) {
+ return fields.getForeground(element);
+ }
+
+ public Image getImage(Object element) {
+ return fields.getImage(element);
+ }
+
+ public String getToolTipText(Object element) {
+ return fields.getToolTipText(element);
+ }
+
+ public boolean useNativeToolTip(Object object) {
+ return true;
+ }
+
+ protected void measure(Event event, Object element) {
+
+ }
+
+ protected void paint(Event event, Object element) {
+ if (fields.getSpecialDrawer(element) != null){
+ fields.getSpecialDrawer(element).handleEvent(event);
+ }
+ }
+
+ public void update(ViewerCell cell) {
+ if (fields.getSpecialDrawer(cell.getElement()) == null){
+ Object element = cell.getElement();
+ cell.setText(getText(element));
+ cell.setImage(getImage(element));
+ cell.setForeground(getForeground(element));
+ cell.setBackground(getBackground(element));
+ }
+ }
+
+ protected void erase(Event event, Object element) {
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseAllTreeAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseAllTreeAction.java
new file mode 100644
index 0000000..d21cff7
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseAllTreeAction.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+
+
+/**
+ * This action collapse all the tree
+ *
+ */
+public class STCollapseAllTreeAction extends Action {
+
+ private final AbstractSTTreeViewer stViewer;
+
+ /**
+ * Constructor
+ * @param stViewer the stViewer to collapse
+ */
+ public STCollapseAllTreeAction(AbstractSTTreeViewer stViewer) {
+ super(STDataViewersMessages.collapseAllAction_title,
+ STDataViewersImages.getImageDescriptor(STDataViewersImages.IMG_COLLAPSEALL));
+ this.stViewer = stViewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ Object input = stViewer.getViewer().getInput();
+ if (input != null) {
+ stViewer.getViewer().collapseAll();
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseSelectionAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseSelectionAction.java
new file mode 100644
index 0000000..073c315
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCollapseSelectionAction.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+
+
+/**
+ * This action collapse the selected items of the tree
+ *
+ */
+public class STCollapseSelectionAction extends Action {
+
+ private final AbstractSTTreeViewer stViewer;
+
+ /**
+ * Constructor
+ * @param stViewer the stViewer to collapse
+ */
+ public STCollapseSelectionAction(AbstractSTTreeViewer stViewer) {
+ super(STDataViewersMessages.collapseSelectionAction_title,
+ STDataViewersImages.getImageDescriptor(STDataViewersImages.IMG_COLLAPSEALL));
+ this.stViewer = stViewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ TreeSelection selection = (TreeSelection)stViewer.getViewer().getSelection();
+ if (selection != null && selection != TreeSelection.EMPTY) {
+ for (Iterator<?> itSel = selection.iterator(); itSel.hasNext();) {
+ stViewer.getViewer().collapseToLevel(itSel.next(), TreeViewer.ALL_LEVELS);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCopyAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCopyAction.java
new file mode 100644
index 0000000..c9c33ba
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STCopyAction.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+
+public class STCopyAction extends Action {
+ private final AbstractSTViewer stViewer;
+
+ /**
+ * Constructor
+ * @param stViewer the stViewer to expand
+ */
+ public STCopyAction(final AbstractSTViewer stViewer) {
+ super(STDataViewersMessages.copyToAction_title,
+ PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ this.stViewer = stViewer;
+ }
+
+ public void run() {
+ Clipboard cb = new Clipboard(Display.getDefault());
+ ISTDataViewersField[] fields = stViewer.getAllFields();
+ IStructuredSelection selections = (IStructuredSelection)stViewer.getViewer().getSelection();
+ Iterator<?> iterator = selections.iterator();
+ StringBuilder sb = new StringBuilder();
+
+ for(int i=0;iterator.hasNext();i++){
+ Object obj = iterator.next();
+
+ for(int j=0;j<fields.length;j++){
+ if (fields[j].getValue(obj) == null){
+ sb.append("");
+ }
+ else{
+ sb.append(fields[j].getValue(obj));
+ sb.append(" ");
+ }
+ }
+
+ sb.append("\n");
+
+ }
+ cb.setContents(new Object[]{sb.toString()}, new Transfer[] {TextTransfer.getInstance()});
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersFiltersAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersFiltersAction.java
new file mode 100644
index 0000000..d1501dd
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersFiltersAction.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+import org.eclipse.swt.graphics.Image;
+
+
+public class STDataViewersFiltersAction extends Action {
+
+ /**
+ * Creates the action
+ */
+ public STDataViewersFiltersAction() {
+ super(STDataViewersMessages.filtersAction_title);
+ Image img = STDataViewersImages.getImage(STDataViewersImages.IMG_FILTER);
+ super.setImageDescriptor(ImageDescriptor.createFromImage(img));
+ super.setToolTipText(STDataViewersMessages.filtersAction_tooltip);
+ super.setEnabled(true);
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersSortAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersSortAction.java
new file mode 100644
index 0000000..b25410c
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STDataViewersSortAction.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+import org.eclipse.linuxtools.dataviewers.dialogs.STDataViewersSortDialog;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This action allows the user to sort the data in the viewer
+ */
+public class STDataViewersSortAction extends Action {
+
+ private final AbstractSTViewer stViewer;
+
+ private final STDataViewersSortDialog dialog;
+
+ /**
+ * Constructor
+ * @param view
+ * @param dialog
+ */
+ public STDataViewersSortAction(AbstractSTViewer stViewer) {
+ super(STDataViewersMessages.sortAction_title);
+ Image img = STDataViewersImages.getImage(STDataViewersImages.IMG_SORT);
+ super.setImageDescriptor(ImageDescriptor.createFromImage(img));
+ super.setToolTipText(STDataViewersMessages.sortAction_tooltip);
+ this.stViewer = stViewer;
+
+ //building a sort dialog
+ dialog = getSortDialog();
+
+ setEnabled(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ if (dialog.open() == Window.OK && dialog.isDirty()) {
+ BusyIndicator.showWhile(null,new Runnable() {
+ public void run() {
+ stViewer.setComparator(dialog.getSorter());
+ }
+ });
+
+ }
+ }
+
+ /**
+ * Return a sort dialog for the receiver.
+ *
+ * @return TableSortDialog
+ */
+ protected STDataViewersSortDialog getSortDialog() {
+ return new STDataViewersSortDialog(stViewer.getViewer().getControl().getShell(),stViewer.getTableSorter());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandAllTreeAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandAllTreeAction.java
new file mode 100644
index 0000000..738288d
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandAllTreeAction.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+
+
+/**
+ * This action expands all the tree
+ *
+ */
+public class STExpandAllTreeAction extends Action {
+
+ private final AbstractSTTreeViewer stViewer;
+
+ /**
+ * Constructor
+ * @param stViewer the stViewer to expand
+ */
+ public STExpandAllTreeAction(AbstractSTTreeViewer stViewer) {
+ super(STDataViewersMessages.expandAllAction_title,
+ STDataViewersImages.getImageDescriptor(STDataViewersImages.IMG_EXPANDALL));
+ this.stViewer = stViewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ Object input = stViewer.getViewer().getInput();
+ if (input != null) {
+ stViewer.getViewer().expandAll();
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandSelectionAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandSelectionAction.java
new file mode 100644
index 0000000..86ba85a
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExpandSelectionAction.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+
+
+/**
+ * This action expands the selected items of the tree
+ *
+ */
+public class STExpandSelectionAction extends Action {
+
+ private final AbstractSTTreeViewer stViewer;
+
+ /**
+ * Constructor
+ * @param stViewer the stViewer to expand
+ */
+ public STExpandSelectionAction(AbstractSTTreeViewer stViewer) {
+ super(STDataViewersMessages.expandSelectionAction_title,
+ STDataViewersImages.getImageDescriptor(STDataViewersImages.IMG_EXPANDALL));
+ this.stViewer = stViewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ TreeSelection selection = (TreeSelection)stViewer.getViewer().getSelection();
+ if (selection != null && selection != TreeSelection.EMPTY) {
+ for (Iterator<?> itSel = selection.iterator(); itSel.hasNext();) {
+ stViewer.getViewer().expandToLevel(itSel.next(), TreeViewer.ALL_LEVELS);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExportToCSVAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExportToCSVAction.java
new file mode 100644
index 0000000..077f666
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STExportToCSVAction.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersCSVExporter;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+import org.eclipse.linuxtools.dataviewers.dialogs.STDataViewersExportToCSVDialog;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * This action export the STViewers data to CSV format file
+ *
+ */
+public class STExportToCSVAction extends Action {
+
+ private final AbstractSTViewer stViewer;
+
+ private STDataViewersCSVExporter exporter;
+
+ /**
+ * Constructor
+ * @param stViewer the stViewer to export
+ */
+ public STExportToCSVAction(AbstractSTViewer stViewer) {
+ super(STDataViewersMessages.exportToCSVAction_title);
+ Image img = STDataViewersImages.getImage(STDataViewersImages.IMG_EXPORT);
+ super.setImageDescriptor(ImageDescriptor.createFromImage(img));
+
+ this.stViewer = stViewer;
+ this.exporter = new STDataViewersCSVExporter(stViewer);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ STDataViewersExportToCSVDialog dialog =
+ new STDataViewersExportToCSVDialog(stViewer.getViewer().getControl().getShell(), exporter);
+ if (dialog.open() == Dialog.OK) {
+ Job exportToCSVJob =
+ new Job("Export to CSV") {
+ public IStatus run(IProgressMonitor monitor) {
+ exporter.export(monitor);
+ return Status.OK_STATUS;
+ }
+ };
+ exportToCSVJob.setUser(true);
+ exportToCSVJob.schedule();
+ }
+ }
+
+ /**
+ *
+ * @return exporter
+ */
+ public STDataViewersCSVExporter getExporter(){
+ return exporter;
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STHideShowColAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STHideShowColAction.java
new file mode 100644
index 0000000..2b0f584
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/actions/STHideShowColAction.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+import org.eclipse.linuxtools.dataviewers.dialogs.STDataViewersHideShowColumnsDialog;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * This action allows the user to hide/show some columns
+ *
+ */
+public class STHideShowColAction extends Action {
+
+ private final AbstractSTViewer stViewer;
+
+ /**
+ * Constructor
+ * @param stViewer
+ */
+ public STHideShowColAction(AbstractSTViewer stViewer) {
+ super(STDataViewersMessages.hideshowAction_title);
+ this.stViewer = stViewer;
+ Image img = STDataViewersImages.getImage(STDataViewersImages.IMG_EDIT_PROPERTIES);
+ super.setImageDescriptor(ImageDescriptor.createFromImage(img));
+ setEnabled(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run(){
+ STDataViewersHideShowColumnsDialog dialog =
+ new STDataViewersHideShowColumnsDialog(stViewer);
+
+ if (dialog.open() == Window.OK && dialog.isDirty()) {
+ if (dialog.getManager() != null) {
+ stViewer.setHideShowManager(dialog.getManager());
+ }
+ }
+ }
+}
+
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java
new file mode 100644
index 0000000..9ff5573
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersExportToCSVDialog.java
@@ -0,0 +1,675 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.dialogs;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersCSVExporter;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersCSVExporterConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SaveAsDialog;
+
+public class STDataViewersExportToCSVDialog extends Dialog {
+
+ private Text previewText = null;
+
+ private Text outputFile = null;
+
+ private Text separatorText = null;
+
+ private Text childLinkText = null;
+
+ private Text noChildLinkText = null;
+
+ private Text childMarkerText = null;
+
+ private Text lastChildMarkerText = null;
+
+ private Text leafMarkerText = null;
+
+ private Text nodeMarkerText = null;
+
+ private Label childLinkLabel = null;
+
+ private Label noChildLinkLabel = null;
+
+ private Label childMarkerLabel = null;
+
+ private Label lastChildMarkerLabel = null;
+
+ private Label leafMarkerLabel = null;
+
+ private Label nodeMarkerLabel = null;
+
+ private Button expandAllButton = null;
+
+ private Button showHiddenColumnsButton = null;
+
+ private Button exportTreePrefixButton = null;
+
+ private Button restoreDefaults = null;
+
+ private STDataViewersCSVExporter exporter = null;
+
+ private ModifyListener updatePreviewModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updatePreview();
+ }
+ };
+
+ private SelectionListener updatePreviewSelectionListener = new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ updatePreview();
+ }
+ };
+
+ public STDataViewersExportToCSVDialog(
+ Shell parentShell,
+ STDataViewersCSVExporter exporter) {
+ super(parentShell);
+
+ this.setShellStyle(this.getShellStyle() | SWT.RESIZE);
+
+ this.exporter = exporter;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Export to CSV");
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
+ composite.setLayoutData(layoutData);
+ GridLayout layout = new GridLayout(1, false);
+ composite.setLayout(layout);
+
+ if (exporter == null) {
+ return composite;
+ }
+
+ initializeDialogUnits(composite);
+
+ createOutputFileArea(composite);
+ createCSVConfigArea(composite);
+
+ if (exporter.isTreeViewerExporter()) {
+ createTreePrefixConfigArea(composite);
+ }
+
+ createCSVPreviewArea(composite);
+ createRestoreDefaultsButton(composite);
+
+ createSeparatorLine(composite);
+ Dialog.applyDialogFont(composite);
+
+ setDefaultWidgetsValues();
+
+ return composite;
+ }
+
+ private void createOutputFileArea(Composite composite) {
+ Group outputGroup = new Group(composite, SWT.NONE);
+ outputGroup.setText("Output file");
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
+ outputGroup.setLayoutData(layoutData);
+ GridLayout layout = new GridLayout(2, false);
+ outputGroup.setLayout(layout);
+
+ Label outputLabel = new Label(outputGroup, SWT.NONE);
+ outputLabel.setText("Output file:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ outputLabel.setLayoutData(layoutData);
+
+ outputFile = new Text(outputGroup, SWT.BORDER);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ outputFile.setLayoutData(layoutData);
+
+ Composite browseComposite = new Composite(outputGroup, SWT.NONE);
+ layoutData = new GridData(SWT.RIGHT, SWT.FILL, false, false, 2, 1);
+ browseComposite.setLayoutData(layoutData);
+ layout = new GridLayout(2, false);
+ browseComposite.setLayout(layout);
+
+ Button browseOutputButton = new Button(browseComposite, SWT.PUSH);
+ browseOutputButton.setText("File System...");
+ browseOutputButton.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse();
+ }
+ }
+ );
+ layoutData = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1);
+ browseOutputButton.setLayoutData(layoutData);
+
+ Button browseOutputInWorkspaceButton = new Button(browseComposite, SWT.PUSH);
+ browseOutputInWorkspaceButton.setText("Workspace...");
+ browseOutputInWorkspaceButton.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowseWorkspace();
+ }
+ }
+ );
+ layoutData = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1);
+ browseOutputInWorkspaceButton.setLayoutData(layoutData);
+ }
+
+ private void createCSVConfigArea(Composite composite) {
+ Group configGroup = new Group(composite, SWT.NONE);
+ configGroup.setText("CSV Configuration");
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
+ configGroup.setLayoutData(layoutData);
+ GridLayout layout = new GridLayout(2, false);
+ configGroup.setLayout(layout);
+
+ Label separatorLabel = new Label(configGroup, SWT.NONE);
+ separatorLabel.setText("CSV Separator:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ separatorLabel.setLayoutData(layoutData);
+
+ separatorText = new Text(configGroup, SWT.BORDER);
+ separatorText.setFont(JFaceResources.getTextFont());
+ separatorText.addModifyListener(updatePreviewModifyListener);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ separatorText.setLayoutData(layoutData);
+
+ if (exporter.isTreeViewerExporter()){
+ expandAllButton = new Button(configGroup, SWT.CHECK);
+ expandAllButton.setText("Expand All");
+ layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
+ expandAllButton.setLayoutData(layoutData);
+ }
+ else{
+ new Label(configGroup,SWT.NONE).setText(" ");
+ }
+
+ showHiddenColumnsButton = new Button(configGroup, SWT.CHECK);
+ showHiddenColumnsButton.setText("Export Hidden Columns");
+ layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
+ showHiddenColumnsButton.setLayoutData(layoutData);
+ }
+
+ private void createTreePrefixConfigArea(Composite composite) {
+ Group prefixConfigGroup = new Group(composite, SWT.NONE);
+ prefixConfigGroup.setText("Tree ascii-art drawing");
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
+ prefixConfigGroup.setLayoutData(layoutData);
+ GridLayout layout = new GridLayout(5, false);
+ prefixConfigGroup.setLayout(layout);
+
+ exportTreePrefixButton = new Button(prefixConfigGroup, SWT.CHECK);
+ exportTreePrefixButton.setText("Export ascii-art tree");
+ exportTreePrefixButton.addSelectionListener(updatePreviewSelectionListener);
+ exportTreePrefixButton.addSelectionListener(
+ new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ boolean enabled = exportTreePrefixButton.getSelection();
+ enableTreePrefixText(enabled);
+ }
+ }
+ );
+ layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1);
+ exportTreePrefixButton.setLayoutData(layoutData);
+
+ Label blankLabel = new Label(prefixConfigGroup, SWT.NONE);
+ blankLabel.setText("");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
+ blankLabel.setLayoutData(layoutData);
+
+ childLinkLabel = new Label(prefixConfigGroup, SWT.NONE);
+ childLinkLabel.setText("Child Link:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ childLinkLabel.setLayoutData(layoutData);
+
+ childLinkText = new Text(prefixConfigGroup, SWT.BORDER);
+ childLinkText.setFont(JFaceResources.getTextFont());
+ childLinkText.addModifyListener(updatePreviewModifyListener);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ childLinkText.setLayoutData(layoutData);
+
+ Label separator = new Label(prefixConfigGroup, SWT.SEPARATOR | SWT.VERTICAL);
+ layoutData = new GridData(SWT.CENTER, SWT.FILL, false, true, 1, 3);
+ separator.setLayoutData(layoutData);
+
+ noChildLinkLabel = new Label(prefixConfigGroup, SWT.NONE);
+ noChildLinkLabel.setText("No-child Link:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ noChildLinkLabel.setLayoutData(layoutData);
+
+ noChildLinkText = new Text(prefixConfigGroup, SWT.BORDER);
+ noChildLinkText.setFont(JFaceResources.getTextFont());
+ noChildLinkText.addModifyListener(updatePreviewModifyListener);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ noChildLinkText.setLayoutData(layoutData);
+
+ childMarkerLabel = new Label(prefixConfigGroup, SWT.NONE);
+ childMarkerLabel.setText("Child Marker:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ childMarkerLabel.setLayoutData(layoutData);
+
+ childMarkerText = new Text(prefixConfigGroup, SWT.BORDER);
+ childMarkerText.setFont(JFaceResources.getTextFont());
+ childMarkerText.addModifyListener(updatePreviewModifyListener);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ childMarkerText.setLayoutData(layoutData);
+
+ lastChildMarkerLabel = new Label(prefixConfigGroup, SWT.NONE);
+ lastChildMarkerLabel.setText("Last child Marker:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ lastChildMarkerLabel.setLayoutData(layoutData);
+
+ lastChildMarkerText = new Text(prefixConfigGroup, SWT.BORDER);
+ lastChildMarkerText.setFont(JFaceResources.getTextFont());
+ lastChildMarkerText.addModifyListener(updatePreviewModifyListener);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ lastChildMarkerText.setLayoutData(layoutData);
+
+ leafMarkerLabel = new Label(prefixConfigGroup, SWT.NONE);
+ leafMarkerLabel.setText("Leaf Marker:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ leafMarkerLabel.setLayoutData(layoutData);
+
+ leafMarkerText = new Text(prefixConfigGroup, SWT.BORDER);
+ leafMarkerText.setFont(JFaceResources.getTextFont());
+ leafMarkerText.addModifyListener(updatePreviewModifyListener);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ leafMarkerText.setLayoutData(layoutData);
+
+ nodeMarkerLabel = new Label(prefixConfigGroup, SWT.NONE);
+ nodeMarkerLabel.setText("Non-leaf Marker:");
+ layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ nodeMarkerLabel.setLayoutData(layoutData);
+
+ nodeMarkerText = new Text(prefixConfigGroup, SWT.BORDER);
+ nodeMarkerText.setFont(JFaceResources.getTextFont());
+ nodeMarkerText.addModifyListener(updatePreviewModifyListener);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ nodeMarkerText.setLayoutData(layoutData);
+ }
+
+ private void createCSVPreviewArea(Composite composite) {
+ Group previewGroup = new Group(composite, SWT.NONE);
+ previewGroup.setText("Preview");
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
+ previewGroup.setLayoutData(layoutData);
+ GridLayout layout = new GridLayout(1, false);
+ previewGroup.setLayout(layout);
+
+ previewText = new Text(previewGroup, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ previewText.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
+ previewText.setFont(JFaceResources.getTextFont());
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 8);
+ previewText.setLayoutData(layoutData);
+ }
+
+ private void createRestoreDefaultsButton(Composite composite) {
+ restoreDefaults = new Button(composite, SWT.NONE);
+ restoreDefaults.setText("Restore Defaults");
+ restoreDefaults.addSelectionListener(
+ new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ restoreDefaults();
+ }
+ });
+ GridData layoutData = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1);
+ restoreDefaults.setLayoutData(layoutData);
+ }
+
+ private void restoreDefaults() {
+ outputFile.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_OUTPUT_FILE_PATH);
+ separatorText.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_SEPARATOR);
+
+ showHiddenColumnsButton.setSelection(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_SHOW_HIDDEN_COLUMNS);
+
+ if (exporter.isTreeViewerExporter()) {
+ expandAllButton.setSelection(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_EXPAND_ALL);
+ childMarkerText.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_CHILD_MARKER);
+ lastChildMarkerText.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_LAST_CHILD_MARKER);
+ childLinkText.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_CHILD_LINK);
+ noChildLinkText.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_NO_CHILD_LINK);
+ leafMarkerText.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_LEAF_MARKER);
+ nodeMarkerText.setText(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_NODE_MARKER);
+ exportTreePrefixButton.setSelection(
+ STDataViewersCSVExporterConstants.DEFAULT_EXPORTER_TREE_PREFIX);
+ enableTreePrefixText(
+ exportTreePrefixButton.getSelection());
+ }
+
+ updatePreview();
+ }
+
+ private void setDefaultWidgetsValues() {
+ outputFile.setText(
+ exporter.getFilePath());
+
+ showHiddenColumnsButton.setSelection(
+ exporter.getShowHiddenColumns());
+ separatorText.setText(
+ inactivateSpecialChars(exporter.getCSVSeparator()));
+
+ if (exporter.isTreeViewerExporter()) {
+ expandAllButton.setSelection(
+ exporter.getExpandAll());
+
+ exportTreePrefixButton.setSelection(
+ exporter.getExportTreePrefix());
+ childLinkText.setText(
+ inactivateSpecialChars(exporter.getCSVChildLink()));
+ childMarkerText.setText(
+ inactivateSpecialChars(exporter.getCSVChildMarker()));
+ lastChildMarkerText.setText(
+ inactivateSpecialChars(exporter.getCSVLastChildMarker()));
+ noChildLinkText.setText(
+ inactivateSpecialChars(exporter.getCSVNoChildLink()));
+ leafMarkerText.setText(
+ inactivateSpecialChars(exporter.getCSVLeafMarker()));
+ nodeMarkerText.setText(
+ inactivateSpecialChars(exporter.getCSVNodeMarker()));
+ enableTreePrefixText(
+ exportTreePrefixButton.getSelection());
+ }
+
+ updatePreview();
+ }
+
+ private void updatePreview() {
+ if (exporter.isTreeViewerExporter()) {
+ previewText.setText(
+ createPreview(
+ separatorText.getText(),
+ childMarkerText.getText(),
+ lastChildMarkerText.getText(),
+ nodeMarkerText.getText(),
+ leafMarkerText.getText(),
+ childLinkText.getText(),
+ noChildLinkText.getText(),
+ exportTreePrefixButton.getSelection()));
+ } else {
+ previewText.setText(
+ createPreview(
+ separatorText.getText(),
+ null, null, null, null, null, null,
+ false));
+ }
+ }
+
+ public String createPreview(
+ String Separator,
+ String childMarker,
+ String lastChildMarker,
+ String nodeMarker,
+ String leafMarker,
+ String childLink,
+ String noChildLink,
+ boolean exportTreePrefix)
+ {
+ String preview = "";
+
+
+ if (exportTreePrefix) {
+ preview += "Hierarchy"+Separator;
+ }
+
+ preview += "col_1"+Separator+"col_2"+"\n";
+
+ if (exportTreePrefix) {
+ preview += childMarker+nodeMarker+Separator;
+ }
+
+ preview += "A1"+Separator+"B1"+"\n";
+
+ if (exportTreePrefix) {
+ preview += childLink+lastChildMarker+leafMarker+Separator;
+ }
+
+ preview += "A11"+Separator+"B11"+"\n";
+
+ if (exportTreePrefix) {
+ preview += lastChildMarker+nodeMarker+Separator;
+ }
+
+ preview += "A2"+Separator+"B2"+"\n";
+
+ if (exportTreePrefix) {
+ preview += noChildLink+childMarker+leafMarker+Separator;
+ }
+
+ preview += "A21"+Separator+"B21"+"\n";
+
+ if (exportTreePrefix) {
+ preview += noChildLink+childMarker+nodeMarker+Separator;
+ }
+
+ preview += "A22"+Separator+"B22"+"\n";
+
+ if (exportTreePrefix) {
+ preview += noChildLink+childLink+lastChildMarker+leafMarker+Separator;
+ }
+
+ preview += "A221"+Separator+"B221"+"\n";
+
+ if (exportTreePrefix) {
+ preview += noChildLink+lastChildMarker+leafMarker+Separator;
+ }
+
+ preview += "A23"+Separator+"B23";
+
+ return activateSpecialChars(preview);
+ }
+
+ private void enableTreePrefixText(boolean enabled) {
+ childLinkText.setEnabled(enabled);
+ noChildLinkText.setEnabled(enabled);
+ childMarkerText.setEnabled(enabled);
+ lastChildMarkerText.setEnabled(enabled);
+ leafMarkerText.setEnabled(enabled);
+ nodeMarkerText.setEnabled(enabled);
+
+ childLinkLabel.setEnabled(enabled);
+ noChildLinkLabel.setEnabled(enabled);
+ childMarkerLabel.setEnabled(enabled);
+ lastChildMarkerLabel.setEnabled(enabled);
+ leafMarkerLabel.setEnabled(enabled);
+ nodeMarkerLabel.setEnabled(enabled);
+ }
+
+ @Override
+ protected void okPressed() {
+ File f = new File(outputFile.getText());
+ if (f.exists()) {
+ MessageDialog dialog =
+ new MessageDialog(
+ this.getShell(),
+ "Warning: file already exists",
+ null,
+ "File \"" +
+ f.getAbsolutePath() +
+ "\" already exists.\n" +
+ "Overwrite it anyway?",
+ MessageDialog.WARNING,
+ new String[] {"OK", "Cancel"}, 1
+ );
+ if (dialog.open() > 0) {
+ return;
+ }
+ }
+
+ if (isDirty()) {
+ saveExporterSettings();
+ }
+ super.okPressed();
+ }
+
+ private String activateSpecialChars(String text) {
+ String result = text.replace("\\t", "\t");
+ result = result.replace("\\n", "\n");
+
+ return result;
+ }
+
+ private String inactivateSpecialChars(String text) {
+ String result = text.replace("\t", "\\t");
+ result = result.replace("\n", "\\n");
+
+ return result;
+ }
+
+ private void saveExporterSettings() {
+ exporter.setFilePath(
+ outputFile.getText());
+
+ exporter.setShowHiddenColumns(
+ showHiddenColumnsButton.getSelection());
+ exporter.setCSVSeparator(
+ activateSpecialChars(separatorText.getText()));
+
+ if (exporter.isTreeViewerExporter()) {
+ exporter.setExpandAll(
+ expandAllButton.getSelection());
+ exporter.setExportTreePrefix(
+ exportTreePrefixButton.getSelection());
+ exporter.setCSVChildLink(
+ activateSpecialChars(childLinkText.getText()));
+ exporter.setCSVChildMarker(
+ activateSpecialChars(childMarkerText.getText()));
+ exporter.setCSVLastChildMarker(
+ activateSpecialChars(lastChildMarkerText.getText()));
+ exporter.setCSVNoChildLink(
+ activateSpecialChars(noChildLinkText.getText()));
+ exporter.setCSVLeafMarker(
+ activateSpecialChars(leafMarkerText.getText()));
+ exporter.setCSVNodeMarker(
+ activateSpecialChars(nodeMarkerText.getText()));
+ }
+ }
+
+ /**
+ * @return boolean
+ */
+ private boolean isDirty() {
+ if (exporter.isTreeViewerExporter()) {
+ return !(
+ exporter.getFilePath().equals(outputFile.getText())
+ &&
+ exporter.getCSVChildLink().equals(childLinkText.getText())
+ &&
+ exporter.getCSVChildMarker().equals(childMarkerText.getText())
+ &&
+ exporter.getCSVLastChildMarker().equals(lastChildMarkerText.getText())
+ &&
+ exporter.getCSVNoChildLink().equals(noChildLinkText.getText())
+ &&
+ exporter.getCSVSeparator().equals(separatorText.getText())
+ &&
+ exporter.getCSVLeafMarker().equals(leafMarkerText.getText())
+ &&
+ exporter.getCSVNodeMarker().equals(nodeMarkerText.getText())
+ &&
+ exporter.getExpandAll() == expandAllButton.getSelection()
+ &&
+ exporter.getShowHiddenColumns() == showHiddenColumnsButton.getSelection()
+ &&
+ exporter.getExportTreePrefix() == exportTreePrefixButton.getSelection()
+ &&
+ exporter.getExpandAll() == expandAllButton.getSelection()
+ );
+ } else {
+ return !(
+ exporter.getFilePath().equals(outputFile.getText())
+ &&
+ exporter.getCSVSeparator().equals(separatorText.getText())
+ &&
+ exporter.getShowHiddenColumns() == showHiddenColumnsButton.getSelection()
+ );
+ }
+ }
+
+ private void createSeparatorLine(Composite parent) {
+ Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_CENTER));
+ }
+
+ private void handleBrowseWorkspace() {
+ SaveAsDialog dialog = new SaveAsDialog(getShell());
+ dialog.setTitle("Output file");
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ IPath p = dialog.getResult();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IFile file = workspace.getRoot().getFile(p);
+ outputFile.setText(file.getLocation().toOSString());
+ }
+ }
+
+ private void handleBrowse() {
+ FileDialog dialog = new FileDialog(this.getShell(),SWT.OPEN|SWT.SAVE);
+ dialog.setText("Select output file");
+ dialog.setFilterExtensions(new String[] {"*.csv", "*.*"});
+ String t = outputFile.getText();
+ File f = new File(t);
+ t = f.getParent();
+ dialog.setFilterPath(t);
+ String s = dialog.open();
+ if (s != null) outputFile.setText(s);
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersHideShowColumnsDialog.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersHideShowColumnsDialog.java
new file mode 100644
index 0000000..3cdb6bd
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersHideShowColumnsDialog.java
@@ -0,0 +1,254 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersHideShowManager;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+import org.eclipse.swt.SWT;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * This dialog allows the user to show/hide some columns of the viewer
+ * The status of shown/hidden columns is saved in the dialog settings of the view.
+ *
+ */
+public class STDataViewersHideShowColumnsDialog extends Dialog {
+
+ private boolean dirty;
+
+ private STDataViewersHideShowManager manager;
+
+ private CheckboxTableViewer checkButtonsTable;
+
+ private Button selectAllButton;
+
+ private Button deselectAllButton;
+
+ private AbstractSTViewer stViewer;
+
+ /**
+ * Constructor
+ * @param parentShell
+ * @param view
+ */
+ public STDataViewersHideShowColumnsDialog(
+ AbstractSTViewer stViewer) {
+ super(stViewer.getViewer().getControl().getShell());
+ this.dirty = false;
+ this.stViewer = stViewer;
+ this.manager = stViewer.getHideShowManager();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Window.
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(STDataViewersMessages.hideshowDialog_title);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1);
+ composite.setLayoutData(layoutData);
+ GridLayout layout = new GridLayout(2, true);
+ composite.setLayout(layout);
+
+ initializeDialogUnits(composite);
+
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+ checkButtonsTable = createCheckboxTable(composite, layoutData);
+ checkButtonsTable.setInput(stViewer.getColumns());
+ checkButtonsTable.addCheckStateListener(checkStateListener);
+
+ selectAllButton = new Button(composite, SWT.NONE);
+ selectAllButton.setText(STDataViewersMessages.selectAll_text);
+ selectAllButton.addSelectionListener(
+ new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ markDirty();
+ checkButtonsTable.setAllChecked(true);
+ }
+ }
+ );
+ layoutData = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
+ selectAllButton.setLayoutData(layoutData);
+
+ deselectAllButton = new Button(composite, SWT.NONE);
+ deselectAllButton.setText(STDataViewersMessages.deselectAll_text);
+ deselectAllButton.addSelectionListener(
+ new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ markDirty();
+ checkButtonsTable.setAllChecked(false);
+ }
+ }
+ );
+ layoutData = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
+ deselectAllButton.setLayoutData(layoutData);
+
+ createSeparatorLine(composite);
+ Dialog.applyDialogFont(composite);
+
+ setDefaultWidgetsValues();
+
+ return composite;
+ }
+
+ private void setDefaultWidgetsValues() {
+ Item[] columns = stViewer.getColumns();
+ for (int i = columns.length; i-->0;) {
+ boolean state = (manager.getState(i) == STDataViewersHideShowManager.STATE_SHOWN);
+ checkButtonsTable.setChecked(columns[i], state);
+ }
+ }
+
+ private ICheckStateListener checkStateListener = new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ markDirty();
+ }
+ };
+
+ /**
+ * Creates a separator line above the OK/Cancel buttons bar
+ *
+ * @param parent
+ * the parent composite
+ */
+ protected void createSeparatorLine(Composite parent) {
+ GridLayout parentLayout = (GridLayout)parent.getLayout();
+
+ // Build the separator line
+ Label separator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, parentLayout.numColumns, 1);
+ separator.setLayoutData(layoutData);
+ }
+
+ private CheckboxTableViewer createCheckboxTable(Composite parent, GridData layoutData) {
+ CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(
+ parent,
+ SWT.SINGLE
+ | SWT.HIDE_SELECTION
+ | SWT.H_SCROLL
+ | SWT.V_SCROLL
+ | SWT.BORDER);
+ tableViewer.getControl().setLayoutData(layoutData);
+
+ tableViewer.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof Item[]) {
+ Item[] columns = (Item[])inputElement;
+ int[] order = stViewer.getColumnOrder();
+ Item[] elements = new Item[columns.length];
+
+ // sort the columns according to their actual display order
+ for (int i = columns.length; i-->0;) {
+ elements[i] = columns[order[i]];
+ }
+
+ return elements;
+ }
+ return new Object[]{};
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+
+ tableViewer.setLabelProvider(new LabelProvider() {
+ public String getText(Object element) {
+ if (element instanceof Item) {
+ Item column = (Item)element;
+
+ if (manager.getWidth(stViewer.getColumnIndex(column)) == 0) {
+ return column.getText() + " (width = 0)";
+ }
+ return column.getText();
+ }
+ return element.toString();
+ }
+ });
+
+ return tableViewer;
+ }
+
+ @Override
+ public int open() {
+ dirty = false;
+ return super.open();
+ }
+
+ @Override
+ protected void okPressed() {
+ if (isDirty()) {
+ saveManagerSettings();
+ }
+ super.okPressed();
+ }
+
+ private void saveManagerSettings() {
+ Item[] columns = stViewer.getColumns();
+ for (int i = columns.length; i-->0;) {
+ int state = checkButtonsTable.getChecked(columns[i])?
+ STDataViewersHideShowManager.STATE_SHOWN :
+ STDataViewersHideShowManager.STATE_HIDDEN;
+ manager.setState(i, state);
+ }
+ }
+
+ /**
+ * @return the hideShowManager
+ */
+ public STDataViewersHideShowManager getManager() {
+ return manager;
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ /**
+ * Sets the dirty flag to true.
+ */
+ public void markDirty() {
+ dirty = true;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java
new file mode 100644
index 0000000..30b147d
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/dialogs/STDataViewersSortDialog.java
@@ -0,0 +1,361 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersComparator;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersMessages;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Control;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * This dialog is used to choose how the data is sorted in the viewer
+ *
+ */
+public class STDataViewersSortDialog extends TrayDialog {
+
+ private final STDataViewersComparator sorter;
+
+ private Combo[] priorityCombos;
+
+ private Button[] ascendingButtons;
+
+ private Button[] descendingButtons;
+
+ private boolean dirty;
+
+ /**
+ * Create a new instance of the receiver.
+ * @param parentShell
+ * @param sorter
+ */
+ public STDataViewersSortDialog(Shell parentShell, STDataViewersComparator sorter) {
+ super(parentShell);
+ this.sorter = sorter;
+ this.dirty = false;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Window.
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(STDataViewersMessages.sortDialog_title);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ if (sorter == null) {
+ return composite;
+ }
+
+ initializeDialogUnits(composite);
+
+ createPrioritiesArea(composite);
+ createRestoreDefaultsButton(composite);
+ createSeparatorLine(composite);
+
+ Dialog.applyDialogFont(composite);
+
+ return composite;
+ }
+
+ /**
+ * Create the proirities area.
+ * @param parent
+ */
+ private void createPrioritiesArea(Composite parent) {
+ Composite prioritiesArea = new Composite(parent, SWT.NULL);
+ prioritiesArea.setLayout(new GridLayout(3, false));
+
+ int[] priorities = sorter.getPriorities();
+
+ ascendingButtons = new Button[priorities.length];
+ descendingButtons = new Button[priorities.length];
+ priorityCombos = new Combo[Math.min(priorities.length,
+ STDataViewersComparator.MAX_DEPTH)];
+
+ Label sortByLabel = new Label(prioritiesArea, SWT.NULL);
+ sortByLabel.setText(STDataViewersMessages.sortDialog_label);
+ GridData data = new GridData();
+ data.horizontalSpan = 3;
+ sortByLabel.setLayoutData(data);
+
+ for (int i = 0; i < priorityCombos.length; i++) {
+ final int index = i;
+ Label numberLabel = new Label(prioritiesArea, SWT.NULL);
+ numberLabel
+ .setText(NLS
+ .bind(STDataViewersMessages.sortDialog_columnLabel, new Integer(i + 1)));
+
+ priorityCombos[i] = new Combo(prioritiesArea, SWT.READ_ONLY);
+ priorityCombos[i].setLayoutData(new GridData(
+ GridData.FILL_HORIZONTAL));
+
+ Composite directionGroup = new Composite(prioritiesArea, SWT.NONE);
+ directionGroup.setLayout(new GridLayout(2, false));
+
+ ascendingButtons[i] = new Button(directionGroup, SWT.RADIO);
+ ascendingButtons[i].setText(getAscendingText(i));
+ ascendingButtons[i].addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ markDirty();
+ }
+ });
+ descendingButtons[i] = new Button(directionGroup, SWT.RADIO);
+ descendingButtons[i].setText(getDescendingText(i));
+ descendingButtons[i].addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ markDirty();
+ }
+ });
+
+ if (i < priorityCombos.length - 1) {
+ priorityCombos[i].addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ List<String> allItems = new ArrayList<String>(
+ Arrays.asList(priorityCombos[index].getItems()));
+ computeSelectionItems(index, allItems);
+ markDirty();
+ }
+
+ private void computeSelectionItems(int index,
+ List<String> allItems) {
+ // if not after the last
+ if (index < priorityCombos.length) {
+ // target combo
+ Combo priorityCombo = priorityCombos[index];
+ // target combo's "old selection" (current selection)
+ String oldSelection = priorityCombo.getItem(priorityCombo.getSelectionIndex());
+ // setting new items list
+ priorityCombo.setItems(
+ allItems.toArray(new String[allItems.size()]));
+
+ if (allItems.contains(oldSelection)) {
+ // old selection can be kept.
+ String newSelection = oldSelection;
+ priorityCombo.select(
+ allItems.indexOf(oldSelection));
+ allItems.remove(newSelection);
+ } else {
+ // old selection has been removed by another combo.
+ // selecting a new element (the first) in the items list.
+ String newSelection = allItems.get(0);
+ priorityCombo.select(0);
+ allItems.remove(newSelection);
+ }
+ computeSelectionItems(index+1, allItems);
+ }
+ }
+ });
+ } else {
+ priorityCombos[i].addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ markDirty();
+ }
+ });
+ }
+ }
+
+ // set widget's values from sorter data
+ // (combos and radio buttons)
+ updateUIFromSorter();
+ }
+
+ /**
+ * Get the descending label for the Descending field
+ * at i. Use the index to determine the mnemonic.
+ * @param index
+ * @return String
+ */
+ private String getDescendingText(int index) {
+ switch (index) {
+ case 1:
+ return STDataViewersMessages.sortDirectionDescending_text2;
+ case 2:
+ return STDataViewersMessages.sortDirectionDescending_text3;
+ case 3:
+ return STDataViewersMessages.sortDirectionDescending_text4;
+ default:
+ return STDataViewersMessages.sortDirectionDescending_text;
+ }
+
+}
+
+ /**
+ * Get the ascending label for the Ascending field
+ * at i. Use the index to determine the mnemonic.
+ * @param index
+ * @return String
+ */
+ private String getAscendingText(int index) {
+ switch (index) {
+ case 1:
+ return STDataViewersMessages.sortDirectionAscending_text2;
+ case 2:
+ return STDataViewersMessages.sortDirectionAscending_text3;
+ case 3:
+ return STDataViewersMessages.sortDirectionAscending_text4;
+ default:
+ return STDataViewersMessages.sortDirectionAscending_text;
+ }
+
+ }
+
+ /**
+ * Create the restore defaults button.
+ * @param parent
+ */
+ private void createRestoreDefaultsButton(Composite parent) {
+ Button defaultsButton = new Button(parent, SWT.PUSH);
+ defaultsButton.setText(STDataViewersMessages.restoreDefaults_text);
+ setButtonSize(defaultsButton, new GridData(
+ GridData.HORIZONTAL_ALIGN_END | GridData.FILL_HORIZONTAL));
+ defaultsButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ restoreDefaults();
+ markDirty();
+ }
+ });
+ }
+
+ private void createSeparatorLine(Composite parent) {
+ Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_CENTER));
+ }
+
+ private void restoreDefaults() {
+ updateUI(null, null);
+ }
+
+ private void updateUIFromSorter() {
+ updateUI(sorter.getPriorities(), sorter.getDirections());
+ }
+
+ private void updateUI(int[] priorities, int[] directions) {
+ Item[] columns = sorter.getColumns();
+ List<String> allItems = new ArrayList<String>();
+ List<Integer> allDirections = new ArrayList<Integer>();
+ for (int i = 0; i < columns.length; i++) {
+ if (priorities == null || directions == null) {
+ allItems.add(columns[i].getText());
+ ISTDataViewersField field = (ISTDataViewersField)columns[i].getData();
+ allDirections.add(field.getDefaultDirection());
+ } else {
+ allItems.add(columns[priorities[i]].getText());
+ allDirections.add(directions[priorities[i]]);
+ }
+ }
+
+ for (int i = 0; i < priorityCombos.length; i++) {
+ priorityCombos[i].removeAll();
+ priorityCombos[i].setItems(allItems.toArray(new String[allItems.size()]));
+ priorityCombos[i].select(0);
+ allItems.remove(0);
+ ascendingButtons[i].setSelection(allDirections.get(0) == STDataViewersComparator.ASCENDING);
+ descendingButtons[i].setSelection(allDirections.get(0) == STDataViewersComparator.DESCENDING);
+ allDirections.remove(0);
+ }
+ }
+
+ @Override
+ public int open() {
+ dirty = false;
+ return super.open();
+ }
+
+ protected void okPressed() {
+ if (isDirty()) {
+ outerfor:
+ for (int i = priorityCombos.length - 1; i >= 0; i--) {
+ Combo combo = priorityCombos[i];
+ int index = combo.getSelectionIndex();
+ String item = combo.getItem(index);
+ Item[] columns = sorter.getColumns();
+ for (Item column : columns) {
+ if (item.equals(column.getText())) {
+ ISTDataViewersField field = (ISTDataViewersField)column.getData();
+ sorter.setTopPriority(column, field);
+ int direction = STDataViewersComparator.ASCENDING;
+ if (descendingButtons[i].getSelection()) {
+ direction = STDataViewersComparator.DESCENDING;
+ }
+ sorter.setTopPriorityDirection(direction);
+ continue outerfor;
+ }
+ }
+ sorter.resetState();
+ return;
+ }
+ }
+ super.okPressed();
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ /**
+ * Sets the dirty flag to true.
+ */
+ public void markDirty() {
+ dirty = true;
+ }
+
+ /**
+ * Set the layout data of the button to a GridData with
+ * appropriate heights and widths.
+ * @param button
+ */
+ private void setButtonSize(Button button, GridData buttonData) {
+ button.setFont(button.getParent().getFont());
+ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ buttonData.widthHint = Math.max(widthHint, button.computeSize(
+ SWT.DEFAULT, SWT.DEFAULT, true).x);
+ button.setLayoutData(buttonData);
+ }
+
+ /**
+ * Return the sorter for the receiver.
+ * @return TableSorter
+ */
+ public STDataViewersComparator getSorter() {
+ return new STDataViewersComparator(sorter);
+ }
+
+}
+
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.java
new file mode 100644
index 0000000..9240eb6
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Helper class to get NLSed messages.
+ */
+final class EditorMessages extends NLS {
+
+ private static final String BUNDLE_FOR_CONSTRUCTED_KEYS= "org.eclipse.ui.texteditor.ConstructedEditorMessages";//$NON-NLS-1$
+ private static ResourceBundle fgBundleForConstructedKeys= ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
+
+ /**
+ * Returns the message bundle which contains constructed keys.
+ *
+ * @since 3.1
+ * @return the message bundle
+ */
+ public static ResourceBundle getBundleForConstructedKeys() {
+ return fgBundleForConstructedKeys;
+ }
+
+ private static final String BUNDLE_NAME= EditorMessages.class.getName();
+
+ private EditorMessages() {
+ // Do not instantiate
+ }
+
+ public static String Editor_error_no_provider;
+ public static String Editor_error_save_title;
+ public static String Editor_error_save_message;
+ public static String Editor_error_save_deleted_title;
+ public static String Editor_error_save_deleted_message;
+ public static String Editor_error_init;
+ public static String Editor_error_save_outofsync_title;
+ public static String Editor_error_save_outofsync_message;
+ public static String Editor_error_activated_outofsync_title;
+ public static String Editor_error_activated_outofsync_message;
+ public static String Editor_error_activated_deleted_save_title;
+ public static String Editor_error_activated_deleted_save_message;
+ public static String Editor_error_activated_deleted_save_button_save;
+ public static String Editor_error_activated_deleted_save_button_close;
+ public static String Editor_error_activated_deleted_close_title;
+ public static String Editor_error_activated_deleted_close_message;
+ public static String Editor_error_refresh_outofsync_title;
+ public static String Editor_error_refresh_outofsync_message;
+ public static String Editor_error_revert_title;
+ public static String Editor_error_revert_message;
+ public static String Editor_error_setinput_title;
+ public static String Editor_error_setinput_message;
+ public static String Editor_error_validateEdit_title;
+ public static String Editor_error_validateEdit_message;
+ public static String Editor_error_HyperlinkDetector_couldNotCreate_message;
+ public static String Editor_error_HyperlinkDetector_invalidElementName_message;
+ public static String Editor_error_HyperlinkDetector_invalidExtension_message;
+ public static String Editor_error_HyperlinkDetectorTarget_invalidElementName_message;
+ public static String Editor_error_HyperlinkDetectorTarget_invalidExtension_message;
+ public static String AbstractDocumentProvider_error_save_inuse;
+ public static String Editor_mark_status_message_mark_set;
+ public static String Editor_mark_status_message_mark_cleared;
+ public static String Editor_mark_status_message_mark_swapped;
+ public static String MarkRegionTarget_markNotSet;
+ public static String MarkRegionTarget_markNotVisible;
+ public static String Editor_FindIncremental_name;
+ public static String Editor_FindIncremental_reverse_name;
+ public static String Editor_FindIncremental_not_found_pattern;
+ public static String Editor_FindIncremental_found_pattern;
+ public static String Editor_FindIncremental_render_tab;
+ public static String Editor_FindIncremental_wrapped;
+ public static String Editor_FindIncremental_reverse;
+ public static String Editor_ConvertLineDelimiter_title;
+ public static String Editor_statusline_state_readonly_label;
+ public static String Editor_statusline_state_writable_label;
+ public static String Editor_statusline_mode_insert_label;
+ public static String Editor_statusline_mode_overwrite_label;
+ public static String Editor_statusline_mode_smartinsert_label;
+ public static String Editor_statusline_position_pattern;
+ public static String Editor_statusline_error_label;
+ public static String WorkbenchChainedTextFontFieldEditor_defaultWorkbenchTextFont;
+ public static String FindReplace_title;
+ public static String FindReplace_Find_label;
+ public static String FindReplace_Replace_label;
+ public static String FindReplace_Direction;
+ public static String FindReplace_ForwardRadioButton_label;
+ public static String FindReplace_BackwardRadioButton_label;
+ public static String FindReplace_Scope;
+ public static String FindReplace_GlobalRadioButton_label;
+ public static String FindReplace_SelectedRangeRadioButton_label;
+ public static String FindReplace_Options;
+ public static String FindReplace_CaseCheckBox_label;
+ public static String FindReplace_WrapCheckBox_label;
+ public static String FindReplace_WholeWordCheckBox_label;
+ public static String FindReplace_IncrementalCheckBox_label;
+ public static String FindReplace_RegExCheckbox_label;
+ public static String FindReplace_FindNextButton_label;
+ public static String FindReplace_ReplaceFindButton_label;
+ public static String FindReplace_ReplaceSelectionButton_label;
+ public static String FindReplace_ReplaceAllButton_label;
+ public static String FindReplace_CloseButton_label;
+ public static String FindReplace_Status_noMatch_label;
+ public static String FindReplace_Status_replacement_label;
+ public static String FindReplace_Status_replacements_label;
+ public static String FindNext_Status_noMatch_label;
+ public static String AbstractDocumentProvider_ok;
+ public static String AbstractDocumentProvider_error;
+ public static String FindReplaceDialog_read_only;
+ public static String Editor_MoveLines_IllegalMove_status;
+ public static String Editor_error_clipboard_copy_failed_message;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, EditorMessages.class);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.properties b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.properties
new file mode 100644
index 0000000..8f7c043
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/EditorMessages.properties
@@ -0,0 +1,120 @@
+###############################################################################
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+
+## Errors ##
+
+Editor_error_no_provider=Text editor does not have a document provider
+
+Editor_error_save_title=Save Problems
+Editor_error_save_message=Save could not be completed.
+
+Editor_error_save_deleted_title=Cannot Save
+Editor_error_save_deleted_message=The file has been deleted or is not accessible.
+
+Editor_error_init= Editor could not be initialized.
+
+Editor_error_save_outofsync_title=Update conflict
+Editor_error_save_outofsync_message=The file ''{0}'' has been changed on the file system. Do you want to overwrite the changes?
+
+Editor_error_activated_outofsync_title=File Changed
+Editor_error_activated_outofsync_message=The file has been changed on the file system. Do you want to load the changes?
+
+Editor_error_activated_deleted_save_title=File Not Accessible
+Editor_error_activated_deleted_save_message=The file has been deleted or is not accessible. Do you want to save your changes or close the editor without saving?
+Editor_error_activated_deleted_save_button_save=Save
+Editor_error_activated_deleted_save_button_close=Close
+Editor_error_activated_deleted_close_title=File Not Accessible
+Editor_error_activated_deleted_close_message=The file has been deleted or is not accessible. This editor will be closed.
+
+Editor_error_refresh_outofsync_title=Problems loading File
+Editor_error_refresh_outofsync_message=The file could not be loaded from the file system.
+
+Editor_error_revert_title=Problems while reverting to saved state
+Editor_error_revert_message=Could not revert to saved state.
+Editor_error_setinput_title=Problem opening
+Editor_error_setinput_message=Cannot open input element:
+
+Editor_error_validateEdit_title= Problems editing file
+Editor_error_validateEdit_message= The file cannot be edited.
+
+Editor_error_HyperlinkDetector_couldNotCreate_message= The ''{0}'' extension from plug-in ''{1}'' to the ''org.eclipse.ui.workbench.texteditor.hyperlinkDetectors'' extension point failed to load the hyperlink detector.
+Editor_error_HyperlinkDetector_invalidElementName_message= An extension from plug-in ''{0}'' to the ''org.eclipse.ui.workbench.texteditor.hyperlinkDetectors'' extension point was ignored because it contains the following invalid element: ''{1}''.
+Editor_error_HyperlinkDetector_invalidExtension_message= The ''{0}'' extension from plug-in ''{1}'' to the ''org.eclipse.ui.workbench.texteditor.hyperlinkDetectors'' extension point will be ignored because it contains invalid attributes.
+Editor_error_HyperlinkDetectorTarget_invalidElementName_message= An extension from plug-in ''{0}'' to the ''org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets'' extension point was ignored because it contains the following invalid element: ''{1}''.
+Editor_error_HyperlinkDetectorTarget_invalidExtension_message= The ''{0}'' extension from plug-in ''{1}'' to the ''org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets'' extension point will be ignored because it contains invalid attributes.
+
+AbstractDocumentProvider_error_save_inuse=File is either open in another editor or in use by another operation.
+
+Editor_mark_status_message_mark_set=Mark set
+Editor_mark_status_message_mark_cleared=Mark cleared
+Editor_mark_status_message_mark_swapped=Mark swapped
+MarkRegionTarget_markNotSet=mark not set
+MarkRegionTarget_markNotVisible=mark not in visible region
+
+# Incremental Find Status field
+Editor_FindIncremental_name= Incremental Find
+Editor_FindIncremental_reverse_name= Reverse Incremental Find
+Editor_FindIncremental_not_found_pattern={0}{1} {2} not found
+Editor_FindIncremental_found_pattern={0}{1}: {2}
+Editor_FindIncremental_render_tab=<TAB>
+
+# The following two properties must end in a space
+Editor_FindIncremental_wrapped=Wrapped
+Editor_FindIncremental_reverse=Reverse
+
+Editor_ConvertLineDelimiter_title=Converting line delimiters...
+
+## Status line ##
+Editor_statusline_state_readonly_label=Read-Only
+Editor_statusline_state_writable_label=Writable
+Editor_statusline_mode_insert_label=Insert
+Editor_statusline_mode_overwrite_label=Overwrite
+Editor_statusline_mode_smartinsert_label=Smart Insert
+Editor_statusline_position_pattern={0} : {1}
+Editor_statusline_error_label=?
+
+## Others ##
+WorkbenchChainedTextFontFieldEditor_defaultWorkbenchTextFont=<Using Workbench Text Font>
+
+FindReplace_title= Find/Replace
+FindReplace_Find_label=&Find:
+FindReplace_Replace_label=R&eplace With:
+FindReplace_Direction=Direction
+FindReplace_ForwardRadioButton_label=F&orward
+FindReplace_BackwardRadioButton_label=&Backward
+FindReplace_Scope=Scope
+FindReplace_GlobalRadioButton_label=A&ll
+FindReplace_SelectedRangeRadioButton_label=Selec&ted Lines
+FindReplace_Options=Options
+FindReplace_CaseCheckBox_label=&Case Sensitive
+FindReplace_WrapCheckBox_label=Wra&p Search
+FindReplace_WholeWordCheckBox_label=&Whole Word
+FindReplace_IncrementalCheckBox_label=&Incremental
+FindReplace_RegExCheckbox_label= Regular e&xpressions
+FindReplace_FindNextButton_label=Fi&nd
+FindReplace_ReplaceFindButton_label=Replace/Fin&d
+FindReplace_ReplaceSelectionButton_label=&Replace
+FindReplace_ReplaceAllButton_label=Replace &All
+FindReplace_CloseButton_label=Close
+FindReplace_Status_noMatch_label=String Not Found
+FindReplace_Status_replacement_label=1 Match replaced
+FindReplace_Status_replacements_label={0} matches replaced
+
+FindNext_Status_noMatch_label=String Not Found
+
+AbstractDocumentProvider_ok=OK
+AbstractDocumentProvider_error=ERROR
+FindReplaceDialog_read_only=Cannot replace. File is read-only.
+
+Editor_MoveLines_IllegalMove_status= Move not possible - Uncheck "Show Source of Selected Element Only" to see the entire document
+
+Editor_error_clipboard_copy_failed_message= Copy to clipboard failed.
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/ISTFindReplaceTarget.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/ISTFindReplaceTarget.java
new file mode 100644
index 0000000..6034bb7
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/ISTFindReplaceTarget.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ViewerCell;
+
+
+public interface ISTFindReplaceTarget {
+ /**
+ * Returns whether a find operation can be performed.
+ *
+ * @return whether a find operation can be performed
+ */
+ boolean canPerformFind();
+
+ /**
+ * Searches for a string starting at the given widget offset and using the specified search
+ * directives. If a string has been found it is selected and its start offset is
+ * returned.
+ *
+ * @param widgetOffset the ViewerCell offset at which searching starts
+ * @param findString the string which should be found
+ * @param searchForward <code>true</code> searches forward, <code>false</code> backwards
+ * @param caseSensitive <code>true</code> performs a case sensitive search, <code>false</code> an insensitive search
+ * @param wholeWord if <code>true</code> only occurrences are reported in which the findString stands as a word by itself
+ * @return the ViewerCell of the specified string, or -1 if the string has not been found
+ */
+ ViewerCell findAndSelect(ViewerCell cellOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord,boolean wrapSearch,boolean regExSearch);
+
+ /**
+ * Returns the ViewerCell from the search has start
+ * @param index
+ */
+ ViewerCell getSelection(ViewerCell index);
+
+ /**
+ *
+ * @param index
+ * @param direction
+ * @return
+ */
+ ViewerCell getFirstCell(ViewerCell index,int direction);
+
+ /**
+ * Returns the text contained into the start cell
+ * @param index
+ * @return
+ */
+ String getSelectionText(ViewerCell index);
+
+ /**
+ * Returns whether a cell is editable
+ *
+ */
+ Boolean isEditable();
+
+ /**
+ * Returns the viewers on which the find operation is working
+ * @return
+ */
+ ColumnViewer getViewer();
+
+ /**
+ * Set the find action associated to this find target
+ * @param action
+ */
+ void setFindAction(STFindReplaceAction action);
+
+ /**
+ * Sets if the "Find" operation is applied only to the selected lines in the viewer
+ * @param use
+ */
+ void useSelectedLines(boolean use);
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExContentProposalProvider.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExContentProposalProvider.java
new file mode 100644
index 0000000..4f11aa9
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExContentProposalProvider.java
@@ -0,0 +1,375 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+
+/**
+ * Content assist proposal provider for regular expressions.
+ * <p>
+ * Note: Replaces <code>RegExContentAssistProcessor</code> which was introduced in 3.0.
+ * </p>
+ *
+ * @since 3.2
+ */
+final class RegExContentProposalProvider implements IContentProposalProvider {
+
+
+ /**
+ * Proposal computer.
+ */
+ public static class ProposalComputer {
+
+ public static class Proposal implements IContentProposal {
+
+ private String fContent;
+ private String fLabel;
+ private String fDescription;
+ private int fCursorPosition;
+
+ Proposal(String content, String label, String description, int cursorPosition) {
+ fContent= content;
+ fLabel= label;
+ fDescription= description;
+ fCursorPosition= cursorPosition;
+ }
+
+ public String getContent() {
+ return fContent;
+ }
+
+ public String getLabel() {
+ return fLabel;
+ }
+
+ public String getDescription() {
+ return fDescription;
+ }
+
+ public int getCursorPosition() {
+ return fCursorPosition;
+ }
+ }
+
+
+ /**
+ * The whole regular expression.
+ */
+ private final String fExpression;
+ /**
+ * The document offset.
+ */
+ private final int fDocumentOffset;
+ /**
+ * The high-priority proposals.
+ */
+ private final ArrayList<Proposal> fPriorityProposals;
+ /**
+ * The low-priority proposals.
+ */
+ private final ArrayList<Proposal> fProposals;
+ /**
+ * <code>true</code> iff <code>fExpression</code> ends with an open escape.
+ */
+ private final boolean fIsEscape;
+
+ /**
+ * Creates a new Proposal Computer.
+ * @param contents the contents of the subject control
+ * @param position the cursor position
+ */
+ public ProposalComputer(String contents, int position) {
+ fExpression= contents;
+ fDocumentOffset= position;
+ fPriorityProposals= new ArrayList<Proposal>();
+ fProposals= new ArrayList<Proposal>();
+
+ boolean isEscape= false;
+ esc: for (int i= position - 1; i >= 0; i--) {
+ if (fExpression.charAt(i) == '\\')
+ isEscape= !isEscape;
+ else
+ break esc;
+ }
+ fIsEscape= isEscape;
+ }
+
+ /**
+ * Computes applicable proposals for the find field.
+ * @return the proposals
+ */
+ public IContentProposal[] computeFindProposals() {
+ //characters
+ addBsProposal("\\\\", RegExMessages.displayString_bs_bs, RegExMessages.additionalInfo_bs_bs); //$NON-NLS-1$
+ addBracketProposal("\\0", 2, RegExMessages.displayString_bs_0, RegExMessages.additionalInfo_bs_0); //$NON-NLS-1$
+ addBracketProposal("\\x", 2, RegExMessages.displayString_bs_x, RegExMessages.additionalInfo_bs_x); //$NON-NLS-1$
+ addBracketProposal("\\u", 2, RegExMessages.displayString_bs_u, RegExMessages.additionalInfo_bs_u); //$NON-NLS-1$
+ addBsProposal("\\t", RegExMessages.displayString_bs_t, RegExMessages.additionalInfo_bs_t); //$NON-NLS-1$
+ addBsProposal("\\n", RegExMessages.displayString_bs_n, RegExMessages.additionalInfo_bs_n); //$NON-NLS-1$
+ addBsProposal("\\r", RegExMessages.displayString_bs_r, RegExMessages.additionalInfo_bs_r); //$NON-NLS-1$
+ addBsProposal("\\f", RegExMessages.displayString_bs_f, RegExMessages.additionalInfo_bs_f); //$NON-NLS-1$
+ addBsProposal("\\a", RegExMessages.displayString_bs_a, RegExMessages.additionalInfo_bs_a); //$NON-NLS-1$
+ addBsProposal("\\e", RegExMessages.displayString_bs_e, RegExMessages.additionalInfo_bs_e); //$NON-NLS-1$
+ addBsProposal("\\c", RegExMessages.displayString_bs_c, RegExMessages.additionalInfo_bs_c); //$NON-NLS-1$
+
+ if (! fIsEscape)
+ addBracketProposal(".", 1, RegExMessages.displayString_dot, RegExMessages.additionalInfo_dot); //$NON-NLS-1$
+ addBsProposal("\\d", RegExMessages.displayString_bs_d, RegExMessages.additionalInfo_bs_d); //$NON-NLS-1$
+ addBsProposal("\\D", RegExMessages.displayString_bs_D, RegExMessages.additionalInfo_bs_D); //$NON-NLS-1$
+ addBsProposal("\\s", RegExMessages.displayString_bs_s, RegExMessages.additionalInfo_bs_s); //$NON-NLS-1$
+ addBsProposal("\\S", RegExMessages.displayString_bs_S, RegExMessages.additionalInfo_bs_S); //$NON-NLS-1$
+ addBsProposal("\\w", RegExMessages.displayString_bs_w, RegExMessages.additionalInfo_bs_w); //$NON-NLS-1$
+ addBsProposal("\\W", RegExMessages.displayString_bs_W, RegExMessages.additionalInfo_bs_W); //$NON-NLS-1$
+
+ // back reference
+ addBsProposal("\\", RegExMessages.displayString_bs_i, RegExMessages.additionalInfo_bs_i); //$NON-NLS-1$
+
+ //quoting
+ addBsProposal("\\", RegExMessages.displayString_bs, RegExMessages.additionalInfo_bs); //$NON-NLS-1$
+ addBsProposal("\\Q", RegExMessages.displayString_bs_Q, RegExMessages.additionalInfo_bs_Q); //$NON-NLS-1$
+ addBsProposal("\\E", RegExMessages.displayString_bs_E, RegExMessages.additionalInfo_bs_E); //$NON-NLS-1$
+
+ //character sets
+ if (! fIsEscape) {
+ addBracketProposal("[]", 1, RegExMessages.displayString_set, RegExMessages.additionalInfo_set); //$NON-NLS-1$
+ addBracketProposal("[^]", 2, RegExMessages.displayString_setExcl, RegExMessages.additionalInfo_setExcl); //$NON-NLS-1$
+ addBracketProposal("[-]", 1, RegExMessages.displayString_setRange, RegExMessages.additionalInfo_setRange); //$NON-NLS-1$
+ addProposal("&&", RegExMessages.displayString_setInter, RegExMessages.additionalInfo_setInter); //$NON-NLS-1$
+ }
+ if (! fIsEscape && fDocumentOffset > 0 && fExpression.charAt(fDocumentOffset - 1) == '\\') {
+ addProposal("\\p{}", 3, RegExMessages.displayString_posix, RegExMessages.additionalInfo_posix); //$NON-NLS-1$
+ addProposal("\\P{}", 3, RegExMessages.displayString_posixNot, RegExMessages.additionalInfo_posixNot); //$NON-NLS-1$
+ } else {
+ addBracketProposal("\\p{}", 3, RegExMessages.displayString_posix, RegExMessages.additionalInfo_posix); //$NON-NLS-1$
+ addBracketProposal("\\P{}", 3, RegExMessages.displayString_posixNot, RegExMessages.additionalInfo_posixNot); //$NON-NLS-1$
+ }
+
+// addBsProposal("\\p{Lower}", RegExMessages.displayString_bs_p{Lower}, RegExMessages.additionalInfo_bs_p{Lower}); //$NON-NLS-1$
+// addBsProposal("\\p{Upper}", RegExMessages.displayString_bs_p{Upper}, RegExMessages.additionalInfo_bs_p{Upper}); //$NON-NLS-1$
+// addBsProposal("\\p{ASCII}", RegExMessages.displayString_bs_p{ASCII}, RegExMessages.additionalInfo_bs_p{ASCII}); //$NON-NLS-1$
+// addBsProposal("\\p{Alpha}", RegExMessages.displayString_bs_p{Alpha}, RegExMessages.additionalInfo_bs_p{Alpha}); //$NON-NLS-1$
+// addBsProposal("\\p{Digit}", RegExMessages.displayString_bs_p{Digit}, RegExMessages.additionalInfo_bs_p{Digit}); //$NON-NLS-1$
+// addBsProposal("\\p{Alnum}", RegExMessages.displayString_bs_p{Alnum}, RegExMessages.additionalInfo_bs_p{Alnum}); //$NON-NLS-1$
+// addBsProposal("\\p{Punct}", RegExMessages.displayString_bs_p{Punct}, RegExMessages.additionalInfo_bs_p{Punct}); //$NON-NLS-1$
+// addBsProposal("\\p{Graph}", RegExMessages.displayString_bs_p{Graph}, RegExMessages.additionalInfo_bs_p{Graph}); //$NON-NLS-1$
+// addBsProposal("\\p{Print}", RegExMessages.displayString_bs_p{Print}, RegExMessages.additionalInfo_bs_p{Print}); //$NON-NLS-1$
+// addBsProposal("\\p{Blank}", RegExMessages.displayString_bs_p{Blank}, RegExMessages.additionalInfo_bs_p{Blank}); //$NON-NLS-1$
+// addBsProposal("\\p{Cntrl}", RegExMessages.displayString_bs_p{Cntrl}, RegExMessages.additionalInfo_bs_p{Cntrl}); //$NON-NLS-1$
+// addBsProposal("\\p{XDigit}", RegExMessages.displayString_bs_p{XDigit}, RegExMessages.additionalInfo_bs_p{XDigit}); //$NON-NLS-1$
+// addBsProposal("\\p{Space}", RegExMessages.displayString_bs_p{Space}, RegExMessages.additionalInfo_bs_p{Space}); //$NON-NLS-1$
+//
+// addBsProposal("\\p{InGreek}", RegExMessages.displayString_bs_p{InGreek}, RegExMessages.additionalInfo_bs_p{InGreek}); //$NON-NLS-1$
+// addBsProposal("\\p{Lu}", RegExMessages.displayString_bs_p{Lu}, RegExMessages.additionalInfo_bs_p{Lu}); //$NON-NLS-1$
+// addBsProposal("\\p{Sc}", RegExMessages.displayString_bs_p{Sc}, RegExMessages.additionalInfo_bs_p{Sc}); //$NON-NLS-1$
+// addBsProposal("\\P{InGreek}", RegExMessages.displayString_bs_P{InGreek}, RegExMessages.additionalInfo_bs_P{InGreek}); //$NON-NLS-1$
+
+ //boundary matchers
+ if (fDocumentOffset == 0) {
+ addPriorityProposal("^", RegExMessages.displayString_start, RegExMessages.additionalInfo_start); //$NON-NLS-1$
+ } else if (fDocumentOffset == 1 && fExpression.charAt(0) == '^') {
+ addBracketProposal("^", 1, RegExMessages.displayString_start, RegExMessages.additionalInfo_start); //$NON-NLS-1$
+ }
+ if (fDocumentOffset == fExpression.length()) {
+ addProposal("$", RegExMessages.displayString_end, RegExMessages.additionalInfo_end); //$NON-NLS-1$
+ }
+ addBsProposal("\\b", RegExMessages.displayString_bs_b, RegExMessages.additionalInfo_bs_b); //$NON-NLS-1$
+ addBsProposal("\\B", RegExMessages.displayString_bs_B, RegExMessages.additionalInfo_bs_B); //$NON-NLS-1$
+ addBsProposal("\\A", RegExMessages.displayString_bs_A, RegExMessages.additionalInfo_bs_A); //$NON-NLS-1$
+ addBsProposal("\\G", RegExMessages.displayString_bs_G, RegExMessages.additionalInfo_bs_G); //$NON-NLS-1$
+ addBsProposal("\\Z", RegExMessages.displayString_bs_Z, RegExMessages.additionalInfo_bs_Z); //$NON-NLS-1$
+ addBsProposal("\\z", RegExMessages.displayString_bs_z, RegExMessages.additionalInfo_bs_z); //$NON-NLS-1$
+
+ if (! fIsEscape) {
+ //capturing groups
+ addBracketProposal("()", 1, RegExMessages.displayString_group, RegExMessages.additionalInfo_group); //$NON-NLS-1$
+
+ //flags
+ addBracketProposal("(?)", 2, RegExMessages.displayString_flag, RegExMessages.additionalInfo_flag); //$NON-NLS-1$
+ addBracketProposal("(?:)", 3, RegExMessages.displayString_flagExpr, RegExMessages.additionalInfo_flagExpr); //$NON-NLS-1$
+
+ //non-capturing group
+ addBracketProposal("(?:)", 3, RegExMessages.displayString_nonCap, RegExMessages.additionalInfo_nonCap); //$NON-NLS-1$
+ addBracketProposal("(?>)", 3, RegExMessages.displayString_atomicCap, RegExMessages.additionalInfo_atomicCap); //$NON-NLS-1$
+
+ //lookaraound
+ addBracketProposal("(?=)", 3, RegExMessages.displayString_posLookahead, RegExMessages.additionalInfo_posLookahead); //$NON-NLS-1$
+ addBracketProposal("(?!)", 3, RegExMessages.displayString_negLookahead, RegExMessages.additionalInfo_negLookahead); //$NON-NLS-1$
+ addBracketProposal("(?<=)", 4, RegExMessages.displayString_posLookbehind, RegExMessages.additionalInfo_posLookbehind); //$NON-NLS-1$
+ addBracketProposal("(?<!)", 4, RegExMessages.displayString_negLookbehind, RegExMessages.additionalInfo_negLookbehind); //$NON-NLS-1$
+
+ //greedy quantifiers
+ addBracketProposal("?", 1, RegExMessages.displayString_quest, RegExMessages.additionalInfo_quest); //$NON-NLS-1$
+ addBracketProposal("*", 1, RegExMessages.displayString_star, RegExMessages.additionalInfo_star); //$NON-NLS-1$
+ addBracketProposal("+", 1, RegExMessages.displayString_plus, RegExMessages.additionalInfo_plus); //$NON-NLS-1$
+ addBracketProposal("{}", 1, RegExMessages.displayString_exact, RegExMessages.additionalInfo_exact); //$NON-NLS-1$
+ addBracketProposal("{,}", 1, RegExMessages.displayString_least, RegExMessages.additionalInfo_least); //$NON-NLS-1$
+ addBracketProposal("{,}", 1, RegExMessages.displayString_count, RegExMessages.additionalInfo_count); //$NON-NLS-1$
+
+ //lazy quantifiers
+ addBracketProposal("??", 1, RegExMessages.displayString_questLazy, RegExMessages.additionalInfo_questLazy); //$NON-NLS-1$
+ addBracketProposal("*?", 1, RegExMessages.displayString_starLazy, RegExMessages.additionalInfo_starLazy); //$NON-NLS-1$
+ addBracketProposal("+?", 1, RegExMessages.displayString_plusLazy, RegExMessages.additionalInfo_plusLazy); //$NON-NLS-1$
+ addBracketProposal("{}?", 1, RegExMessages.displayString_exactLazy, RegExMessages.additionalInfo_exactLazy); //$NON-NLS-1$
+ addBracketProposal("{,}?", 1, RegExMessages.displayString_leastLazy, RegExMessages.additionalInfo_leastLazy); //$NON-NLS-1$
+ addBracketProposal("{,}?", 1, RegExMessages.displayString_countLazy, RegExMessages.additionalInfo_countLazy); //$NON-NLS-1$
+
+ //possessive quantifiers
+ addBracketProposal("?+", 1, RegExMessages.displayString_questPoss, RegExMessages.additionalInfo_questPoss); //$NON-NLS-1$
+ addBracketProposal("*+", 1, RegExMessages.displayString_starPoss, RegExMessages.additionalInfo_starPoss); //$NON-NLS-1$
+ addBracketProposal("++", 1, RegExMessages.displayString_plusPoss, RegExMessages.additionalInfo_plusPoss); //$NON-NLS-1$
+ addBracketProposal("{}+", 1, RegExMessages.displayString_exactPoss, RegExMessages.additionalInfo_exactPoss); //$NON-NLS-1$
+ addBracketProposal("{,}+", 1, RegExMessages.displayString_leastPoss, RegExMessages.additionalInfo_leastPoss); //$NON-NLS-1$
+ addBracketProposal("{,}+", 1, RegExMessages.displayString_countPoss, RegExMessages.additionalInfo_countPoss); //$NON-NLS-1$
+
+ //alternative
+ addBracketProposal("|", 1, RegExMessages.displayString_alt, RegExMessages.additionalInfo_alt); //$NON-NLS-1$
+ }
+
+ fPriorityProposals.addAll(fProposals);
+ return fPriorityProposals.toArray(new IContentProposal[fProposals.size()]);
+ }
+
+ /**
+ * Computes applicable proposals for the replace field.
+ * @return the proposals
+ */
+ public IContentProposal[] computeReplaceProposals() {
+ if (fDocumentOffset > 0 && '$' == fExpression.charAt(fDocumentOffset - 1)) {
+ addProposal("", RegExMessages.displayString_dollar, RegExMessages.additionalInfo_dollar); //$NON-NLS-1$
+ } else {
+ addProposal("$", RegExMessages.displayString_dollar, RegExMessages.additionalInfo_dollar); //$NON-NLS-1$
+ addBsProposal("\\", RegExMessages.displayString_replace_bs, RegExMessages.additionalInfo_replace_bs); //$NON-NLS-1$
+ addProposal("\t", RegExMessages.displayString_tab, RegExMessages.additionalInfo_tab); //$NON-NLS-1$
+ }
+ return fProposals.toArray(new IContentProposal[fProposals.size()]);
+ }
+
+ /**
+ * Adds a proposal.
+ *
+ * @param proposal the string to be inserted
+ * @param displayString the proposal's label
+ * @param additionalInfo the additional information
+ */
+ private void addProposal(String proposal, String displayString, String additionalInfo) {
+ fProposals.add(new Proposal(proposal, displayString, additionalInfo, proposal.length()));
+ }
+
+ /**
+ * Adds a proposal.
+ *
+ * @param proposal the string to be inserted
+ * @param cursorPosition the cursor position after insertion,
+ * relative to the start of the proposal
+ * @param displayString the proposal's label
+ * @param additionalInfo the additional information
+ */
+ private void addProposal(String proposal, int cursorPosition, String displayString, String additionalInfo) {
+ fProposals.add(new Proposal(proposal, displayString, additionalInfo, cursorPosition));
+ }
+
+ /**
+ * Adds a proposal to the priority proposals list.
+ *
+ * @param proposal the string to be inserted
+ * @param displayString the proposal's label
+ * @param additionalInfo the additional information
+ */
+ private void addPriorityProposal(String proposal, String displayString, String additionalInfo) {
+ fPriorityProposals.add(new Proposal(proposal, displayString, additionalInfo, proposal.length()));
+ }
+
+ /**
+ * Adds a proposal. Ensures that existing pre- and postfixes are not duplicated.
+ *
+ * @param proposal the string to be inserted
+ * @param cursorPosition the cursor position after insertion,
+ * relative to the start of the proposal
+ * @param displayString the proposal's label
+ * @param additionalInfo the additional information
+ */
+ private void addBracketProposal(String proposal, int cursorPosition, String displayString, String additionalInfo) {
+ String prolog= fExpression.substring(0, fDocumentOffset);
+ if (! fIsEscape && prolog.endsWith("\\") && proposal.startsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$
+ fProposals.add(new Proposal(proposal, displayString, additionalInfo, cursorPosition));
+ return;
+ }
+ for (int i= 1; i <= cursorPosition; i++) {
+ String prefix= proposal.substring(0, i);
+ if (prolog.endsWith(prefix)) {
+ String postfix= proposal.substring(cursorPosition);
+ String epilog= fExpression.substring(fDocumentOffset);
+ if (epilog.startsWith(postfix)) {
+ fPriorityProposals.add(new Proposal(proposal.substring(i, cursorPosition), displayString, additionalInfo, cursorPosition-i));
+ } else {
+ fPriorityProposals.add(new Proposal(proposal.substring(i), displayString, additionalInfo, cursorPosition-i));
+ }
+ return;
+ }
+ }
+ fProposals.add(new Proposal(proposal, displayString, additionalInfo, cursorPosition));
+ }
+
+ /**
+ * Adds a proposal that starts with a backslash.
+ * Ensures that the backslash is not repeated if already typed.
+ *
+ * @param proposal the string to be inserted
+ * @param displayString the proposal's label
+ * @param additionalInfo the additional information
+ */
+ private void addBsProposal(String proposal, String displayString, String additionalInfo) {
+ String prolog= fExpression.substring(0, fDocumentOffset);
+ int position= proposal.length();
+ // If the string already contains the backslash, do not include in the proposal
+ if (prolog.endsWith("\\")) { //$NON-NLS-1$
+ position--;
+ proposal= proposal.substring(1);
+ }
+
+ if (fIsEscape) {
+ fPriorityProposals.add(new Proposal(proposal, displayString, additionalInfo, position));
+ } else {
+ addProposal(proposal, position, displayString, additionalInfo);
+ }
+ }
+ }
+
+ /**
+ * <code>true</code> iff the processor is for the find field.
+ * <code>false</code> iff the processor is for the replace field.
+ */
+ private final boolean fIsFind;
+
+
+ /**
+ * Creates a new completion proposal provider.
+ *
+ * @param isFind <code>true</code> if the provider is used for the 'find' field
+ * <code>false</code> if the provider is used for the 'reaplce' field
+ */
+ public RegExContentProposalProvider(boolean isFind) {
+ fIsFind= isFind;
+ }
+
+ /*
+ * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
+ */
+ public IContentProposal [] getProposals(String contents, int position) {
+ if (fIsFind)
+ return new ProposalComputer(contents, position).computeFindProposals();
+ return new ProposalComputer(contents, position).computeReplaceProposals();
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExMessages.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExMessages.java
new file mode 100644
index 0000000..f70a829
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/RegExMessages.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * RegEx messages. Helper class to get NLSed messages.
+ *
+ * @since 3.1
+ */
+final class RegExMessages extends NLS {
+
+ private static final String BUNDLE_NAME= RegExMessages.class.getName();
+
+ private RegExMessages() {
+ // Do not instantiate
+ }
+
+ static {
+ reloadMessages();
+ }
+
+ static void reloadMessages() {
+ NLS.initializeMessages(BUNDLE_NAME, RegExMessages.class);
+ }
+
+ //characters
+ public static String displayString_bs_bs;
+ public static String additionalInfo_bs_bs;
+ public static String displayString_bs_0;
+ public static String additionalInfo_bs_0;
+ public static String displayString_bs_x;
+ public static String additionalInfo_bs_x;
+ public static String displayString_bs_u;
+ public static String additionalInfo_bs_u;
+ public static String displayString_bs_t;
+ public static String additionalInfo_bs_t;
+ public static String displayString_bs_n;
+ public static String additionalInfo_bs_n;
+ public static String displayString_bs_r;
+ public static String additionalInfo_bs_r;
+ public static String displayString_bs_f;
+ public static String additionalInfo_bs_f;
+ public static String displayString_bs_a;
+ public static String additionalInfo_bs_a;
+ public static String displayString_bs_e;
+ public static String additionalInfo_bs_e;
+ public static String displayString_bs_c;
+ public static String additionalInfo_bs_c;
+
+ //character classes
+ public static String displayString_dot;
+ public static String additionalInfo_dot;
+ public static String displayString_bs_d;
+ public static String additionalInfo_bs_d;
+ public static String displayString_bs_D;
+ public static String additionalInfo_bs_D;
+ public static String displayString_bs_s;
+ public static String additionalInfo_bs_s;
+ public static String displayString_bs_S;
+ public static String additionalInfo_bs_S;
+ public static String displayString_bs_w;
+ public static String additionalInfo_bs_w;
+ public static String displayString_bs_W;
+ public static String additionalInfo_bs_W;
+
+ //boundary matchers
+ public static String displayString_start;
+ public static String additionalInfo_start;
+ public static String displayString_end;
+ public static String additionalInfo_end;
+ public static String displayString_bs_b;
+ public static String additionalInfo_bs_b;
+ public static String displayString_bs_B;
+ public static String additionalInfo_bs_B;
+ public static String displayString_bs_A;
+ public static String additionalInfo_bs_A;
+ public static String displayString_bs_G;
+ public static String additionalInfo_bs_G;
+ public static String displayString_bs_Z;
+ public static String additionalInfo_bs_Z;
+ public static String displayString_bs_z;
+ public static String additionalInfo_bs_z;
+
+ //greedy quantifiers
+ public static String displayString_quest;
+ public static String additionalInfo_quest;
+ public static String displayString_star;
+ public static String additionalInfo_star;
+ public static String displayString_plus;
+ public static String additionalInfo_plus;
+ public static String displayString_exact;
+ public static String additionalInfo_exact;
+ public static String displayString_least;
+ public static String additionalInfo_least;
+ public static String displayString_count;
+ public static String additionalInfo_count;
+
+ //lazy quantifiers
+ public static String displayString_questLazy;
+ public static String additionalInfo_questLazy;
+ public static String displayString_starLazy;
+ public static String additionalInfo_starLazy;
+ public static String displayString_plusLazy;
+ public static String additionalInfo_plusLazy;
+ public static String displayString_exactLazy;
+ public static String additionalInfo_exactLazy;
+ public static String displayString_leastLazy;
+ public static String additionalInfo_leastLazy;
+ public static String displayString_countLazy;
+ public static String additionalInfo_countLazy;
+
+ //possessive quantifiers
+ public static String displayString_questPoss;
+ public static String additionalInfo_questPoss;
+ public static String displayString_starPoss;
+ public static String additionalInfo_starPoss;
+ public static String displayString_plusPoss;
+ public static String additionalInfo_plusPoss;
+ public static String displayString_exactPoss;
+ public static String additionalInfo_exactPoss;
+ public static String displayString_leastPoss;
+ public static String additionalInfo_leastPoss;
+ public static String displayString_countPoss;
+ public static String additionalInfo_countPoss;
+
+ //alternative
+ public static String displayString_alt;
+ public static String additionalInfo_alt;
+
+ //capturing groups
+ public static String displayString_group;
+ public static String additionalInfo_group;
+ public static String displayString_bs_i;
+ public static String additionalInfo_bs_i;
+
+ //quoting
+ public static String displayString_bs;
+ public static String additionalInfo_bs;
+ public static String displayString_bs_Q;
+ public static String additionalInfo_bs_Q;
+ public static String displayString_bs_E;
+ public static String additionalInfo_bs_E;
+
+ //character sets
+ public static String displayString_set;
+ public static String additionalInfo_set;
+ public static String displayString_setExcl;
+ public static String additionalInfo_setExcl;
+ public static String displayString_setRange;
+ public static String additionalInfo_setRange;
+ public static String displayString_setInter;
+ public static String additionalInfo_setInter;
+ public static String displayString_posix;
+ public static String additionalInfo_posix;
+ public static String displayString_posixNot;
+ public static String additionalInfo_posixNot;
+
+ public static String displayString_flag;
+ public static String additionalInfo_flag;
+ public static String displayString_flagExpr;
+ public static String additionalInfo_flagExpr;
+
+ //non-capturing group
+ public static String displayString_nonCap;
+ public static String additionalInfo_nonCap;
+ public static String displayString_atomicCap;
+ public static String additionalInfo_atomicCap;
+
+ //look-ahead
+ public static String displayString_posLookahead;
+ public static String additionalInfo_posLookahead;
+ public static String displayString_negLookahead;
+ public static String additionalInfo_negLookahead;
+ public static String displayString_posLookbehind;
+ public static String additionalInfo_posLookbehind;
+ public static String displayString_negLookbehind;
+ public static String additionalInfo_negLookbehind;
+
+ //replace
+ public static String displayString_dollar;
+ public static String additionalInfo_dollar;
+ public static String additionalInfo_replace_bs;
+ public static String displayString_replace_bs;
+ public static String displayString_tab;
+ public static String additionalInfo_tab;
+ public static String displayString_nl;
+ public static String additionalInfo_nl;
+ public static String displayString_cr;
+ public static String additionalInfo_cr;
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceAction.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceAction.java
new file mode 100644
index 0000000..4bf57c7
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceAction.java
@@ -0,0 +1,330 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+
+import java.util.ResourceBundle;
+
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IPartService;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
+import org.eclipse.ui.texteditor.ITextEditorExtension2;
+import org.eclipse.ui.texteditor.IUpdate;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+import org.eclipse.ui.texteditor.ResourceAction;
+
+/**
+ * An action which opens a Find/Replace dialog.
+ * The dialog while open, tracks the active workbench part
+ * and retargets itself to the active find/replace target.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @see ISTFindReplaceTarget
+ */
+public class STFindReplaceAction extends ResourceAction implements IUpdate {
+ private static final String BUNDLE_FOR_CONSTRUCTED_KEYS= "org.eclipse.ui.texteditor.ConstructedEditorMessages";//$NON-NLS-1$
+ private static ResourceBundle fgBundleForConstructedKeys= ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
+ private static String prefix = "Editor.FindReplace.";
+
+ /**
+ * Represents the "global" find/replace dialog. It tracks the active
+ * part and retargets the find/replace dialog accordingly. The find/replace
+ * target is retrieved from the active part using
+ * <code>getAdapter(ISTFindReplaceTarget.class)</code>.
+ */
+ static class FindReplaceDialogStub implements IPartListener, DisposeListener {
+
+ /** The workbench part */
+ private IWorkbenchPart fPart;
+ /** The previous workbench part */
+ private IWorkbenchPart fPreviousPart;
+ /** The previous find/replace target */
+ private ISTFindReplaceTarget fPreviousTarget;
+
+ /** The workbench window */
+ private IWorkbenchWindow fWindow;
+ /** The find/replace dialog */
+ private STFindReplaceDialog fDialog;
+
+ /**
+ * Creates a new find/replace dialog accessor anchored at the given part site.
+ *
+ * @param site the part site
+ */
+ public FindReplaceDialogStub(IWorkbenchPartSite site) {
+ this(site.getShell());
+ fWindow= site.getWorkbenchWindow();
+ IPartService service= fWindow.getPartService();
+ service.addPartListener(this);
+ partActivated(service.getActivePart());
+ }
+
+ /**
+ * Creates a new find/replace dialog accessor anchored at the given shell.
+ *
+ * @param shell the shell if no site is used
+ */
+ public FindReplaceDialogStub(Shell shell) {
+ fDialog= new STFindReplaceDialog(shell);
+ fDialog.create();
+ fDialog.getShell().addDisposeListener(this);
+ }
+
+ /**
+ * Returns the find/replace dialog.
+ * @return the find/replace dialog
+ */
+ public STFindReplaceDialog getDialog() {
+ return fDialog;
+ }
+
+ /*
+ * @see IPartListener#partActivated(IWorkbenchPart)
+ */
+ public void partActivated(IWorkbenchPart part) {
+ ISTFindReplaceTarget target= part == null ? null : (ISTFindReplaceTarget) part.getAdapter(ISTFindReplaceTarget.class);
+ fPreviousPart= fPart;
+ fPart= target == null ? null : part;
+
+ if (fPreviousTarget != target) {
+ fPreviousTarget= target;
+ if (fDialog != null) {
+ boolean isEditable= false;
+ if (fPart instanceof ITextEditorExtension2) {
+ ITextEditorExtension2 extension= (ITextEditorExtension2) fPart;
+ isEditable= extension.isEditorInputModifiable();
+ } else if (target != null) {
+ isEditable= target.isEditable();
+ }
+ fDialog.updateTarget(target, isEditable, false);
+ }
+ }
+ }
+
+ /*
+ * @see IPartListener#partClosed(IWorkbenchPart)
+ */
+ public void partClosed(IWorkbenchPart part) {
+
+ if (part == fPreviousPart) {
+ fPreviousPart= null;
+ fPreviousTarget= null;
+ }
+
+ if (part == fPart)
+ partActivated(null);
+ }
+
+ /*
+ * @see DisposeListener#widgetDisposed(DisposeEvent)
+ */
+ public void widgetDisposed(DisposeEvent event) {
+
+ if (fgFindReplaceDialogStub == this)
+ fgFindReplaceDialogStub= null;
+
+ if(fgFindReplaceDialogStubShell == this)
+ fgFindReplaceDialogStubShell= null;
+
+ if (fWindow != null) {
+ fWindow.getPartService().removePartListener(this);
+ fWindow= null;
+ }
+ fDialog= null;
+ fPart= null;
+ fPreviousPart= null;
+ fPreviousTarget= null;
+ }
+
+ /*
+ * @see IPartListener#partOpened(IWorkbenchPart)
+ */
+ public void partOpened(IWorkbenchPart part) {}
+
+ /*
+ * @see IPartListener#partDeactivated(IWorkbenchPart)
+ */
+ public void partDeactivated(IWorkbenchPart part) {}
+
+ /*
+ * @see IPartListener#partBroughtToTop(IWorkbenchPart)
+ */
+ public void partBroughtToTop(IWorkbenchPart part) {}
+
+ /**
+ * Checks if the dialogs shell is the same as the
+ * given <code>shell</code> and if not clears the stub
+ * and closes the dialog.
+ *
+ * @param shell the shell check
+ */
+ public void checkShell(Shell shell) {
+ if (fDialog != null && shell != fDialog.getParentShell()) {
+ if (fgFindReplaceDialogStub == this)
+ fgFindReplaceDialogStub= null;
+
+ if(fgFindReplaceDialogStubShell == this)
+ fgFindReplaceDialogStubShell= null;
+
+ fDialog.close();
+ }
+ }
+ }
+
+ /**
+ * Listener for disabling the dialog on shell close.
+ * <p>
+ * This stub is shared amongst <code>IWorkbenchPart</code>s.</p>
+ */
+ private static FindReplaceDialogStub fgFindReplaceDialogStub;
+
+ /** Listener for disabling the dialog on shell close.
+ * <p>
+ * This stub is shared amongst <code>Shell</code>s.</p>
+ */
+ private static FindReplaceDialogStub fgFindReplaceDialogStubShell;
+
+ /** The action's target */
+ private ISTFindReplaceTarget fTarget;
+ /** The part to use if the action is created with a part. */
+ private IWorkbenchPart fWorkbenchPart;
+ /** The workbench window */
+ private IWorkbenchWindow fWorkbenchWindow;
+ /**
+ * The shell to use if the action is created with a shell.
+ */
+ private Shell fShell;
+
+ /**
+ * Creates a new find/replace action for the given workbench part.
+ * <p>
+ * The action configures its visual representation from the given
+ * resource bundle.</p>
+ *
+ * @param bundle the resource bundle
+ * @param prefix a prefix to be prepended to the various resource keys
+ * (described in <code>ResourceAction</code> constructor), or
+ * <code>null</code> if none
+ * @param workbenchPart the workbench part
+ * @see ResourceAction#ResourceAction(ResourceBundle, String)
+ */
+ public STFindReplaceAction(IWorkbenchPart workbenchPart) {
+ super(fgBundleForConstructedKeys, prefix);
+ Assert.isLegal(workbenchPart != null);
+ setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_ACTION);
+ setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_REPLACE);
+ fWorkbenchPart= workbenchPart;
+ update();
+ }
+
+ /**
+ * Creates a new find/replace action for the given target and shell.
+ * <p>
+ * This can be used without having an IWorkbenchPart e.g. for
+ * dialogs or wizards.</p>
+ * <p>
+ * The action configures its visual representation from the given
+ * resource bundle.</p>
+ *
+ * @param bundle the resource bundle
+ * @param prefix a prefix to be prepended to the various resource keys
+ * (described in <code>ResourceAction</code> constructor), or
+ * <code>null</code> if none
+ * @param target the ISTFindReplaceTarget to use
+ * @param shell the shell
+ * @see ResourceAction#ResourceAction(ResourceBundle, String)
+ *
+ */
+ public STFindReplaceAction(Shell shell, ISTFindReplaceTarget target) {
+ super(fgBundleForConstructedKeys, prefix);
+ Assert.isLegal(target != null && shell != null);
+ setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_ACTION);
+ setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_REPLACE);
+ fTarget= target;
+ fShell= shell;
+ update();
+ }
+
+ /*
+ * @see IAction#run()
+ */
+ public void run() {
+ if (fTarget == null){
+ return;
+ }
+
+
+ final STFindReplaceDialog dialog;
+ final boolean isEditable;
+
+ if(fShell == null) {
+ if (fgFindReplaceDialogStub != null) {
+ Shell shell= fWorkbenchPart.getSite().getShell();
+ fgFindReplaceDialogStub.checkShell(shell);
+ }
+ if (fgFindReplaceDialogStub == null)
+ fgFindReplaceDialogStub= new FindReplaceDialogStub(fWorkbenchPart.getSite());
+
+ if (fWorkbenchPart instanceof ITextEditorExtension2)
+ isEditable= ((ITextEditorExtension2) fWorkbenchPart).isEditorInputModifiable();
+ else
+ isEditable= fTarget.isEditable();
+
+ dialog= fgFindReplaceDialogStub.getDialog();
+
+ } else {
+ if (fgFindReplaceDialogStubShell != null) {
+ fgFindReplaceDialogStubShell.checkShell(fShell);
+ }
+ if (fgFindReplaceDialogStubShell == null)
+ fgFindReplaceDialogStubShell= new FindReplaceDialogStub(fShell);
+
+ isEditable= fTarget.isEditable();
+ dialog= fgFindReplaceDialogStubShell.getDialog();
+ }
+
+ dialog.updateTarget(fTarget, isEditable, true);
+ dialog.open();
+ }
+
+ /*
+ * @see IUpdate#update()
+ */
+ public void update() {
+ if(fShell == null){
+ if (fWorkbenchPart == null && fWorkbenchWindow != null)
+ fWorkbenchPart= fWorkbenchWindow.getPartService().getActivePart();
+
+ if (fWorkbenchPart != null)
+ fTarget= (ISTFindReplaceTarget) fWorkbenchPart.getAdapter(ISTFindReplaceTarget.class);
+ else
+ fTarget= null;
+ }
+
+ if (fTarget != null){
+ fTarget.setFindAction(this);
+ }
+
+ setEnabled(fTarget != null && fTarget.canPerformFind());
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceDialog.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceDialog.java
new file mode 100644
index 0000000..2c2ba94
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STFindReplaceDialog.java
@@ -0,0 +1,1605 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.PatternSyntaxException;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ViewerRow;
+import org.eclipse.linuxtools.dataviewers.STDataViewersActivator;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.ShellAdapter;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+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.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
+import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
+import org.eclipse.ui.texteditor.IEditorStatusLine;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+
+
+/**
+ * Find/Replace dialog. The dialog is opened on a particular
+ * target but can be re-targeted. Internally used by the <code>FindReplaceAction</code>
+ */
+class STFindReplaceDialog extends Dialog {
+ private ViewerCell index;
+
+ private ViewerCell findReplacePosition;
+
+ /**
+ * Updates the find replace dialog on activation changes.
+ */
+ class ActivationListener extends ShellAdapter {
+ /*
+ * @see ShellListener#shellActivated(ShellEvent)
+ */
+ public void shellActivated(ShellEvent e) {
+ fActiveShell= (Shell)e.widget;
+ updateButtonState();
+
+ if (fGiveFocusToFindField && getShell() == fActiveShell && okToUse(fFindField))
+ fFindField.setFocus();
+
+ }
+
+ /*
+ * @see ShellListener#shellDeactivated(ShellEvent)
+ */
+ public void shellDeactivated(ShellEvent e) {
+ fGiveFocusToFindField= false;
+
+ storeSettings();
+
+ fGlobalRadioButton.setSelection(true);
+ fSelectedRangeRadioButton.setSelection(false);
+ fUseSelectedLines= false;
+
+ fActiveShell= null;
+ updateButtonState();
+ }
+ }
+
+ /**
+ * Modify listener to update the search result in case of incremental search.
+ * @since 2.0
+ */
+ private class FindModifyListener implements ModifyListener {
+
+ /*
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked()) {
+ if (fFindField.getText().equals("") && fTarget != null) { //$NON-NLS-1$
+ // empty selection at base location
+ ViewerCell start= fIncrementalBaseLocation;
+
+ if (isForwardSearch() && !fNeedsInitialFindBeforeReplace || !isForwardSearch() && fNeedsInitialFindBeforeReplace){
+ if (start.getNeighbor(ViewerCell.RIGHT, true) == null)
+ start.getNeighbor(ViewerCell.BELOW, true);
+ }
+ fNeedsInitialFindBeforeReplace= false;
+ findAndSelect(start, "", isForwardSearch(), isCaseSensitiveSearch(), isWholeWordSearch(), isRegExSearchAvailableAndChecked(),isWrapSearch()); //$NON-NLS-1$
+ } else {
+ performSearch(false);
+ }
+ }
+
+ updateButtonState(!isIncrementalSearch());
+ }
+ }
+
+ /** The size of the dialogs search history. */
+ private static final int HISTORY_SIZE= 5;
+
+ private ViewerCell fIncrementalBaseLocation;
+ private boolean fWrapInit, fCaseInit, fWholeWordInit, fForwardInit, fGlobalInit, fIncrementalInit;
+ /**
+ * Tells whether an initial find operation is needed
+ * before the replace operation.
+ * @since 3.0
+ */
+ private boolean fNeedsInitialFindBeforeReplace;
+ /**
+ * Initial value for telling whether the search string is a regular expression.
+ * @since 3.0
+ */
+ boolean fIsRegExInit;
+
+ private List<String> fFindHistory;
+ private List<String> fReplaceHistory;
+
+ private boolean fIsTargetEditable;
+ private ISTFindReplaceTarget fTarget;
+ private Shell fParentShell;
+ private Shell fActiveShell;
+
+ private final ActivationListener fActivationListener= new ActivationListener();
+ private final ModifyListener fFindModifyListener= new FindModifyListener();
+
+ private Label fReplaceLabel, fStatusLabel;
+ private Button fForwardRadioButton, fGlobalRadioButton, fSelectedRangeRadioButton;
+ private Button fCaseCheckBox, fWrapCheckBox, fWholeWordCheckBox, fIncrementalCheckBox;
+
+ /**
+ * Checkbox for selecting whether the search string is a regular expression.
+ * @since 3.0
+ */
+ private Button fIsRegExCheckBox;
+
+ private Button fReplaceSelectionButton, fReplaceFindButton, fFindNextButton, fReplaceAllButton;
+ private Combo fFindField, fReplaceField;
+
+ /**
+ * Find and replace command adapters.
+ * @since 3.3
+ */
+ private ContentAssistCommandAdapter fContentAssistFindField, fContentAssistReplaceField;
+
+ private Rectangle fDialogPositionInit;
+
+ private IDialogSettings fDialogSettings;
+ /**
+ * Tells whether the target supports regular expressions.
+ * <code>true</code> if the target supports regular expressions
+ * @since 3.0
+ */
+ private boolean fIsTargetSupportingRegEx;
+ /**
+ * Tells whether fUseSelectedLines radio is checked.
+ * @since 3.0
+ */
+ private boolean fUseSelectedLines;
+ /**
+ * <code>true</code> if the find field should receive focus the next time
+ * the dialog is activated, <code>false</code> otherwise.
+ * @since 3.0
+ */
+ private boolean fGiveFocusToFindField= true;
+
+
+ /**
+ * Creates a new dialog with the given shell as parent.
+ * @param parentShell the parent shell
+ */
+ public STFindReplaceDialog(Shell parentShell) {
+ super(parentShell);
+
+ fParentShell= null;
+ fTarget= null;
+
+ fDialogPositionInit= null;
+ fFindHistory= new ArrayList<String>(HISTORY_SIZE - 1);
+ fReplaceHistory= new ArrayList<String>(HISTORY_SIZE - 1);
+
+ fWrapInit= false;
+ fCaseInit= false;
+ fIsRegExInit= false;
+ fWholeWordInit= false;
+ fIncrementalInit= false;
+ fGlobalInit= true;
+ fForwardInit= true;
+
+ readConfiguration();
+
+ setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE | SWT.RESIZE);
+ setBlockOnOpen(false);
+ }
+
+ /**
+ * Returns this dialog's parent shell.
+ * @return the dialog's parent shell
+ */
+ public Shell getParentShell() {
+ return super.getParentShell();
+ }
+
+
+ /**
+ * Returns <code>true</code> if control can be used.
+ *
+ * @param control the control to be checked
+ * @return <code>true</code> if control can be used
+ */
+ private boolean okToUse(Control control) {
+ return control != null && !control.isDisposed();
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#create()
+ */
+ public void create() {
+
+ super.create();
+
+ Shell shell= getShell();
+ shell.addShellListener(fActivationListener);
+
+ // set help context
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IAbstractTextEditorHelpContextIds.FIND_REPLACE_DIALOG);
+
+ // fill in combo contents
+ fFindField.removeModifyListener(fFindModifyListener);
+ updateCombo(fFindField, fFindHistory);
+ fFindField.addModifyListener(fFindModifyListener);
+ updateCombo(fReplaceField, fReplaceHistory);
+
+ // get find string
+ initFindStringFromSelection();
+
+ // set dialog position
+ if (fDialogPositionInit != null)
+ shell.setBounds(fDialogPositionInit);
+
+ shell.setText(EditorMessages.FindReplace_title);
+ // shell.setImage(null);
+ }
+
+ /**
+ * Create the button section of the find/replace dialog.
+ *
+ * @param parent the parent composite
+ * @return the button section
+ */
+ private Composite createButtonSection(Composite parent) {
+
+ Composite panel= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= -2; // this is intended
+ panel.setLayout(layout);
+
+ fFindNextButton= makeButton(panel, EditorMessages.FindReplace_FindNextButton_label, 102, true, new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked())
+ initIncrementalBaseLocation();
+
+ fNeedsInitialFindBeforeReplace= false;
+ performSearch();
+ updateFindHistory();
+ fFindNextButton.setFocus();
+ }
+ });
+ setGridData(fFindNextButton, SWT.FILL, true, SWT.FILL, false);
+
+ fReplaceFindButton= makeButton(panel, EditorMessages.FindReplace_ReplaceFindButton_label, 103, false, new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ /*if (fNeedsInitialFindBeforeReplace)
+ performSearch();
+ if (performReplaceSelection())
+ performSearch();
+ updateFindAndReplaceHistory();
+ fReplaceFindButton.setFocus();*/
+ }
+ });
+ setGridData(fReplaceFindButton, SWT.FILL, false, SWT.FILL, false);
+
+ fReplaceSelectionButton= makeButton(panel, EditorMessages.FindReplace_ReplaceSelectionButton_label, 104, false, new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ /*if (fNeedsInitialFindBeforeReplace)
+ performSearch();
+ performReplaceSelection();
+ updateFindAndReplaceHistory();
+ fFindNextButton.setFocus();*/
+ }
+ });
+ setGridData(fReplaceSelectionButton, SWT.FILL, false, SWT.FILL, false);
+
+ fReplaceAllButton= makeButton(panel, EditorMessages.FindReplace_ReplaceAllButton_label, 105, false, new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ /*performReplaceAll();
+ updateFindAndReplaceHistory();
+ fFindNextButton.setFocus();*/
+ }
+ });
+ setGridData(fReplaceAllButton, SWT.FILL, true, SWT.FILL, false);
+
+ // Make the all the buttons the same size as the Remove Selection button.
+ fReplaceAllButton.setEnabled(isEditable());
+
+ return panel;
+ }
+
+ /**
+ * Creates the options configuration section of the find replace dialog.
+ *
+ * @param parent the parent composite
+ * @return the options configuration section
+ */
+ private Composite createConfigPanel(Composite parent) {
+
+ Composite panel= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ layout.makeColumnsEqualWidth= true;
+ panel.setLayout(layout);
+
+ Composite directionGroup= createDirectionGroup(panel);
+ setGridData(directionGroup, SWT.FILL, true, SWT.FILL, false);
+
+ Composite scopeGroup= createScopeGroup(panel);
+ setGridData(scopeGroup, SWT.FILL, true, SWT.FILL, false);
+
+ Composite optionsGroup= createOptionsGroup(panel);
+ setGridData(optionsGroup, SWT.FILL, true, SWT.FILL, true);
+ ((GridData)optionsGroup.getLayoutData()).horizontalSpan= 2;
+
+ return panel;
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(Composite parent) {
+
+ Composite panel= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 1;
+ layout.makeColumnsEqualWidth= true;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Composite inputPanel= createInputPanel(panel);
+ setGridData(inputPanel, SWT.FILL, true, SWT.TOP, false);
+
+ Composite configPanel= createConfigPanel(panel);
+ setGridData(configPanel, SWT.FILL, true, SWT.TOP, true);
+
+ Composite buttonPanelB= createButtonSection(panel);
+ setGridData(buttonPanelB, SWT.RIGHT, true, SWT.BOTTOM, false);
+
+ Composite statusBar= createStatusAndCloseButton(panel);
+ setGridData(statusBar, SWT.FILL, true, SWT.BOTTOM, false);
+
+ updateButtonState();
+
+ applyDialogFont(panel);
+
+ return panel;
+ }
+
+ private void setContentAssistsEnablement(boolean enable) {
+ fContentAssistFindField.setEnabled(enable);
+ fContentAssistReplaceField.setEnabled(enable);
+ }
+
+ /**
+ * Creates the direction defining part of the options defining section
+ * of the find replace dialog.
+ *
+ * @param parent the parent composite
+ * @return the direction defining part
+ */
+ private Composite createDirectionGroup(Composite parent) {
+
+ Composite panel= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginWidth= 0;
+ layout.marginHeight= 0;
+ panel.setLayout(layout);
+
+ Group group= new Group(panel, SWT.SHADOW_ETCHED_IN);
+ group.setText(EditorMessages.FindReplace_Direction);
+ GridLayout groupLayout= new GridLayout();
+ group.setLayout(groupLayout);
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ SelectionListener selectionListener= new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ calcolateIndex(fForwardRadioButton.getSelection());
+ if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked())
+ initIncrementalBaseLocation();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ };
+
+ fForwardRadioButton= new Button(group, SWT.RADIO | SWT.LEFT);
+ fForwardRadioButton.setText(EditorMessages.FindReplace_ForwardRadioButton_label);
+ setGridData(fForwardRadioButton, SWT.LEFT, false, SWT.CENTER, false);
+ fForwardRadioButton.addSelectionListener(selectionListener);
+
+ Button backwardRadioButton= new Button(group, SWT.RADIO | SWT.LEFT);
+ backwardRadioButton.setText(EditorMessages.FindReplace_BackwardRadioButton_label);
+ setGridData(backwardRadioButton, SWT.LEFT, false, SWT.CENTER, false);
+ backwardRadioButton.addSelectionListener(selectionListener);
+
+ backwardRadioButton.setSelection(!fForwardInit);
+ backwardRadioButton.setEnabled(true);
+ fForwardRadioButton.setSelection(fForwardInit);
+
+ return panel;
+ }
+
+ /**
+ * Creates the scope defining part of the find replace dialog.
+ *
+ * @param parent the parent composite
+ * @return the scope defining part
+ * @since 2.0
+ */
+ private Composite createScopeGroup(Composite parent) {
+
+ Composite panel= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginWidth= 0;
+ layout.marginHeight= 0;
+ panel.setLayout(layout);
+
+ Group group= new Group(panel, SWT.SHADOW_ETCHED_IN);
+ group.setText(EditorMessages.FindReplace_Scope);
+ GridLayout groupLayout= new GridLayout();
+ group.setLayout(groupLayout);
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ fGlobalRadioButton= new Button(group, SWT.RADIO | SWT.LEFT);
+ fGlobalRadioButton.setText(EditorMessages.FindReplace_GlobalRadioButton_label);
+ setGridData(fGlobalRadioButton, SWT.LEFT, false, SWT.CENTER, false);
+ fGlobalRadioButton.setSelection(fGlobalInit);
+ fGlobalRadioButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ if (!fGlobalRadioButton.getSelection() || !fUseSelectedLines)
+ return;
+ fUseSelectedLines= false;
+ useSelectedLines(false);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ fSelectedRangeRadioButton= new Button(group, SWT.RADIO | SWT.LEFT);
+ fSelectedRangeRadioButton.setText(EditorMessages.FindReplace_SelectedRangeRadioButton_label);
+ setGridData(fSelectedRangeRadioButton, SWT.LEFT, false, SWT.CENTER, false);
+ fSelectedRangeRadioButton.setSelection(!fGlobalInit);
+ fUseSelectedLines= !fGlobalInit;
+ fSelectedRangeRadioButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ if (!fSelectedRangeRadioButton.getSelection() || fUseSelectedLines)
+ return;
+ fUseSelectedLines= true;
+ useSelectedLines(true);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ return panel;
+ }
+
+ /**
+ * Tells the dialog to perform searches only in the scope given by the actually selected lines.
+ * @param selectedLines <code>true</code> if selected lines should be used
+ * @since 2.0
+ */
+ private void useSelectedLines(boolean selectedLines) {
+ if (isIncrementalSearch() && !isRegExSearchAvailableAndChecked())
+ initIncrementalBaseLocation();
+
+ if (fTarget == null || !(fTarget instanceof ISTFindReplaceTarget))
+ return;
+
+ fTarget.useSelectedLines(selectedLines);
+
+ }
+
+ /**
+ * Creates the panel where the user specifies the text to search
+ * for and the optional replacement text.
+ *
+ * @param parent the parent composite
+ * @return the input panel
+ */
+ private Composite createInputPanel(Composite parent) {
+
+ ModifyListener listener= new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateButtonState();
+ }
+ };
+
+ Composite panel= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ panel.setLayout(layout);
+
+ Label findLabel= new Label(panel, SWT.LEFT);
+ findLabel.setText(EditorMessages.FindReplace_Find_label);
+ setGridData(findLabel, SWT.LEFT, false, SWT.CENTER, false);
+
+ // Create the find content assist field
+ ComboContentAdapter contentAdapter= new ComboContentAdapter();
+ RegExContentProposalProvider findProposer= new RegExContentProposalProvider(true);
+ fFindField= new Combo(panel, SWT.DROP_DOWN | SWT.BORDER);
+ fContentAssistFindField= new ContentAssistCommandAdapter(
+ fFindField,
+ contentAdapter,
+ findProposer,
+ ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS,
+ new char[] {'\\', '[', '('},
+ true);
+ setGridData(fFindField, SWT.FILL, true, SWT.CENTER, false);
+ addDecorationMargin(fFindField);
+ fFindField.addModifyListener(fFindModifyListener);
+
+ fReplaceLabel= new Label(panel, SWT.LEFT);
+ fReplaceLabel.setText(EditorMessages.FindReplace_Replace_label);
+ setGridData(fReplaceLabel, SWT.LEFT, false, SWT.CENTER, false);
+
+ // Create the replace content assist field
+ RegExContentProposalProvider replaceProposer= new RegExContentProposalProvider(false);
+ fReplaceField= new Combo(panel, SWT.DROP_DOWN | SWT.BORDER);
+ fContentAssistReplaceField= new ContentAssistCommandAdapter(
+ fReplaceField,
+ contentAdapter, replaceProposer,
+ ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS,
+ new char[] {'$'},
+ true);
+ setGridData(fReplaceField, SWT.FILL, true, SWT.CENTER, false);
+ addDecorationMargin(fReplaceField);
+ fReplaceField.addModifyListener(listener);
+
+ return panel;
+ }
+
+ /**
+ * Creates the functional options part of the options defining
+ * section of the find replace dialog.
+ *
+ * @param parent the parent composite
+ * @return the options group
+ */
+ private Composite createOptionsGroup(Composite parent) {
+
+ Composite panel= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginWidth= 0;
+ layout.marginHeight= 0;
+ panel.setLayout(layout);
+
+ Group group= new Group(panel, SWT.SHADOW_NONE);
+ group.setText(EditorMessages.FindReplace_Options);
+ GridLayout groupLayout= new GridLayout();
+ groupLayout.numColumns= 2;
+ groupLayout.makeColumnsEqualWidth= true;
+ group.setLayout(groupLayout);
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ SelectionListener selectionListener= new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ storeSettings();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ };
+
+ fCaseCheckBox= new Button(group, SWT.CHECK | SWT.LEFT);
+ fCaseCheckBox.setText(EditorMessages.FindReplace_CaseCheckBox_label);
+ setGridData(fCaseCheckBox, SWT.LEFT, false, SWT.CENTER, false);
+ fCaseCheckBox.setSelection(fCaseInit);
+ fCaseCheckBox.addSelectionListener(selectionListener);
+
+ fWrapCheckBox= new Button(group, SWT.CHECK | SWT.LEFT);
+ fWrapCheckBox.setText(EditorMessages.FindReplace_WrapCheckBox_label);
+ setGridData(fWrapCheckBox, SWT.LEFT, false, SWT.CENTER, false);
+ fWrapCheckBox.setSelection(fWrapInit);
+ fWrapCheckBox.addSelectionListener(selectionListener);
+
+ fWholeWordCheckBox= new Button(group, SWT.CHECK | SWT.LEFT);
+ fWholeWordCheckBox.setText(EditorMessages.FindReplace_WholeWordCheckBox_label);
+ setGridData(fWholeWordCheckBox, SWT.LEFT, false, SWT.CENTER, false);
+ fWholeWordCheckBox.setSelection(fWholeWordInit);
+ fWholeWordCheckBox.addSelectionListener(selectionListener);
+
+ fIncrementalCheckBox= new Button(group, SWT.CHECK | SWT.LEFT);
+ fIncrementalCheckBox.setText(EditorMessages.FindReplace_IncrementalCheckBox_label);
+ setGridData(fIncrementalCheckBox, SWT.LEFT, false, SWT.CENTER, false);
+ fIncrementalCheckBox.setSelection(fIncrementalInit);
+ fIncrementalCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ if (isIncrementalSearch() && !isRegExSearch())
+ initIncrementalBaseLocation();
+
+ storeSettings();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ fIncrementalCheckBox.setEnabled(false);
+
+ fIsRegExCheckBox= new Button(group, SWT.CHECK | SWT.LEFT);
+ fIsRegExCheckBox.setText(EditorMessages.FindReplace_RegExCheckbox_label);
+ setGridData(fIsRegExCheckBox, SWT.LEFT, false, SWT.CENTER, false);
+ ((GridData)fIsRegExCheckBox.getLayoutData()).horizontalSpan= 2;
+ fIsRegExCheckBox.setSelection(fIsRegExInit);
+ fIsRegExCheckBox.addSelectionListener(new SelectionAdapter() {
+ /*
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ boolean newState= fIsRegExCheckBox.getSelection();
+ fIncrementalCheckBox.setEnabled(!newState);
+ updateButtonState();
+ storeSettings();
+ setContentAssistsEnablement(newState);
+ }
+ });
+
+
+ fWholeWordCheckBox.setEnabled(!isRegExSearchAvailableAndChecked());
+ fWholeWordCheckBox.addSelectionListener(new SelectionAdapter() {
+ /*
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ updateButtonState();
+ }
+ });
+ fIncrementalCheckBox.setEnabled(!isRegExSearchAvailableAndChecked());
+ return panel;
+ }
+
+ /**
+ * Creates the status and close section of the dialog.
+ *
+ * @param parent the parent composite
+ * @return the status and close button
+ */
+ private Composite createStatusAndCloseButton(Composite parent) {
+
+ Composite panel= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ layout.marginWidth= 0;
+ layout.marginHeight= 0;
+ panel.setLayout(layout);
+
+ fStatusLabel= new Label(panel, SWT.LEFT);
+ setGridData(fStatusLabel, SWT.FILL, true, SWT.CENTER, false);
+
+ String label= EditorMessages.FindReplace_CloseButton_label;
+ Button closeButton= createButton(panel, 101, label, false);
+ setGridData(closeButton, SWT.RIGHT, false, SWT.BOTTOM, false);
+
+ return panel;
+ }
+
+ /*
+ * @see Dialog#buttonPressed
+ */
+ protected void buttonPressed(int buttonID) {
+ if (buttonID == 101)
+ close();
+ }
+
+
+
+ // ------- action invocation ---------------------------------------
+
+ /**
+ * Returns the position of the specified search string, or <code>-1</code> if the string can
+ * not be found when searching using the given options.
+ *
+ * @param findString the string to search for
+ * @param startPosition the position at which to start the search
+ * @param forwardSearch the direction of the search
+ * @param caseSensitive should the search be case sensitive
+ * @param wrapSearch should the search wrap to the start/end if arrived at the end/start
+ * @param wholeWord does the search string represent a complete word
+ * @param regExSearch if <code>true</code> findString represents a regular expression
+ * @return the occurrence of the find string following the options or <code>-1</code> if nothing found
+ * @since 3.0
+ */
+ private ViewerCell findIndex(String findString, ViewerCell startPosition, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean regExSearch) {
+
+ if (forwardSearch) {
+ if (wrapSearch) {
+ ViewerCell index= findAndSelect(startPosition, findString, true, caseSensitive, wholeWord,regExSearch,wrapSearch);
+ if (index == null) {
+ if (okToUse(getShell()) && !isIncrementalSearch())
+ getShell().getDisplay().beep();
+
+ index= findAndSelect(fTarget.getFirstCell(startPosition,ViewerRow.ABOVE), findString, true, caseSensitive, wholeWord,regExSearch,wrapSearch);
+ }
+ return index;
+ }
+ return findAndSelect(startPosition, findString, true, caseSensitive, wholeWord,regExSearch,wrapSearch);
+ }
+
+ // backward
+ if (wrapSearch) {
+ ViewerCell index= findAndSelect(startPosition, findString, false, caseSensitive, wholeWord,regExSearch,wrapSearch);
+ if (index == null) {
+ if (okToUse(getShell()) && !isIncrementalSearch())
+ getShell().getDisplay().beep();
+ index= findAndSelect(fTarget.getFirstCell(startPosition,ViewerRow.BELOW), findString, false, caseSensitive, wholeWord,regExSearch,wrapSearch);
+ }
+ return index;
+ }
+ return findAndSelect(startPosition, findString, false, caseSensitive, wholeWord,regExSearch,wrapSearch);
+ }
+
+ /**
+ * Searches for a string starting at the given offset and using the specified search
+ * directives. If a string has been found it is selected and its start offset is
+ * returned.
+ *
+ * @param offset the offset at which searching starts
+ * @param findString the string which should be found
+ * @param forwardSearch the direction of the search
+ * @param caseSensitive <code>true</code> performs a case sensitive search, <code>false</code> an insensitive search
+ * @param wholeWord if <code>true</code> only occurrences are reported in which the findString stands as a word by itself
+ * @param regExSearch if <code>true</code> findString represents a regular expression
+ * @return the position of the specified string, or -1 if the string has not been found
+ * @since 3.0
+ */
+ private ViewerCell findAndSelect(ViewerCell offset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch,boolean wrapSearch) {
+ if (fTarget instanceof ISTFindReplaceTarget)
+ return ((ISTFindReplaceTarget)fTarget).findAndSelect(offset, findString, forwardSearch, caseSensitive, wholeWord,wrapSearch,regExSearch);
+ return null;
+ }
+
+ /**
+ * Replaces the selection with <code>replaceString</code>. If
+ * <code>regExReplace</code> is <code>true</code>,
+ * <code>replaceString</code> is a regex replace pattern which will get
+ * expanded if the underlying target supports it. Returns the region of the
+ * inserted text; note that the returned selection covers the expanded
+ * pattern in case of regex replace.
+ *
+ * @param replaceString the replace string (or a regex pattern)
+ * @param regExReplace <code>true</code> if <code>replaceString</code>
+ * is a pattern
+ * @return the selection after replacing, i.e. the inserted text
+ * @since 3.0
+ */
+ ViewerCell replaceSelection(String replaceString, boolean regExReplace) {
+ return fTarget.getSelection(index);
+ }
+
+ /**
+ * Returns whether the specified search string can be found using the given options.
+ *
+ * @param findString the string to search for
+ * @param forwardSearch the direction of the search
+ * @param caseSensitive should the search be case sensitive
+ * @param wrapSearch should the search wrap to the start/end if arrived at the end/start
+ * @param wholeWord does the search string represent a complete word
+ * @param incremental is this an incremental search
+ * @param regExSearch if <code>true</code> findString represents a regular expression
+ * @return <code>true</code> if the search string can be found using the given options
+ *
+ * @since 3.0
+ */
+ private boolean findNext(String findString, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean incremental, boolean regExSearch) {
+ if (fTarget == null)
+ return false;
+
+ ViewerCell r= null;
+
+ if (incremental)
+ r= fIncrementalBaseLocation;
+ else{
+ r= fTarget.getSelection(index);
+ }
+
+ //restores the original value
+ if (findReplacePosition != null){
+ AbstractSTViewer target = (AbstractSTViewer) fTarget;
+ if (target.getAllFields()[findReplacePosition.getColumnIndex()].getSpecialDrawer(findReplacePosition.getElement()) != null){
+ findReplacePosition.setBackground(target.getAllFields()[findReplacePosition.getColumnIndex()].getBackground(findReplacePosition.getElement()));
+ }
+ else
+ fTarget.getViewer().refresh(findReplacePosition.getElement());
+ }
+
+ findReplacePosition = r;
+
+ findReplacePosition = findIndex(findString, findReplacePosition, forwardSearch, caseSensitive, wrapSearch, wholeWord, regExSearch);
+
+ if (findReplacePosition != null){
+ findReplacePosition.setBackground(findReplacePosition.getControl().getShell().getDisplay().getSystemColor(SWT.COLOR_GREEN));
+
+ calcolateIndex(forwardSearch);
+
+ fNeedsInitialFindBeforeReplace= false;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private void calcolateIndex(boolean forwardSearch){
+ if (forwardSearch){
+ if (findReplacePosition.getNeighbor(ViewerCell.RIGHT, true) != null)
+ index = findReplacePosition.getNeighbor(ViewerCell.RIGHT, true);
+ else{
+ ViewerRow row = findReplacePosition.getViewerRow();
+ index = row.getNeighbor(ViewerRow.BELOW, true).getCell(0);
+ }
+ }
+ else{
+ if (findReplacePosition.getNeighbor(ViewerCell.LEFT, true) != null)
+ index = findReplacePosition.getNeighbor(ViewerCell.LEFT, true);
+ else{
+ ViewerRow row = findReplacePosition.getViewerRow();
+ index = row.getNeighbor(ViewerRow.ABOVE, true).getCell(0);
+ }
+ }
+ }
+
+ /**
+ * Returns the dialog's boundaries.
+ * @return the dialog's boundaries
+ */
+ private Rectangle getDialogBoundaries() {
+ if (okToUse(getShell()))
+ return getShell().getBounds();
+ return fDialogPositionInit;
+ }
+
+ /**
+ * Returns the dialog's history.
+ * @return the dialog's history
+ */
+ private List<String> getFindHistory() {
+ return fFindHistory;
+ }
+
+ // ------- accessors ---------------------------------------
+
+ /**
+ * Retrieves the string to search for from the appropriate text input field and returns it.
+ * @return the search string
+ */
+ private String getFindString() {
+ if (okToUse(fFindField)) {
+ return fFindField.getText();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the dialog's replace history.
+ * @return the dialog's replace history
+ */
+ private List<String> getReplaceHistory() {
+ return fReplaceHistory;
+ }
+
+ /**
+ * Retrieves the replacement string from the appropriate text input field and returns it.
+ * @return the replacement string
+ */
+ private String getReplaceString() {
+ if (okToUse(fReplaceField)) {
+ return fReplaceField.getText();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ // ------- init / close ---------------------------------------
+
+ /**
+ * Returns the actual selection of the find replace target.
+ * @return the selection of the target
+ */
+ private String getSelectionString() {
+ String selection= fTarget.getSelectionText(index);
+ if (selection != null && selection.length() > 0) {
+ int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0);
+ if (info[0] > 0)
+ return selection.substring(0, info[0]);
+ else if (info[0] == -1)
+ return selection;
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jface.window.Window#close()
+ */
+ public boolean close() {
+ handleDialogClose();
+ return super.close();
+ }
+
+ /**
+ * Removes focus changed listener from browser and stores settings for re-open.
+ */
+ private void handleDialogClose() {
+
+ // remove listeners
+ if (okToUse(fFindField)) {
+ fFindField.removeModifyListener(fFindModifyListener);
+ }
+
+ if (fParentShell != null) {
+ fParentShell.removeShellListener(fActivationListener);
+ fParentShell= null;
+ }
+
+ getShell().removeShellListener(fActivationListener);
+
+ // store current settings in case of re-open
+ storeSettings();
+
+ // prevent leaks
+ fActiveShell= null;
+ fTarget= null;
+
+ }
+
+ /**
+ * Writes the current selection to the dialog settings.
+ * @since 3.0
+ */
+ private void writeSelection() {
+ if (fTarget == null)
+ return;
+ String selection= fTarget.getSelectionText(index);
+ if (selection == null)
+ selection= ""; //$NON-NLS-1$
+
+ IDialogSettings s= getDialogSettings();
+ s.put("selection", selection); //$NON-NLS-1$
+ }
+
+ /**
+ * Stores the current state in the dialog settings.
+ * @since 2.0
+ */
+ private void storeSettings() {
+ fDialogPositionInit= getDialogBoundaries();
+ fWrapInit= isWrapSearch();
+ fWholeWordInit= isWholeWordSetting();
+ fCaseInit= isCaseSensitiveSearch();
+ fIsRegExInit= isRegExSearch();
+ fIncrementalInit= isIncrementalSearch();
+ fForwardInit= isForwardSearch();
+
+ writeConfiguration();
+ }
+
+ /**
+ * Initializes the string to search for and the appropriate
+ * text in the Find field based on the selection found in the
+ * action's target.
+ */
+ private void initFindStringFromSelection() {
+ if (fTarget != null && okToUse(fFindField)) {
+ String selection= getSelectionString();
+ fFindField.removeModifyListener(fFindModifyListener);
+ if (selection != null) {
+ fFindField.setText(selection);
+ if (!selection.equals(fTarget.getSelectionText(index))) {
+ useSelectedLines(true);
+ fGlobalRadioButton.setSelection(false);
+ fSelectedRangeRadioButton.setSelection(true);
+ fUseSelectedLines= true;
+ }
+ } else {
+ if ("".equals(fFindField.getText())) { //$NON-NLS-1$
+ if (fFindHistory.size() > 0)
+ fFindField.setText((String) fFindHistory.get(0));
+ else
+ fFindField.setText(""); //$NON-NLS-1$
+ }
+ }
+ fFindField.setSelection(new Point(0, fFindField.getText().length()));
+ fFindField.addModifyListener(fFindModifyListener);
+ }
+ }
+
+ /**
+ * Initializes the anchor used as starting point for incremental searching.
+ * @since 2.0
+ */
+ private void initIncrementalBaseLocation() {
+ if (fTarget != null && isIncrementalSearch() && !isRegExSearchAvailableAndChecked()) {
+ fIncrementalBaseLocation= fTarget.getSelection(index);
+ } else {
+ fIncrementalBaseLocation= null;
+ }
+
+
+ }
+
+ // ------- history ---------------------------------------
+
+ /**
+ * Retrieves and returns the option case sensitivity from the appropriate check box.
+ * @return <code>true</code> if case sensitive
+ */
+ private boolean isCaseSensitiveSearch() {
+ if (okToUse(fCaseCheckBox)) {
+ return fCaseCheckBox.getSelection();
+ }
+ return fCaseInit;
+ }
+
+ /**
+ * Retrieves and returns the regEx option from the appropriate check box.
+ *
+ * @return <code>true</code> if case sensitive
+ * @since 3.0
+ */
+ private boolean isRegExSearch() {
+ if (okToUse(fIsRegExCheckBox)) {
+ return fIsRegExCheckBox.getSelection();
+ }
+ return fIsRegExInit;
+ }
+
+ /**
+ * If the target supports regular expressions search retrieves and returns
+ * regEx option from appropriate check box.
+ *
+ * @return <code>true</code> if regEx is available and checked
+ * @since 3.0
+ */
+ private boolean isRegExSearchAvailableAndChecked() {
+ if (okToUse(fIsRegExCheckBox)) {
+ return fIsTargetSupportingRegEx && fIsRegExCheckBox.getSelection();
+ }
+ return fIsRegExInit;
+ }
+
+ /**
+ * Retrieves and returns the option search direction from the appropriate check box.
+ * @return <code>true</code> if searching forward
+ */
+ private boolean isForwardSearch() {
+ if (okToUse(fForwardRadioButton)) {
+ return fForwardRadioButton.getSelection();
+ }
+ return fForwardInit;
+ }
+
+ /**
+ * Retrieves and returns the option search whole words from the appropriate check box.
+ * @return <code>true</code> if searching for whole words
+ */
+ private boolean isWholeWordSetting() {
+ if (okToUse(fWholeWordCheckBox)) {
+ return fWholeWordCheckBox.getSelection();
+ }
+ return fWholeWordInit;
+ }
+
+ /**
+ * Returns <code>true</code> if searching should be restricted to entire
+ * words, <code>false</code> if not. This is the case if the respective
+ * checkbox is turned on, regex is off, and the checkbox is enabled, i.e.
+ * the current find string is an entire word.
+ *
+ * @return <code>true</code> if the search is restricted to whole words
+ */
+ private boolean isWholeWordSearch() {
+ return isWholeWordSetting() && !isRegExSearchAvailableAndChecked() && (okToUse(fWholeWordCheckBox) ? fWholeWordCheckBox.isEnabled() : true);
+ }
+
+ /**
+ * Retrieves and returns the option wrap search from the appropriate check box.
+ * @return <code>true</code> if wrapping while searching
+ */
+ private boolean isWrapSearch() {
+ if (okToUse(fWrapCheckBox)) {
+ return fWrapCheckBox.getSelection();
+ }
+ return fWrapInit;
+ }
+
+ /**
+ * Retrieves and returns the option incremental search from the appropriate check box.
+ * @return <code>true</code> if incremental search
+ * @since 2.0
+ */
+ private boolean isIncrementalSearch() {
+ if (okToUse(fIncrementalCheckBox)) {
+ return fIncrementalCheckBox.getSelection();
+ }
+ return fIncrementalInit;
+ }
+
+ /**
+ * Creates a button.
+ * @param parent the parent control
+ * @param label the button label
+ * @param id the button id
+ * @param dfltButton is this button the default button
+ * @param listener a button pressed listener
+ * @return the new button
+ */
+ private Button makeButton(Composite parent, String label, int id, boolean dfltButton, SelectionListener listener) {
+ Button b= createButton(parent, id, label, dfltButton);
+ b.addSelectionListener(listener);
+ return b;
+ }
+
+ /**
+ * Returns the status line manager of the active editor or <code>null</code> if there is no such editor.
+ * @return the status line manager of the active editor
+ */
+ private IEditorStatusLine getStatusLineManager() {
+ IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null)
+ return null;
+
+ IWorkbenchPage page= window.getActivePage();
+ if (page == null)
+ return null;
+
+ IEditorPart editor= page.getActiveEditor();
+ if (editor == null)
+ return null;
+
+ return (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class);
+ }
+
+ /**
+ * Sets the given status message in the status line.
+ *
+ * @param error <code>true</code> if it is an error
+ * @param message the error message
+ */
+ private void statusMessage(boolean error, String message) {
+ fStatusLabel.setText(message);
+
+ if (error)
+ fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
+ else
+ fStatusLabel.setForeground(null);
+
+ IEditorStatusLine statusLine= getStatusLineManager();
+ if (statusLine != null)
+ statusLine.setMessage(error, message, null);
+
+ if (error)
+ getShell().getDisplay().beep();
+ }
+
+ /**
+ * Sets the given error message in the status line.
+ * @param message the message
+ */
+ private void statusError(String message) {
+ statusMessage(true, message);
+ }
+
+ /**
+ * Sets the given message in the status line.
+ * @param message the message
+ */
+ private void statusMessage(String message) {
+ statusMessage(false, message);
+ }
+
+ /**
+ * Locates the user's findString in the text of the target.
+ */
+ private void performSearch() {
+ performSearch(isIncrementalSearch() && !isRegExSearchAvailableAndChecked());
+ }
+
+ /**
+ * Locates the user's findString in the text of the target.
+ *
+ * @param mustInitIncrementalBaseLocation <code>true</code> if base location must be initialized
+ * @since 3.0
+ */
+ private void performSearch(boolean mustInitIncrementalBaseLocation) {
+
+ if (mustInitIncrementalBaseLocation)
+ initIncrementalBaseLocation();
+
+ String findString= getFindString();
+
+ if (fIncrementalBaseLocation != null){
+ findString = findString + fIncrementalBaseLocation.getText();
+ }
+
+ boolean somethingFound= false;
+
+ if (findString != null && findString.length() > 0) {
+
+ try {
+ somethingFound= findNext(findString, isForwardSearch(), isCaseSensitiveSearch(), isWrapSearch(), isWholeWordSearch(), isIncrementalSearch() && !isRegExSearchAvailableAndChecked(), isRegExSearchAvailableAndChecked());
+ if (somethingFound) {
+ statusMessage(""); //$NON-NLS-1$
+ } else {
+ statusMessage(EditorMessages.FindReplace_Status_noMatch_label);
+ }
+ } catch (PatternSyntaxException ex) {
+ statusError(ex.getLocalizedMessage());
+ } catch (IllegalStateException ex) {
+ // we don't keep state in this dialog
+ }
+ }
+ writeSelection();
+ updateButtonState(!somethingFound);
+ }
+
+
+ // ------- UI creation ---------------------------------------
+
+ /**
+ * Attaches the given layout specification to the <code>component</code>.
+ *
+ * @param component the component
+ * @param horizontalAlignment horizontal alignment
+ * @param grabExcessHorizontalSpace grab excess horizontal space
+ * @param verticalAlignment vertical alignment
+ * @param grabExcessVerticalSpace grab excess vertical space
+ */
+ private void setGridData(Control component, int horizontalAlignment, boolean grabExcessHorizontalSpace, int verticalAlignment, boolean grabExcessVerticalSpace) {
+ GridData gd;
+ if (component instanceof Button && (((Button)component).getStyle() & SWT.PUSH) != 0) {
+ gd= (GridData)component.getLayoutData();
+ gd.horizontalAlignment = GridData.FILL;
+ } else {
+ gd= new GridData();
+ component.setLayoutData(gd);
+ gd.horizontalAlignment= horizontalAlignment;
+ gd.grabExcessHorizontalSpace= grabExcessHorizontalSpace;
+ }
+ gd.verticalAlignment= verticalAlignment;
+ gd.grabExcessVerticalSpace= grabExcessVerticalSpace;
+ }
+
+ /**
+ * Adds enough space in the control's layout data margin for the content assist
+ * decoration.
+ * @param control the control that needs a margin
+ * @since 3.3
+ */
+ private void addDecorationMargin(Control control) {
+ Object layoutData= control.getLayoutData();
+ if (!(layoutData instanceof GridData))
+ return;
+ GridData gd= (GridData)layoutData;
+ FieldDecoration dec= FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ gd.horizontalIndent= dec.getImage().getBounds().width;
+ }
+
+ /**
+ * Updates the enabled state of the buttons.
+ */
+ private void updateButtonState() {
+ updateButtonState(false);
+ }
+
+ /**
+ * Updates the enabled state of the buttons.
+ *
+ * @param disableReplace <code>true</code> if replace button must be disabled
+ * @since 3.0
+ */
+ private void updateButtonState(boolean disableReplace) {
+ if (okToUse(getShell()) && okToUse(fFindNextButton)) {
+ boolean enable= fTarget != null && (fActiveShell == fParentShell || fActiveShell == getShell());
+ String str= getFindString();
+ boolean findString= str != null && str.length() > 0;
+
+ fWholeWordCheckBox.setEnabled(isWord(str) && !isRegExSearchAvailableAndChecked());
+
+ fFindNextButton.setEnabled(enable && findString);
+ fReplaceSelectionButton.setEnabled(false);
+ fReplaceFindButton.setEnabled(false);
+ fReplaceAllButton.setEnabled(false);
+ }
+ }
+
+ /**
+ * Tests whether each character in the given
+ * string is a letter.
+ *
+ * @param str
+ * @return <code>true</code> if the given string is a word
+ * @since 3.0
+ */
+ private boolean isWord(String str) {
+ if (str == null || str.length() == 0)
+ return false;
+
+ for (int i= 0; i < str.length(); i++) {
+ if (!Character.isJavaIdentifierPart(str.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Updates the given combo with the given content.
+ * @param combo combo to be updated
+ * @param content to be put into the combo
+ */
+ private void updateCombo(Combo combo, List<String> content) {
+ combo.removeAll();
+ for (int i= 0; i < content.size(); i++) {
+ combo.add(content.get(i).toString());
+ }
+ }
+
+ // ------- open / reopen ---------------------------------------
+
+
+ /**
+ * Called after executed find action to update the history.
+ */
+ private void updateFindHistory() {
+ if (okToUse(fFindField)) {
+ fFindField.removeModifyListener(fFindModifyListener);
+ updateHistory(fFindField, fFindHistory);
+ fFindField.addModifyListener(fFindModifyListener);
+ }
+ }
+
+ /**
+ * Updates the combo with the history.
+ * @param combo to be updated
+ * @param history to be put into the combo
+ */
+ private void updateHistory(Combo combo, List<String> history) {
+ String findString= combo.getText();
+ int index= history.indexOf(findString);
+ if (index != 0) {
+ if (index != -1) {
+ history.remove(index);
+ }
+ history.add(0, findString);
+ updateCombo(combo, history);
+ combo.setText(findString);
+ }
+ }
+
+ /**
+ * Returns whether the target is editable.
+ * @return <code>true</code> if target is editable
+ */
+ private boolean isEditable() {
+ boolean isEditable= (fTarget == null ? false : fTarget.isEditable());
+ return fIsTargetEditable && isEditable;
+ }
+
+ /**
+ * Updates this dialog because of a different target.
+ * @param target the new target
+ * @param isTargetEditable <code>true</code> if the new target can be modified
+ * @param initializeFindString <code>true</code> if the find string of this dialog should be initialized based on the viewer's selection
+ * @since 2.0
+ */
+ public void updateTarget(ISTFindReplaceTarget target, boolean isTargetEditable, boolean initializeFindString) {
+
+ fIsTargetEditable= isTargetEditable;
+ fNeedsInitialFindBeforeReplace= true;
+
+ if (target != fTarget) {
+ //TO ADAPT with ISTFindReplaceTarget
+ /*if (fTarget != null && fTarget instanceof IFindReplaceTargetExtension)
+ ((IFindReplaceTargetExtension) fTarget).endSession();*/
+
+ fTarget= target;
+ if (fTarget != null)
+ fIsTargetSupportingRegEx= fTarget instanceof ISTFindReplaceTarget;
+
+
+ if (fTarget instanceof ISTFindReplaceTarget) {
+ //((IFindReplaceTargetExtension) fTarget).beginSession();
+
+ fGlobalInit= true;
+ fGlobalRadioButton.setSelection(fGlobalInit);
+ fSelectedRangeRadioButton.setSelection(!fGlobalInit);
+ fUseSelectedLines= !fGlobalInit;
+ }
+ }
+
+ if (okToUse(fIsRegExCheckBox))
+ fIsRegExCheckBox.setEnabled(fIsTargetSupportingRegEx);
+
+ if (okToUse(fWholeWordCheckBox))
+ fWholeWordCheckBox.setEnabled(!isRegExSearchAvailableAndChecked());
+
+ /*if (okToUse(fIncrementalCheckBox))
+ fIncrementalCheckBox.setEnabled(!isRegExSearchAvailableAndChecked());*/
+
+ if (okToUse(fReplaceLabel)) {
+ fReplaceLabel.setEnabled(isEditable());
+ fReplaceField.setEnabled(isEditable());
+ if (initializeFindString) {
+ initFindStringFromSelection();
+ fGiveFocusToFindField= true;
+ }
+ initIncrementalBaseLocation();
+ updateButtonState();
+ }
+
+ setContentAssistsEnablement(isRegExSearchAvailableAndChecked());
+ }
+
+ /**
+ * Sets the parent shell of this dialog to be the given shell.
+ *
+ * @param shell the new parent shell
+ */
+ public void setParentShell(Shell shell) {
+ if (shell != fParentShell) {
+
+ if (fParentShell != null)
+ fParentShell.removeShellListener(fActivationListener);
+
+ fParentShell= shell;
+ fParentShell.addShellListener(fActivationListener);
+ }
+
+ fActiveShell= shell;
+ }
+
+
+ //--------------- configuration handling --------------
+
+ /**
+ * Returns the dialog settings object used to share state
+ * between several find/replace dialogs.
+ *
+ * @return the dialog settings to be used
+ */
+ private IDialogSettings getDialogSettings() {
+ IDialogSettings settings= STDataViewersActivator.getDefault().getDialogSettings();
+ fDialogSettings= settings.getSection(getClass().getName());
+ if (fDialogSettings == null)
+ fDialogSettings= settings.addNewSection(getClass().getName());
+ return fDialogSettings;
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+ * @since 3.2
+ */
+ protected IDialogSettings getDialogBoundsSettings() {
+ String sectionName= getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
+ IDialogSettings settings= STDataViewersActivator.getDefault().getDialogSettings();
+ IDialogSettings section= settings.getSection(sectionName);
+ if (section == null)
+ section= settings.addNewSection(sectionName);
+ return section;
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsStrategy()
+ * @since 3.2
+ */
+ protected int getDialogBoundsStrategy() {
+ return DIALOG_PERSISTLOCATION | DIALOG_PERSISTSIZE;
+ }
+
+ /**
+ * Initializes itself from the dialog settings with the same state
+ * as at the previous invocation.
+ */
+ private void readConfiguration() {
+ IDialogSettings s= getDialogSettings();
+
+ fWrapInit= s.getBoolean("wrap"); //$NON-NLS-1$
+ fCaseInit= s.getBoolean("casesensitive"); //$NON-NLS-1$
+ fWholeWordInit= s.getBoolean("wholeword"); //$NON-NLS-1$
+ fIncrementalInit= s.getBoolean("incremental"); //$NON-NLS-1$
+ fIsRegExInit= s.getBoolean("isRegEx"); //$NON-NLS-1$
+
+ String[] findHistory= s.getArray("findhistory"); //$NON-NLS-1$
+ if (findHistory != null) {
+ List<String> history= getFindHistory();
+ history.clear();
+ for (int i= 0; i < findHistory.length; i++)
+ history.add(findHistory[i]);
+ }
+
+ String[] replaceHistory= s.getArray("replacehistory"); //$NON-NLS-1$
+ if (replaceHistory != null) {
+ List<String> history= getReplaceHistory();
+ history.clear();
+ for (int i= 0; i < replaceHistory.length; i++)
+ history.add(replaceHistory[i]);
+ }
+ }
+
+ /**
+ * Stores its current configuration in the dialog store.
+ */
+ private void writeConfiguration() {
+ IDialogSettings s= getDialogSettings();
+
+ s.put("wrap", fWrapInit); //$NON-NLS-1$
+ s.put("casesensitive", fCaseInit); //$NON-NLS-1$
+ s.put("wholeword", fWholeWordInit); //$NON-NLS-1$
+ s.put("incremental", fIncrementalInit); //$NON-NLS-1$
+ s.put("isRegEx", fIsRegExInit); //$NON-NLS-1$
+
+ List<String> history= getFindHistory();
+ String findString= getFindString();
+ if (findString.length() > 0)
+ history.add(0, findString);
+ writeHistory(history, s, "findhistory"); //$NON-NLS-1$
+
+ history= getReplaceHistory();
+ String replaceString= getReplaceString();
+ if (replaceString.length() > 0)
+ history.add(0, replaceString);
+ writeHistory(history, s, "replacehistory"); //$NON-NLS-1$
+ }
+
+ /**
+ * Writes the given history into the given dialog store.
+ *
+ * @param history the history
+ * @param settings the dialog settings
+ * @param sectionName the section name
+ * @since 3.2
+ */
+ private void writeHistory(List<String> history, IDialogSettings settings, String sectionName) {
+ int itemCount= history.size();
+ Set<String> distinctItems= new HashSet<String>(itemCount);
+ for (int i= 0; i < itemCount; i++) {
+ String item= history.get(i);
+ if (distinctItems.contains(item)) {
+ history.remove(i--);
+ itemCount--;
+ } else {
+ distinctItems.add(item);
+ }
+ }
+
+ while (history.size() > 8)
+ history.remove(8);
+
+ String[] names= new String[history.size()];
+ history.toArray(names);
+ settings.put(sectionName, names);
+
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableFindReplaceTarget.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableFindReplaceTarget.java
new file mode 100644
index 0000000..680e8a4
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableFindReplaceTarget.java
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ViewerRow;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTableViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.listeners.ISpecialDrawerListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+
+/**
+ * This class implements an ISTFindReplaceTarget for an abstractSTTableViewer instance
+ * It use a representation of a ViewerRow that is an instance of STTableViewerRow
+ * so that can be applied the "FIND algorithm" using the methods like:
+ * getCell(...)
+ * getNeighbor(...)
+ * setBackground(...)
+ * ...
+ *
+ */
+public abstract class STTableFindReplaceTarget extends AbstractSTTableViewer implements ISTFindReplaceTarget{
+ private TableViewer _viewer;
+ private STFindReplaceAction action;
+ private boolean scope;
+ private STTableViewerRow fRow;
+
+ public STTableFindReplaceTarget(Composite parent) {
+ super(parent, SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION);
+ _viewer = getViewer();
+
+ addSelectionListener();
+ }
+
+
+ public STTableFindReplaceTarget(Composite parent,boolean init) {
+ super(parent,SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION,init);
+ _viewer = getViewer();
+ addSelectionListener();
+ }
+
+ public STTableFindReplaceTarget(Composite parent, int style) {
+ super(parent,style,true);
+ _viewer = getViewer();
+ addSelectionListener();
+ }
+
+ public STTableFindReplaceTarget(Composite parent, int style,boolean init) {
+ super(parent,style,init);
+ _viewer = getViewer();
+ addSelectionListener();
+ }
+
+ public boolean canPerformFind() {
+ if (_viewer != null && _viewer.getInput() != null)
+ return true;
+ return false;
+ }
+
+ public ViewerCell findAndSelect(ViewerCell widgetOffset, String findString,
+ boolean searchForward, boolean caseSensitive, boolean wholeWord,boolean wrapSearch,boolean regExSearch) {
+ return findAndSelect(widgetOffset,findString,searchForward,searchForward,caseSensitive, wholeWord,wrapSearch,regExSearch);
+ }
+
+ public ViewerCell getSelection(ViewerCell index) {
+ if (index == null){
+ if (fRow != null)
+ return fRow.getCell(0);
+ else{
+ fRow = new STTableViewerRow(_viewer.getTable().getItem(0));
+ return fRow.getCell(0);
+ }
+ }
+
+ return index;
+ }
+
+ public String getSelectionText(ViewerCell index) {
+ if (index == null){
+ if (fRow != null)
+ return fRow.getCell(0).getText();
+ else{
+ fRow = new STTableViewerRow(_viewer.getTable().getItem(0));
+ return fRow.getCell(0).getText();
+ }
+ }
+ return index.getText();
+ }
+
+ public Boolean isEditable() {
+ return false;
+ }
+
+ private ViewerCell findAndSelect(ViewerCell cell, String findString,
+ boolean searchForward, boolean direction,boolean caseSensitive, boolean wholeWord,boolean wrapSearch,boolean regExSearch) {
+
+ if (cell == null) return null;
+
+ int dirCell = ViewerCell.RIGHT;
+
+ if (!searchForward)
+ dirCell = ViewerCell.LEFT;
+
+ Table table = _viewer.getTable();
+
+
+ if (!scope || table.isSelected(table.indexOf((TableItem)cell.getItem()))){
+ ViewerCell cellFound = searchInRow(cell.getViewerRow(),cell.getColumnIndex(),findString,searchForward,caseSensitive,wholeWord,dirCell,regExSearch);
+
+ if( cellFound != null) return cellFound;
+ }
+
+ dirCell = ViewerCell.RIGHT;
+
+ int dirRow = 0;
+ if (searchForward)
+ dirRow = ViewerRow.BELOW;
+ else
+ dirRow = ViewerRow.ABOVE;
+
+ ViewerRow row = cell.getViewerRow();
+
+ if (table.getSelectionCount() == 0){
+ while (row.getNeighbor(dirRow, true) != null){
+ row = row.getNeighbor(dirRow, true);
+ cell = searchInRow(row,0,findString,searchForward,caseSensitive,wholeWord,dirCell,regExSearch);
+ if (cell != null)
+ return cell;
+ }
+ }
+ else{
+ while (row.getNeighbor(dirRow, true) != null){
+ row = row.getNeighbor(dirRow, true);
+ if (!scope || table.isSelected(table.indexOf((TableItem)row.getItem()))){
+ cell = searchInRow(row,0,findString,searchForward,caseSensitive,wholeWord,dirCell,regExSearch);
+ if (cell != null)
+ return cell;
+ }
+ }
+ }
+
+ return null;
+
+ }
+
+ private ViewerCell searchInRow(ViewerRow row,int index,String findString,boolean searchForward,boolean caseSensitive, boolean wholeWord,int dirCell,boolean regExSearch){
+ Pattern pattern = null;
+ if (regExSearch){
+ pattern = Pattern.compile(findString);
+ }
+
+ ISTDataViewersField[] fields = getAllFields();
+
+ ViewerCell cell = row.getCell(index);
+
+ do{
+ String text = "";
+
+ ISTDataViewersField field = fields[cell.getColumnIndex()];
+ if (field.getSpecialDrawer(cell.getElement()) != null){
+ ISpecialDrawerListener hfield = (ISpecialDrawerListener)field;
+ text = hfield.getValue(cell.getElement()).trim();
+ }
+ else
+ text = cell.getText().trim();
+ boolean ok = false;
+
+ if (regExSearch){
+ Matcher matcher = pattern.matcher(text);
+ ok = matcher.find();
+ }
+ else{
+
+
+ if (wholeWord){
+ if (caseSensitive)
+ ok = text.equals(findString);
+ else
+ ok = text.equalsIgnoreCase(findString);
+ }
+ else{
+ ok = text.contains(findString);
+
+ if (ok && caseSensitive){
+ text.indexOf(findString);
+ }
+ }
+ }
+
+ if (ok){
+ _viewer.reveal(cell.getElement());
+ if (((TableViewer)_viewer).getTable().getSelectionCount() > 0){
+ TableViewer tv = (TableViewer)_viewer;
+ Table table = tv.getTable();
+ table.deselect(table.indexOf((TableItem)row.getItem()));
+ }
+
+ return cell;
+
+ }
+ cell = cell.getNeighbor(dirCell, true);
+ }
+ while(cell != null);
+
+ return null;
+ }
+
+
+ private void addSelectionListener(){
+ _viewer.addSelectionChangedListener(new ISelectionChangedListener(){
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (_viewer.getTable().getSelectionCount() > 0)
+ fRow = new STTableViewerRow(_viewer.getTable().getSelection()[0]);
+ else
+ fRow = null;
+ }
+
+ });
+ }
+
+ protected Table createTable(Composite parent, int style) {
+ Table table = new Table(parent, style);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ table.addPaintListener(new PaintListener(){
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ if (action != null) action.setEnabled(canPerformFind());
+
+ }
+
+ });
+
+ return table;
+ }
+
+
+ public void setFindAction(STFindReplaceAction action){
+ this.action = action;
+ }
+
+ public ViewerCell getFirstCell(ViewerCell start,int direction)
+ {
+ ViewerRow row = null;
+
+ if (direction == ViewerRow.ABOVE){
+ if (scope && _viewer.getTable().getSelectionCount() > 0)
+ row = new STTableViewerRow(_viewer.getTable().getSelection()[0]);
+ else
+ row = new STTableViewerRow(_viewer.getTable().getItem(0));
+ }
+ else{
+ if (scope && _viewer.getTable().getSelectionCount() > 0)
+ row = new STTableViewerRow(_viewer.getTable().getSelection()[_viewer.getTable().getSelection().length -1]);
+ else
+ row = new STTableViewerRow(_viewer.getTable().getItem(_viewer.getTable().getItemCount()-1));
+ }
+
+ return row.getCell(0);
+ }
+
+ public void useSelectedLines(boolean use){
+ this.scope = use;
+ }
+
+
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableViewerRow.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableViewerRow.java
new file mode 100644
index 0000000..1aa560b
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTableViewerRow.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.ViewerRow;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * This is a copy of TableViewerRow is the Table implementation of ViewerRow.
+ * It's useful to use some methods from protected to public that in the original
+ * TableViewerRow can't be used
+ *
+ */
+public class STTableViewerRow extends ViewerRow {
+ private TableItem item;
+
+ /**
+ * Create a new instance of the receiver from item.
+ * @param item
+ */
+ public STTableViewerRow(TableItem item) {
+ this.item = item;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getBounds(int)
+ */
+ public Rectangle getBounds(int columnIndex) {
+ return item.getBounds(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getBounds()
+ */
+ public Rectangle getBounds() {
+ return item.getBounds();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getItem()
+ */
+ public Widget getItem() {
+ return item;
+ }
+
+ void setItem(TableItem item) {
+ this.item = item;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getColumnCount()
+ */
+ public int getColumnCount() {
+ return item.getParent().getColumnCount();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getBackground(int)
+ */
+ public Color getBackground(int columnIndex) {
+ return item.getBackground(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getFont(int)
+ */
+ public Font getFont(int columnIndex) {
+ return item.getFont(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getForeground(int)
+ */
+ public Color getForeground(int columnIndex) {
+ return item.getForeground(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getImage(int)
+ */
+ public Image getImage(int columnIndex) {
+ return item.getImage(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getText(int)
+ */
+ public String getText(int columnIndex) {
+ return item.getText(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setBackground(int, org.eclipse.swt.graphics.Color)
+ */
+ public void setBackground(int columnIndex, Color color) {
+ item.setBackground(columnIndex, color);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setFont(int, org.eclipse.swt.graphics.Font)
+ */
+ public void setFont(int columnIndex, Font font) {
+ item.setFont(columnIndex, font);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setForeground(int, org.eclipse.swt.graphics.Color)
+ */
+ public void setForeground(int columnIndex, Color color) {
+ item.setForeground(columnIndex, color);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setImage(int, org.eclipse.swt.graphics.Image)
+ */
+ public void setImage(int columnIndex, Image image) {
+ Image oldImage = item.getImage(columnIndex);
+ if (oldImage != image) {
+ item.setImage(columnIndex,image);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setText(int, java.lang.String)
+ */
+ public void setText(int columnIndex, String text) {
+ item.setText(columnIndex, text == null ? "" : text); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getControl()
+ */
+ public Control getControl() {
+ return item.getParent();
+ }
+
+ public ViewerRow getNeighbor(int direction, boolean sameLevel) {
+ if( direction == ViewerRow.ABOVE ) {
+ return getRowAbove();
+ } else if( direction == ViewerRow.BELOW ) {
+ return getRowBelow();
+ } else {
+ throw new IllegalArgumentException("Illegal value of direction argument."); //$NON-NLS-1$
+ }
+ }
+
+
+ private ViewerRow getRowAbove() {
+ int index = item.getParent().indexOf(item) - 1;
+
+ if( index >= 0 ) {
+ return new STTableViewerRow(item.getParent().getItem(index));
+ }
+
+ return null;
+ }
+
+ private ViewerRow getRowBelow() {
+ int index = item.getParent().indexOf(item) + 1;
+
+ if( index < item.getParent().getItemCount() ) {
+ TableItem tmp = item.getParent().getItem(index);
+ //TODO NULL can happen in case of VIRTUAL => How do we deal with that
+ if( tmp != null ) {
+ return new STTableViewerRow(tmp);
+ }
+ }
+
+ return null;
+ }
+
+ public TreePath getTreePath() {
+ return new TreePath(new Object[] {item.getData()});
+ }
+
+ public Object clone() {
+ return new STTableViewerRow(item);
+ }
+
+ public Object getElement() {
+ return item.getData();
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeFindReplaceTarget.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeFindReplaceTarget.java
new file mode 100644
index 0000000..331afba
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeFindReplaceTarget.java
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ViewerRow;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.listeners.ISpecialDrawerListener;
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+
+/**
+ * This class implements an ISTFindReplaceTarget for an abstractSTTreeViewer instance
+ * It use a representation of a ViewerRow that is an instance of STTreeViewerRow
+ * so that can be applied the "FIND algorithm" using the methods like:
+ * getCell(...)
+ * getNeighbor(...)
+ * setBackground(...)
+ * ...
+ * @author maugerim
+ *
+ */
+public abstract class STTreeFindReplaceTarget extends AbstractSTTreeViewer implements ISTFindReplaceTarget{
+ private TreeViewer _viewer;
+ private STFindReplaceAction action;
+ private boolean scope;
+ private List<TreeItem> fSelections;
+ private STTreeViewerRow fRow;
+
+ public STTreeFindReplaceTarget(Composite parent) {
+ super(parent, SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION);
+ _viewer = getViewer();
+ addSelectionListener();
+ }
+
+ public STTreeFindReplaceTarget(Composite parent,boolean init) {
+ super(parent,SWT.BORDER |SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI| SWT.FULL_SELECTION,init);
+ _viewer = getViewer();
+ addSelectionListener();
+ }
+
+ public STTreeFindReplaceTarget(Composite parent, int style) {
+ super(parent,style,true);
+ _viewer = getViewer();
+ addSelectionListener();
+ }
+
+ public STTreeFindReplaceTarget(Composite parent, int style,boolean init) {
+ super(parent,style,init);
+ _viewer = getViewer();
+ addSelectionListener();
+ }
+
+
+ public boolean canPerformFind() {
+ if (_viewer != null && _viewer.getInput() != null)
+ return true;
+ return false;
+ }
+
+ public ViewerCell findAndSelect(ViewerCell widgetOffset, String findString,
+ boolean searchForward, boolean caseSensitive, boolean wholeWord,boolean wrapSearch,boolean regExSearch) {
+ return findAndSelect(widgetOffset,findString,searchForward,searchForward,caseSensitive, wholeWord,wrapSearch,regExSearch);
+ }
+
+ public ViewerCell getSelection(ViewerCell index) {
+ if (index == null){
+ if (fRow != null)
+ return fRow.getCell(0);
+ else{
+ fRow = new STTreeViewerRow(_viewer.getTree().getItem(0));
+ return fRow.getCell(0);
+ }
+ }
+
+ return index;
+ }
+
+ public String getSelectionText(ViewerCell index) {
+ if (index == null){
+ if (fRow != null)
+ return fRow.getCell(0).getText();
+ else{
+ fRow = new STTreeViewerRow(_viewer.getTree().getItem(0));
+ return fRow.getCell(0).getText();
+ }
+ }
+ return index.getText();
+ }
+
+ public Boolean isEditable() {
+ return false;
+ }
+
+ private ViewerCell findAndSelect(ViewerCell cell, String findString,
+ boolean searchForward, boolean direction,boolean caseSensitive, boolean wholeWord,boolean wrapSearch,boolean regExSearch) {
+
+ if (cell == null) return null;
+
+
+ int dirCell = ViewerCell.RIGHT;
+
+ if (!searchForward)
+ dirCell = ViewerCell.LEFT;
+
+ if (!scope || fSelections.indexOf(cell.getViewerRow().getItem()) != -1){
+ ViewerCell cellFound = searchInRow(cell.getViewerRow(),cell.getColumnIndex(),findString,searchForward,caseSensitive,wholeWord,dirCell,regExSearch);
+
+ if( cellFound != null) return cellFound;
+ }
+
+ dirCell = ViewerCell.RIGHT;
+
+ int dirRow = 0;
+ if (searchForward)
+ dirRow = ViewerRow.BELOW;
+ else
+ dirRow = ViewerRow.ABOVE;
+
+ ViewerRow row = cell.getViewerRow();
+
+ if (fSelections == null){
+ while (row.getNeighbor(dirRow, false) != null){
+ row = row.getNeighbor(dirRow, false);
+ cell = searchInRow(row,0,findString,searchForward,caseSensitive,wholeWord,dirCell,regExSearch);
+ if (cell != null)
+ return cell;
+ }
+ }
+ else{
+ while (row.getNeighbor(dirRow, false) != null){
+ row = row.getNeighbor(dirRow, false);
+ if (!scope || fSelections.indexOf(cell.getViewerRow().getItem()) != -1){
+ cell = searchInRow(row,0,findString,searchForward,caseSensitive,wholeWord,dirCell,regExSearch);
+ if (cell != null)
+ return cell;
+ }
+ }
+ }
+
+ return null;
+
+ }
+
+ private ViewerCell searchInRow(ViewerRow row,int index,String findString,boolean searchForward,boolean caseSensitive, boolean wholeWord,int dirCell,boolean regExSearch){
+ Pattern pattern = null;
+ if (regExSearch){
+ pattern = Pattern.compile(findString);
+ }
+
+ ISTDataViewersField[] fields = getAllFields();
+
+ ViewerCell cell = row.getCell(index);
+
+ do{
+ String text = "";
+
+ ISTDataViewersField field = fields[cell.getColumnIndex()];
+ if (field.getSpecialDrawer(cell.getElement()) != null){
+ ISpecialDrawerListener hfield = (ISpecialDrawerListener)field;
+ text = hfield.getValue(cell.getElement()).trim();
+ }
+ else
+ text = cell.getText().trim();
+
+ boolean ok = false;
+
+ if (regExSearch){
+ Matcher matcher = pattern.matcher(text);
+ ok = matcher.find();
+ }
+ else{
+ if (wholeWord){
+ if (caseSensitive)
+ ok = text.equals(findString);
+ else
+ ok = text.equalsIgnoreCase(findString);
+ }
+ else{
+ ok = text.contains(findString);
+
+ if (ok && caseSensitive){
+ text.indexOf(findString);
+ }
+ }
+ }
+
+ if (ok){
+ _viewer.reveal(cell.getElement());
+
+ if (fSelections != null && fSelections.indexOf(row.getItem()) != -1)
+ _viewer.getTree().deselectAll();
+
+ return cell;
+
+ }
+ cell = cell.getNeighbor(dirCell, true);
+ }
+ while(cell != null);
+
+ return null;
+ }
+
+ public void setFindAction(STFindReplaceAction action){
+ this.action = action;
+ }
+
+ protected Tree createTree(Composite parent, int style) {
+ Tree tree = new Tree(parent, style);
+ tree.setLinesVisible(true);
+ tree.setHeaderVisible(true);
+ tree.addPaintListener(new PaintListener(){
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ if (action != null) action.setEnabled(canPerformFind());
+
+ }
+
+ });
+
+ return tree;
+ }
+
+ public ViewerCell getFirstCell(ViewerCell start,int direction)
+ {
+ if (direction == ViewerRow.ABOVE){
+ STTreeViewerRow row;
+ if (scope && fSelections != null)
+ row = new STTreeViewerRow(_viewer.getTree().getSelection()[0]);
+ else
+ row = new STTreeViewerRow(_viewer.getTree().getItem(0));
+
+ return row.getCell(0);
+ }
+
+ if (scope && fSelections != null){
+ STTreeViewerRow row = new STTreeViewerRow(_viewer.getTree().getSelection()[_viewer.getTree().getSelection().length -1]);
+ return row.getCell(0);
+ }
+
+
+ ViewerRow row = start.getViewerRow();
+ while (row.getNeighbor(direction, true) != null)
+ row = row.getNeighbor(direction, true);
+
+ return row.getCell(0);
+ }
+
+ public void useSelectedLines(boolean use){
+ this.scope = use;
+ }
+
+ private void addSelectionListener(){
+ _viewer.addSelectionChangedListener(new ISelectionChangedListener(){
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (!event.getSelection().isEmpty()){
+ TreeItem[] items = _viewer.getTree().getSelection();
+ fSelections = Arrays.asList(items == null ? new TreeItem[0] : items);
+ fRow = new STTreeViewerRow(_viewer.getTree().getSelection()[0]);
+ }
+ else{
+ fRow = null;
+ fSelections = null;
+ }
+ }
+ });
+
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeViewerRow.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeViewerRow.java
new file mode 100644
index 0000000..123db04
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/findreplace/STTreeViewerRow.java
@@ -0,0 +1,315 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.dataviewers.findreplace;
+
+import java.util.LinkedList;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.ViewerRow;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * This is a copy of TreeViewerRow is the Tree implementation of ViewerRow.
+ * It's useful to use some methods from protected to public that in the original
+ * TreeViewerRow can't be used
+ *
+ */
+public class STTreeViewerRow extends ViewerRow {
+ private TreeItem item;
+
+ /**
+ * Create a new instance of the receiver.
+ * @param item
+ */
+ public STTreeViewerRow(TreeItem item) {
+ this.item = item;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getBounds(int)
+ */
+ public Rectangle getBounds(int columnIndex) {
+ return item.getBounds(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getBounds()
+ */
+ public Rectangle getBounds() {
+ return item.getBounds();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getColumnCount()
+ */
+ public int getColumnCount() {
+ return item.getParent().getColumnCount();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getItem()
+ */
+ public Widget getItem() {
+ return item;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getBackground(int)
+ */
+ public Color getBackground(int columnIndex) {
+ return item.getBackground(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getFont(int)
+ */
+ public Font getFont(int columnIndex) {
+ return item.getFont(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getForeground(int)
+ */
+ public Color getForeground(int columnIndex) {
+ return item.getForeground(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getImage(int)
+ */
+ public Image getImage(int columnIndex) {
+ return item.getImage(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getText(int)
+ */
+ public String getText(int columnIndex) {
+ return item.getText(columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setBackground(int, org.eclipse.swt.graphics.Color)
+ */
+ public void setBackground(int columnIndex, Color color) {
+ item.setBackground(columnIndex, color);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setFont(int, org.eclipse.swt.graphics.Font)
+ */
+ public void setFont(int columnIndex, Font font) {
+ item.setFont(columnIndex, font);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setForeground(int, org.eclipse.swt.graphics.Color)
+ */
+ public void setForeground(int columnIndex, Color color) {
+ item.setForeground(columnIndex, color);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setImage(int, org.eclipse.swt.graphics.Image)
+ */
+ public void setImage(int columnIndex, Image image) {
+ Image oldImage = item.getImage(columnIndex);
+ if (image != oldImage) {
+ item.setImage(columnIndex, image);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#setText(int, java.lang.String)
+ */
+ public void setText(int columnIndex, String text) {
+ item.setText(columnIndex, text == null ? "" : text); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerRow#getControl()
+ */
+ public Control getControl() {
+ return item.getParent();
+ }
+
+
+ public ViewerRow getNeighbor(int direction, boolean sameLevel) {
+ if( direction == ViewerRow.ABOVE ) {
+ return getRowAbove(sameLevel);
+ } else if( direction == ViewerRow.BELOW ) {
+ return getRowBelow(sameLevel);
+ } else {
+ throw new IllegalArgumentException("Illegal value of direction argument."); //$NON-NLS-1$
+ }
+ }
+
+ private ViewerRow getRowBelow(boolean sameLevel) {
+ Tree tree = item.getParent();
+
+ // This means we have top-level item
+ if( item.getParentItem() == null ) {
+ if( sameLevel || ! item.getExpanded() ) {
+ int index = tree.indexOf(item) + 1;
+
+ if( index < tree.getItemCount() ) {
+ return new STTreeViewerRow(tree.getItem(index));
+ }
+ } else if( item.getExpanded() && item.getItemCount() > 0 ) {
+ return new STTreeViewerRow(item.getItem(0));
+ }
+ } else {
+ if( sameLevel || ! item.getExpanded() ) {
+ TreeItem parentItem = item.getParentItem();
+
+ int nextIndex = parentItem.indexOf(item) + 1;
+ int totalIndex = parentItem.getItemCount();
+
+ TreeItem itemAfter;
+
+ // This would mean that it was the last item
+ if( nextIndex == totalIndex ) {
+ itemAfter = findNextItem( parentItem );
+ } else {
+ itemAfter = parentItem.getItem(nextIndex);
+ }
+
+ if( itemAfter != null ) {
+ return new STTreeViewerRow(itemAfter);
+ }
+
+ } else if( item.getExpanded() && item.getItemCount() > 0 ) {
+ return new STTreeViewerRow(item.getItem(0));
+ }
+ }
+
+ return null;
+ }
+
+ private ViewerRow getRowAbove(boolean sameLevel) {
+ Tree tree = item.getParent();
+
+ // This means we have top-level item
+ if( item.getParentItem() == null ) {
+ int index = tree.indexOf(item) - 1;
+ TreeItem nextTopItem = null;
+
+ if( index >= 0 ) {
+ nextTopItem = tree.getItem(index);
+ }
+
+ if( nextTopItem != null ) {
+ if( sameLevel ) {
+ return new STTreeViewerRow(nextTopItem);
+ }
+
+ return new STTreeViewerRow(findLastVisibleItem(nextTopItem));
+ }
+ } else {
+ TreeItem parentItem = item.getParentItem();
+ int previousIndex = parentItem.indexOf(item) - 1;
+
+ TreeItem itemBefore;
+ if( previousIndex >= 0 ) {
+ if( sameLevel ) {
+ itemBefore = parentItem.getItem(previousIndex);
+ } else {
+ itemBefore = findLastVisibleItem(parentItem.getItem(previousIndex));
+ }
+ } else {
+ itemBefore = parentItem;
+ }
+
+ if( itemBefore != null ) {
+ return new STTreeViewerRow(itemBefore);
+ }
+ }
+
+ return null;
+ }
+
+ private TreeItem findLastVisibleItem(TreeItem parentItem) {
+ TreeItem rv = parentItem;
+
+ while( rv.getExpanded() && rv.getItemCount() > 0 ) {
+ rv = rv.getItem(rv.getItemCount()-1);
+ }
+
+ return rv;
+ }
+
+ private TreeItem findNextItem(TreeItem item) {
+ TreeItem rv = null;
+ Tree tree = item.getParent();
+ TreeItem parentItem = item.getParentItem();
+
+ int nextIndex;
+ int totalItems;
+
+ if( parentItem == null ) {
+ nextIndex = tree.indexOf(item) + 1;
+ totalItems = tree.getItemCount();
+ } else {
+ nextIndex = parentItem.indexOf(item) + 1;
+ totalItems = parentItem.getItemCount();
+ }
+
+ // This is once more the last item in the tree
+ // Search on
+ if( nextIndex == totalItems ) {
+ if( item.getParentItem() != null ) {
+ rv = findNextItem(item.getParentItem());
+ }
+ } else {
+ if( parentItem == null ) {
+ rv = tree.getItem(nextIndex);
+ } else {
+ rv = parentItem.getItem(nextIndex);
+ }
+ }
+
+ return rv;
+ }
+
+ public TreePath getTreePath() {
+ TreeItem tItem = item;
+ LinkedList<Object> segments = new LinkedList<Object>();
+ while (tItem != null) {
+ Object segment = tItem.getData();
+ Assert.isNotNull(segment);
+ segments.addFirst(segment);
+ tItem = tItem.getParentItem();
+ }
+
+ return new TreePath(segments.toArray());
+ }
+
+ void setItem(TreeItem item) {
+ this.item = item;
+ }
+
+ public Object clone() {
+ return new STTreeViewerRow(item);
+ }
+
+ public Object getElement() {
+ return item.getData();
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/ISpecialDrawerListener.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/ISpecialDrawerListener.java
new file mode 100644
index 0000000..8dba8e8
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/ISpecialDrawerListener.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.listeners;
+
+import org.eclipse.swt.widgets.Listener;
+
+public interface ISpecialDrawerListener extends Listener {
+ public String getValue(Object obj);
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STColumnSizeListener.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STColumnSizeListener.java
new file mode 100644
index 0000000..8a38830
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STColumnSizeListener.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.listeners;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersHideShowManager;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Listener;
+
+
+public class STColumnSizeListener implements Listener {
+ private STDataViewersHideShowManager hideshowMng;
+
+ public STColumnSizeListener(STDataViewersHideShowManager hideshowMng){
+ this.hideshowMng = hideshowMng;
+ }
+
+ public void handleEvent(Event event) {
+ if (hideshowMng != null) {
+ Item column = (Item)event.widget;
+ AbstractSTViewer stViewer = hideshowMng.getSTViewer();
+ int width = stViewer.getColumnWidth(column);
+ hideshowMng.setWidth(stViewer.getColumnIndex(column), width);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STDisposeListener.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STDisposeListener.java
new file mode 100644
index 0000000..15881e7
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STDisposeListener.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.listeners;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+
+
+public class STDisposeListener implements DisposeListener {
+ AbstractSTViewer stViewer;
+
+ public STDisposeListener(AbstractSTViewer stViewer){
+ this.stViewer = stViewer;
+ }
+
+ public void widgetDisposed(DisposeEvent e) {
+ stViewer.saveState();
+ }
+
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STHeaderListener.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STHeaderListener.java
new file mode 100644
index 0000000..c89da79
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STHeaderListener.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.listeners;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersComparator;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Item;
+
+
+/**
+ * Handles the case of user selecting the header area.
+ */
+public class STHeaderListener implements SelectionListener {
+
+ private AbstractSTViewer stViewer;
+
+ public STHeaderListener(AbstractSTViewer stViewer){
+ this.stViewer = stViewer;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ final Item column = (Item) e.widget;
+ final ISTDataViewersField field = (ISTDataViewersField) column.getData();
+ resortTable(column, field);
+ }
+
+ /**
+ * Resort the table based on field.
+ *
+ * @param column
+ * the column being updated
+ * @param field
+ * @param monitor
+ */
+ private void resortTable(final Item column,final ISTDataViewersField field) {
+ STDataViewersComparator sorter = stViewer.getTableSorter();
+
+ if (column.equals(sorter.getTopColumn()))
+ sorter.reverseTopPriority();
+ else
+ sorter.setTopPriority(column, field);
+
+ BusyIndicator.showWhile(null,new Runnable() {
+ public void run() {
+ stViewer.getViewer().refresh();
+ stViewer.updateDirectionIndicator(column);
+ }
+ });
+ }
+}
diff --git a/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STSelectionProvider.java b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STSelectionProvider.java
new file mode 100644
index 0000000..a10f43f
--- /dev/null
+++ b/org.eclipse.linuxtools.dataviewers/src/org/eclipse/linuxtools/dataviewers/listeners/STSelectionProvider.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.dataviewers.listeners;
+
+import java.util.LinkedList;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+/*
+ * This class implements a selection service
+ */
+public class STSelectionProvider implements ISelectionProvider {
+
+ private final LinkedList<ISelectionChangedListener> listeners = new LinkedList<ISelectionChangedListener>();
+ private ISelection selection = StructuredSelection.EMPTY;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ listeners.add(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
+ */
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ listeners.remove(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
+ */
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ for (ISelectionChangedListener listener : listeners) {
+ listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov-feature/.project b/org.eclipse.linuxtools.gcov-feature/.project
new file mode 100755
index 0000000..9229605
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov-feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.gcov-feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.gcov-feature/build.properties b/org.eclipse.linuxtools.gcov-feature/build.properties
new file mode 100755
index 0000000..804860c
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov-feature/build.properties
@@ -0,0 +1,8 @@
+bin.includes = feature.xml,\
+ feature.properties,\
+ epl-v10.html,\
+ license.html
+src.includes = feature.xml,\
+ feature.properties,\
+ epl-v10.html,\
+ license.html
diff --git a/org.eclipse.linuxtools.gcov-feature/epl-v10.html b/org.eclipse.linuxtools.gcov-feature/epl-v10.html
new file mode 100755
index 0000000..9321f40
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov-feature/epl-v10.html
@@ -0,0 +1,256 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Eclipse Public License - Version 1.0</title>
+
+<style type="text/css">
+ body {
+ size: 8.5in 11.0in;
+ margin: 0.25in 0.5in 0.25in 0.5in;
+ tab-interval: 0.5in;
+ }
+ p {
+ margin-left: auto;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ p.list {
+ margin-left: 0.5in;
+ margin-top: 0.05em;
+ margin-bottom: 0.05em;
+ }
+ </style></head><body lang="EN-US">
+
+<p align="center"><b>Eclipse Public License - v 1.0</b></p>
+
+<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+AGREEMENT.</p>
+
+<p><b>1. DEFINITIONS</b></p>
+
+<p>"Contribution" means:</p>
+
+<p class="list">a) in the case of the initial Contributor, the initial
+code and documentation distributed under this Agreement, and</p>
+<p class="list">b) in the case of each subsequent Contributor:</p>
+<p class="list">i) changes to the Program, and</p>
+<p class="list">ii) additions to the Program;</p>
+<p class="list">where such changes and/or additions to the Program
+originate from and are distributed by that particular Contributor. A
+Contribution 'originates' from a Contributor if it was added to the
+Program by such Contributor itself or anyone acting on such
+Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.</p>
+
+<p>"Contributor" means any person or entity that distributes
+the Program.</p>
+
+<p>"Licensed Patents" mean patent claims licensable by a
+Contributor which are necessarily infringed by the use or sale of its
+Contribution alone or when combined with the Program.</p>
+
+<p>"Program" means the Contributions distributed in accordance
+with this Agreement.</p>
+
+<p>"Recipient" means anyone who receives the Program under
+this Agreement, including all Contributors.</p>
+
+<p><b>2. GRANT OF RIGHTS</b></p>
+
+<p class="list">a) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works
+of, publicly display, publicly perform, distribute and sublicense the
+Contribution of such Contributor, if any, and such derivative works, in
+source code and object code form.</p>
+
+<p class="list">b) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell,
+offer to sell, import and otherwise transfer the Contribution of such
+Contributor, if any, in source code and object code form. This patent
+license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to be covered
+by the Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.</p>
+
+<p class="list">c) Recipient understands that although each Contributor
+grants the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to
+secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow Recipient
+to distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.</p>
+
+<p class="list">d) Each Contributor represents that to its knowledge it
+has sufficient copyright rights in its Contribution, if any, to grant
+the copyright license set forth in this Agreement.</p>
+
+<p><b>3. REQUIREMENTS</b></p>
+
+<p>A Contributor may choose to distribute the Program in object code
+form under its own license agreement, provided that:</p>
+
+<p class="list">a) it complies with the terms and conditions of this
+Agreement; and</p>
+
+<p class="list">b) its license agreement:</p>
+
+<p class="list">i) effectively disclaims on behalf of all Contributors
+all warranties and conditions, express and implied, including warranties
+or conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;</p>
+
+<p class="list">ii) effectively excludes on behalf of all Contributors
+all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;</p>
+
+<p class="list">iii) states that any provisions which differ from this
+Agreement are offered by that Contributor alone and not by any other
+party; and</p>
+
+<p class="list">iv) states that source code for the Program is available
+from such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for software
+exchange.</p>
+
+<p>When the Program is made available in source code form:</p>
+
+<p class="list">a) it must be made available under this Agreement; and</p>
+
+<p class="list">b) a copy of this Agreement must be included with each
+copy of the Program.</p>
+
+<p>Contributors may not remove or alter any copyright notices contained
+within the Program.</p>
+
+<p>Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.</p>
+
+<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
+
+<p>Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and
+indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses")
+arising from claims, lawsuits and other legal actions brought by a third
+party against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In
+order to qualify, an Indemnified Contributor must: a) promptly notify
+the Commercial Contributor in writing of such claim, and b) allow the
+Commercial Contributor to control, and cooperate with the Commercial
+Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own
+expense.</p>
+
+<p>For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.</p>
+
+<p><b>5. NO WARRANTY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable laws,
+damage to or loss of data, programs or equipment, and unavailability or
+interruption of operations.</p>
+
+<p><b>6. DISCLAIMER OF LIABILITY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
+
+<p><b>7. GENERAL</b></p>
+
+<p>If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further action
+by the parties hereto, such provision shall be reformed to the minimum
+extent necessary to make such provision valid and enforceable.</p>
+
+<p>If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the
+date such litigation is filed.</p>
+
+<p>All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of time
+after becoming aware of such noncompliance. If all Recipient's rights
+under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.</p>
+
+<p>Everyone is permitted to copy and distribute copies of this
+Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The
+Agreement Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other than the
+Agreement Steward has the right to modify this Agreement. The Eclipse
+Foundation is the initial Agreement Steward. The Eclipse Foundation may
+assign the responsibility to serve as the Agreement Steward to a
+suitable separate entity. Each new version of the Agreement will be
+given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version
+of the Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
+rights or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.</p>
+
+<p>This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No party
+to this Agreement will bring a legal action under this Agreement more
+than one year after the cause of action arose. Each party waives its
+rights to a jury trial in any resulting litigation.</p>
+
+</body></html> \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov-feature/feature.properties b/org.eclipse.linuxtools.gcov-feature/feature.properties
new file mode 100755
index 0000000..be4bda4
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov-feature/feature.properties
@@ -0,0 +1,138 @@
+#*******************************************************************************
+# Copyright (c) 2009 Red Hat, Inc.
+# 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:
+# Red Hat, Inc. - initial API and implementation
+#********************************************************************************
+featureName=GCov Integration (Incubation)
+description=Functionality to integrate GCov with the workbench.
+featureProvider=Eclipse Linux Tools
+copyright=Copyright 2009, 2010 Red Hat, Inc.
+licenseURL=license.html
+license=\
+Eclipse Foundation Software User Agreement\n\
+April 14, 2010\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+ - Content may be structured and packaged into modules to facilitate delivering,\n\
+ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+ plug-in fragments ("Fragments"), and features ("Features").\n\
+ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+ in a directory named "plugins".\n\
+ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+ Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+ - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+ - The top-level (root) directory\n\
+ - Plug-in and Fragment directories\n\
+ - Inside Plug-ins and Fragments packaged as JARs\n\
+ - Sub-directories of the directory named "src" of certain Plug-ins\n\
+ - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+ extending or updating the functionality of an Eclipse-based product.\n\
+ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+ govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+ with the Specification. Such Installable Software Agreement must inform the user of the\n\
+ terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+ indication of agreement by the user, the provisioning Technology will complete installation\n\
+ of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
diff --git a/org.eclipse.linuxtools.gcov-feature/feature.xml b/org.eclipse.linuxtools.gcov-feature/feature.xml
new file mode 100755
index 0000000..72a9463
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov-feature/feature.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.linuxtools.gcov"
+ label="%featureName"
+ version="0.4.1.qualifier"
+ provider-name="%featureProvider">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <url>
+ <update label="Linux Tools Update Site" url="http://download.eclipse.org/technology/linuxtools/update"/>
+ </url>
+
+ <plugin
+ id="org.eclipse.linuxtools.gcov"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.binutils"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.dataviewers"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.dataviewers.charts"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/org.eclipse.linuxtools.gcov-feature/license.html b/org.eclipse.linuxtools.gcov-feature/license.html
new file mode 100644
index 0000000..c184ca3
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov-feature/license.html
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>April 14, 2010</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+ (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+ CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+ OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+ NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+ CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+ (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+ repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+ <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+ <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+ and/or Fragments associated with that Feature.</li>
+ <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+ <li>The top-level (root) directory</li>
+ <li>Plug-in and Fragment directories</li>
+ <li>Inside Plug-ins and Fragments packaged as JARs</li>
+ <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+ <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+ <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+ <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+ <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+ <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+ <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+ Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+ install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+ href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+ (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+ applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+ in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+ Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+ <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+ on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+ product.</li>
+ <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+ accessed and copied to the Target Machine.</li>
+ <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+ Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+ Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+ the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+ indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+ another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+ possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/org.eclipse.linuxtools.gcov.test/.classpath b/org.eclipse.linuxtools.gcov.test/.classpath
new file mode 100644
index 0000000..1ca8caa
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry excluding="**/.svn/**" kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.gcov.test/.project b/org.eclipse.linuxtools.gcov.test/.project
new file mode 100644
index 0000000..ea8b6fd
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.gcov.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.gcov.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.gcov.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..4ec9559
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Fri Jan 16 09:19:58 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..7340221
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.gcov.test
+Bundle-Version: 4.1.1.qualifier
+Bundle-Vendor: %bundleProvider
+Fragment-Host: org.eclipse.linuxtools.gcov
+Require-Bundle: org.junit
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.linuxtools.gcov.test/about.html b/org.eclipse.linuxtools.gcov.test/about.html
new file mode 100644
index 0000000..0c6525d
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/about.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>24th October, 2008</p>
+<h3>License</h3>
+<p>The Eclipse Software Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<h3>Contributions</h3>
+
+<p>If this Content is licensed to you under the terms and conditions of the EPL, any Contributions, as defined in the EPL, uploaded, submitted, or otherwise
+made available to the Eclipse Foundation, its members and/or the host of the Eclipse Foundation web site, by you that relate to such
+Content are provided under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+<p>If this Content is licensed to you under license terms and conditions other than the EPL (&quot;Other License&quot;), any modifications, enhancements and/or
+other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to the Eclipse Foundation, its members and/or the
+host of the Eclipse Foundation web site, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
+to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
+providing the Modifications under the terms and conditions of the <a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>
+for the Eclipse Foundation web site and such Modifications can be made available to others under the terms of the licenses as set out in the
+<a href="http://www.eclipse.org/legal/termsofuse.html">Terms of Use</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov.test/build.properties b/org.eclipse.linuxtools.gcov.test/build.properties
new file mode 100644
index 0000000..e70eafa
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/build.properties
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ test.xml,\
+ plugin.properties,\
+ test_c/,\
+ test_cpp/,\
+ about.html
diff --git a/org.eclipse.linuxtools.gcov.test/plugin.properties b/org.eclipse.linuxtools.gcov.test/plugin.properties
new file mode 100644
index 0000000..cec757f
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/plugin.properties
@@ -0,0 +1,12 @@
+#******************************************************************************
+# Copyright (c) 2009 STMicroelectronics.
+# 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:
+# Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+#*******************************************************************************
+bundleProvider = Eclipse Linux Tools
+bundleName = Gcov Test Plug-in (Incubation) \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/AllGcovTests.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/AllGcovTests.java
new file mode 100755
index 0000000..b44f96a
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/AllGcovTests.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllGcovTests {
+
+ public static Test suite() {
+ TestSuite ats = new TestSuite("Tests for org.eclipse.linuxtools.gcov.test");
+ //$JUnit-BEGIN$
+ ats.addTest(GcovGCDARetrieverTest.suite());
+ ats.addTest(GcovParserTest.suite());
+// Comment out until we fix bug #299995
+// ats.addTest(GcovViewTest.suite());
+ //$JUnit-END$
+ return ats;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovGCDARetrieverTest.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovGCDARetrieverTest.java
new file mode 100755
index 0000000..92f2ee1
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovGCDARetrieverTest.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+
+public class GcovGCDARetrieverTest extends TestCase {
+
+ public GcovGCDARetrieverTest() {
+ }
+
+ public static Test suite() {
+ TestSuite ats = new TestSuite("Gcov:GCDA_Retriever");
+ File[] testDirs = STJunitUtils.getTestDirs(Activator.PLUGIN_ID + ".test", "test.*");
+ for (File testDir : testDirs) {
+ final String[] covFiles = GcovTestUtils.getGCDANames(testDir);
+ final File binaryFile = GcovTestUtils.getBinary(testDir);
+ ats.addTest(
+ new TestCase(testDir.getName() + ":GCDA_Retriever") {
+ public void runTest() throws Throwable {
+ testGcdaRetriever(binaryFile, covFiles);
+ }
+ }
+ );
+ }
+ return ats;
+ }
+
+
+ public static void testGcdaRetriever(
+ File binaryFile, String[] covFilesPaths)
+ throws Exception {
+ CovManager covManager = new CovManager(binaryFile.getAbsolutePath());
+ List<String> list = covManager.getGCDALocations();
+ String[] generatedCovFilesPath = new String[list.size()];
+ int index = 0;
+ for (String string : list) {
+ int i = string.lastIndexOf('/');
+ string = string.substring(i+1);
+ i = string.lastIndexOf('\\');
+ string = string.substring(i+1);
+ generatedCovFilesPath[index] = string;
+ index++;
+ }
+ Arrays.sort(generatedCovFilesPath);
+ boolean b = Arrays.equals(generatedCovFilesPath, covFilesPaths);
+ Assert.assertEquals("May be normal if binary not complied with gcov options", true, b);
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovParserTest.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovParserTest.java
new file mode 100755
index 0000000..1c0b5c6
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovParserTest.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+
+public class GcovParserTest extends TestCase {
+
+ public GcovParserTest() {
+ }
+
+
+ public static Test suite() {
+ TestSuite ats = new TestSuite("Gcov:Parser");
+ File[] testDirs = STJunitUtils.getTestDirs(Activator.PLUGIN_ID + ".test", "test.*");
+ for (File testDir : testDirs) {
+ final List<String> covPaths = GcovTestUtils.getGCDAPath(testDir);
+ final File binaryFile = GcovTestUtils.getBinary(testDir);
+ final File parserRefFile = new File(testDir, "testProcessCovFiles.ref");
+ final File parserDumpFile = new File(testDir, "testProcessCovFiles.dump");
+ ats.addTest(
+ new TestCase(testDir.getName() + ":Parser") {
+ public void runTest() throws Throwable {
+ testGcovParsing(binaryFile, covPaths, parserRefFile, parserDumpFile);
+ }
+ }
+ );
+ }
+ return ats;
+ }
+
+ public static void testGcovParsing(
+ File binaryFile, List<String> covFilesPaths,
+ File parserRefFile, File parserDumpFile)
+ throws Exception {
+ CovManager covManager = new CovManager(binaryFile.getAbsolutePath());
+ covManager.processCovFiles(covFilesPaths);
+ covManager.dumpProcessCovFilesResult(new PrintStream(parserDumpFile));
+ STJunitUtils.compareIgnoreEOL(parserDumpFile.getAbsolutePath(), parserRefFile.getAbsolutePath(), true);
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovTestUtils.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovTestUtils.java
new file mode 100755
index 0000000..bd128bd
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovTestUtils.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Assert;
+
+public class GcovTestUtils {
+ public static final String GCOV_FILE_SUFFIX = ".gcda";
+ public static final String GCOV_BINARY_FILE_SUFFIX = ".out";
+ public static final String GCOV_DIRECTORY_SUFFIX = "_gcov_input";
+
+ public static String[] getGCDANames(File directory) {
+ String[] covFiles = directory.list(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(GCOV_FILE_SUFFIX);
+ }
+ });
+ Arrays.sort(covFiles);
+ return covFiles;
+ }
+
+ public static File[] getGCDA(File directory) {
+ File[] covFiles = directory.listFiles(new FileFilter() {
+ public boolean accept(File arg0) {
+ return ( arg0.isDirectory() == false && arg0.getName().endsWith(GCOV_FILE_SUFFIX));
+ }
+ });
+ Arrays.sort(covFiles);
+ return covFiles;
+ }
+
+ public static List<String> getGCDAPath(File directory) {
+ File[] covFiles = getGCDA(directory);
+ final List<String> covPaths = new ArrayList<String>(covFiles.length);
+ for (File file : covFiles) {
+ covPaths.add(file.getAbsolutePath());
+ }
+ return covPaths;
+ }
+
+ public static File getBinary(File directory) {
+ File[] binaries = directory.listFiles(new FileFilter() {
+ public boolean accept(File arg1) {
+ return ( !arg1.isDirectory() && arg1.getName().endsWith(GCOV_BINARY_FILE_SUFFIX));
+ }
+ });
+ Assert.assertEquals(1, binaries.length);
+ return binaries[0];
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovViewTest.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovViewTest.java
new file mode 100755
index 0000000..a49fcd1
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/GcovViewTest.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.util.List;
+import java.util.Locale;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.action.SwitchContentProviderAction;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+import org.eclipse.linuxtools.gcov.view.CovFileContentProvider;
+import org.eclipse.linuxtools.gcov.view.CovFolderContentProvider;
+import org.eclipse.linuxtools.gcov.view.CovFunctionContentProvider;
+import org.eclipse.linuxtools.gcov.view.CovView;
+
+public class GcovViewTest extends TestCase {
+
+ public GcovViewTest() {
+ }
+
+ public static Test suite() {
+ TestSuite emptyTestSuite = new TestSuite();
+ return emptyTestSuite;
+// Comment out until we fix bug #299995
+// TestSuite ats = new TestSuite("GCov:View");
+// File[] testDirs = STJunitUtils.getTestDirs(Activator.PLUGIN_ID + ".test", "test.*");
+//
+// for (File testDir : testDirs) {
+// final List<String> covFilesPaths = GcovTestUtils.getGCDAPath(testDir);
+// final File binary = GcovTestUtils.getBinary(testDir);
+// final File folderRefFile = new File(testDir, "testViewFolder.ref");
+// final File folderDumpFile = new File(testDir, "testViewFolder.dump");
+// final File fileRefFile = new File(testDir, "testView.ref");
+// final File fileDumpFile = new File(testDir, "testView.dump");
+// final File functionRefFile = new File(testDir, "testViewFunction.ref");
+// final File functionDumpFile = new File(testDir, "testViewFunction.dump");
+// ats.addTest(
+// new TestCase(testDir.getName() + ":CSV-DIRECTORY") {
+// public void runTest() throws Throwable {
+// testView(
+// covFilesPaths, binary,
+// CovFolderContentProvider.sharedInstance,
+// folderRefFile, folderDumpFile
+// );
+// }
+// }
+// );
+// ats.addTest(
+// new TestCase(testDir.getName() + ":CSV-FILE") {
+// public void runTest() throws Throwable {
+// testView(
+// covFilesPaths, binary,
+// CovFileContentProvider.sharedInstance,
+// fileRefFile, fileDumpFile
+// );
+// }
+// }
+// );
+// ats.addTest(
+// new TestCase(testDir.getName() + ":CSV-FUNCTION") {
+// public void runTest() throws Throwable {
+// testView(
+// covFilesPaths, binary,
+// CovFunctionContentProvider.sharedInstance,
+// functionRefFile, functionDumpFile
+// );
+// }
+// }
+// );
+// }
+// return ats;
+ }
+
+
+ public static void testView(
+ List<String> covFilesPaths, File binaryFile,
+ ITreeContentProvider provider,
+ File refFile, File dumpFile) throws Exception {
+ Locale.setDefault( Locale.US );
+ CovManager cvrgeMnger = new CovManager(binaryFile.getAbsolutePath());
+ cvrgeMnger.processCovFiles(covFilesPaths);
+ // generate model for view
+ cvrgeMnger.fillGcovView();
+ //load an Eclipse view
+ CovView cvrgeView = CovView.displayCovResults(cvrgeMnger);
+
+ SwitchContentProviderAction action = new SwitchContentProviderAction(
+ "test", "icons/directory_obj.gif",
+ cvrgeView.getSTViewer().getViewer(),
+ provider
+ );
+ action.run();
+ STJunitUtils.testCSVExport(cvrgeView, dumpFile.getAbsolutePath(), refFile.getAbsolutePath());
+
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/STJunitUtils.java b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/STJunitUtils.java
new file mode 100755
index 0000000..39cdeee
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/src/org/eclipse/linuxtools/gcov/test/STJunitUtils.java
@@ -0,0 +1,267 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.test;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.LineNumberReader;
+import java.net.URL;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersCSVExporter;
+import org.osgi.framework.Bundle;
+
+
+/**
+ * This class only contains some tools to facilitate tests
+ * (compare)
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class STJunitUtils {
+
+
+ /**
+ * Test CSV export of the given view
+ * @param view
+ * @param dumpFullFileName
+ * @param refFullFileName
+ */
+ public static void testCSVExport(AbstractSTDataView view, String dumpFullFileName, String refFullFileName) {
+ STDataViewersCSVExporter exporter = new STDataViewersCSVExporter(view.getSTViewer());
+ exporter.exportTo(dumpFullFileName, new NullProgressMonitor());
+ // compare with ref
+ compareCSVIgnoreEOL(dumpFullFileName, refFullFileName, true);
+ }
+
+ /**
+ * Utility method to compare files
+ * @param dumpFile
+ * @param refFile
+ */
+ public static boolean compare(String dumpFile, String refFile, boolean deleteDumpFileIfOk) {
+ String message = "Comparing ref file ("+refFile+ ")and dump file (" +
+ dumpFile+")";
+ boolean equals = false;
+ System.out.println(message);
+ try {
+ InputStream is1 = new FileInputStream(dumpFile);
+ InputStream is2 = new FileInputStream(refFile);
+ equals = compare(is1, is2);
+ if (!equals) {
+ System.out.println(message + "... FAILED");
+ junit.framework.Assert.assertEquals(message + ": not correspond ", true, false);
+ }
+ else {
+ System.out.println(message + "... successful");
+ }
+ // delete dump only for successful tests
+ if (equals && deleteDumpFileIfOk)
+ new File(dumpFile).delete();
+ }catch (FileNotFoundException _) {
+ message += "... FAILED: One of these files may not exist";
+ System.out.println(message);
+ junit.framework.Assert.assertNull(message, _);
+ }
+ catch (Exception _) {
+ message += ": exception raised ... FAILED";
+ System.out.println(message);
+ junit.framework.Assert.assertNull(message, _);
+ }
+ return equals;
+ }
+
+ /**
+ * Utility method to compare files
+ * @param dumpFile
+ * @param refFile
+ * @return
+ */
+ public static boolean compareIgnoreEOL(String dumpFile, String refFile, boolean deleteDumpFileIfOk) {
+ String message = "Comparing ref file ("+refFile+ ")and dump file (" +
+ dumpFile+")";
+ boolean equals = false;
+ try {
+ LineNumberReader is1 = new LineNumberReader(new FileReader(dumpFile));
+ LineNumberReader is2 = new LineNumberReader(new FileReader(refFile));
+ do {
+ String line1 = is1.readLine();
+ String line2 = is2.readLine();
+ if (line1 == null) {
+ if (line2 == null) {
+ equals = true;
+ }
+ break;
+ } else if (line2 == null || !line1.equals(line2)) {
+ break;
+ }
+ } while (true);
+
+ if (!equals) {
+ junit.framework.Assert.assertEquals(message + ": not correspond ", true, false);
+ }
+
+ is1.close();
+ is2.close();
+ // delete dump only for successful tests
+ if (equals && deleteDumpFileIfOk) {
+ new File(dumpFile).delete();
+ }
+ }catch (FileNotFoundException _) {
+ message += "... FAILED: One of these files may not exist";
+ junit.framework.Assert.assertNull(message, _);
+ }
+ catch (Exception _) {
+ message += ": exception raised ... FAILED";
+ junit.framework.Assert.assertNull(message, _);
+ }
+ return equals;
+ }
+
+ /**
+ * Utility method to compare exported CSV files
+ * @param dumpFile
+ * @param refFile
+ * @return
+ */
+ public static boolean compareCSVIgnoreEOL(String dumpFile, String refFile, boolean deleteDumpFileIfOk) {
+ String message = "Comparing ref file ("+refFile+ ")and dump file (" +
+ dumpFile+")";
+ boolean equals = false;
+ String str = "[in-charge]"; // this string can be dumped according to binutils version installed on local machine
+
+ try {
+ LineNumberReader is1 = new LineNumberReader(new FileReader(dumpFile));
+ LineNumberReader is2 = new LineNumberReader(new FileReader(refFile));
+ do {
+ String line1 = is1.readLine();
+ String line2 = is2.readLine();
+ int length = str.length();
+ if (line1 == null) {
+ if (line2 == null) {
+ equals = true;
+ }
+ break;
+ } else if (line1.contains(str)){
+ int idx = line1.indexOf("[in-charge]");
+ char c = line1.charAt(idx -1);
+ if (c == ' ' ){
+ idx--;
+ length++;
+ }
+ line1 = line1.substring(0, idx) + line1.substring(idx+length, line1.length());
+ if (!line1.equals(line2))
+ break;
+ } else if (line2 == null || !line1.equals(line2)) {
+ break;
+ }
+ } while (true);
+
+ if (!equals) {
+ junit.framework.Assert.assertEquals(message + ": not correspond ", true, false);
+ }
+
+ is1.close();
+ is2.close();
+ // delete dump only for successful tests
+ if (equals && deleteDumpFileIfOk) {
+ new File(dumpFile).delete();
+ }
+ }catch (FileNotFoundException _) {
+ message += "... FAILED: One of these files may not exist";
+ junit.framework.Assert.assertNull(message, _);
+ }
+ catch (Exception _) {
+ message += ": exception raised ... FAILED";
+ junit.framework.Assert.assertNull(message, _);
+ }
+ return equals;
+ }
+
+ /**
+ * Utility method to compare Input streams
+ * @param ISdump
+ * @param ISref
+ * @return
+ * @throws IOException
+ */
+ public static boolean compare(InputStream ISdump, InputStream ISref) throws IOException {
+ try {
+ boolean equals = false;
+ do {
+ int char1 = ISdump.read();
+ int char2 = ISref.read();
+ if (char1 != char2)
+ break;
+ if (char1 == -1) {
+ equals = true;
+ break;
+ }
+ } while (true);
+ return equals;
+ } finally {
+ ISdump.close();
+ ISref.close();
+ }
+ }
+
+ /**
+ * Gets the absolute path of a resource in the given plugin
+ * @param pluginId
+ * @param relativeName
+ * @return an absolute path to a file
+ */
+ public static String getAbsolutePath(String pluginId, String relativeName) {
+ Bundle b = Platform.getBundle(pluginId);
+ URL url = FileLocator.find(b, new Path(relativeName), null);
+ try {
+ url = FileLocator.toFileURL(url);
+ } catch (IOException e) {
+ Assert.assertNotNull("Problem locating " + relativeName + " in" + pluginId,e);
+ }
+ String filename = url.getFile();
+ return filename;
+ }
+
+ /**
+ * Utility method
+ * @param pluginDirectory: the plugin where to look for directories
+ * @param regexp: the regexp used for matching directories
+ * @return the list of directories that belong to the pluginDirectory and
+ * ends with the given extensionSuffix
+ */
+ public static File[] getTestDirs(String pluginDirectory, final String regexp) {
+ // load directories containing tests
+ String filename = getAbsolutePath(pluginDirectory, ".");
+ File dir = new File(filename);
+ File[] testDirs = dir.listFiles(
+ new FileFilter() {
+ public boolean accept(File arg0) {
+ return (arg0.isDirectory() && arg0.getName().matches(regexp));
+ }
+ }
+ );
+
+ // test if there is any directory samples
+ Assert.assertNotNull("No project files to test",testDirs);
+ return testDirs;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov.test/test.xml b/org.eclipse.linuxtools.gcov.test/test.xml
new file mode 100755
index 0000000..0d6d7f8
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+
+<project name="testsuite" default="run" basedir=".">
+ <property name="classname" value="org.eclipse.linuxtools.gcov.test.AllGcovTests" />
+ <property name="plugin-name" value="org.eclipse.linuxtools.gcov.test" />
+
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <property name="eclipse-home" value="${basedir}/../../" />
+
+ <property name="library-file" value="${eclipse-home}/dropins/${subProjectName2}/plugins/org.eclipse.test/library.xml" />
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp />
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org*.xml" />
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="gcov_suite">
+ <property name="gcov-folder" value="${eclipse-home}/gcov_folder" />
+ <delete dir="${gcov-folder}" quiet="true" />
+ <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${gcov-folder}" />
+ <property name="plugin-name" value="${plugin-name}" />
+ <property name="classname" value="${classname}" />
+ </ant>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ <mkdir dir="${results}/consolelogs" />
+ <copy failonerror="false" file="${eclipse-home}/results/${classname}.txt" tofile="${results}/consolelogs/${classname}_${platform}.metadata.log.txt" />
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,gcov_suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org*.xml" />
+ <property name="output-file" value="${plugin-name}.xml" />
+ </ant>
+ </target>
+
+ <target name="all" depends="run" description="Dummy target to run all tests">
+ </target>
+
+</project>
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/Makefile b/org.eclipse.linuxtools.gcov.test/test_c/Makefile
new file mode 100644
index 0000000..9771c05
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/Makefile
@@ -0,0 +1,8 @@
+build a.out:
+ gcc -fprofile-arcs -ftest-coverage *.c
+
+all: a.out
+ ./$< 1 2 3 4 5 6
+
+clean:
+ rm -f *.o a.out *.gcno *.gcda
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/a.out b/org.eclipse.linuxtools.gcov.test/test_c/a.out
new file mode 100755
index 0000000..baebd86
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/a.out
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/fact.c b/org.eclipse.linuxtools.gcov.test/test_c/fact.c
new file mode 100644
index 0000000..f37737a
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/fact.c
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+long mult(long val1, long val2);
+
+long fact(long val)
+{
+ int k = 100;
+ for (; k-->0;);
+ if (val == 1) return 1;
+ return mult(val,fact(val-1));
+}
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/fact.gcda b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcda
new file mode 100644
index 0000000..0515b5e
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcda
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/fact.gcno b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcno
new file mode 100644
index 0000000..d9242a8
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/fact.gcno
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/main.c b/org.eclipse.linuxtools.gcov.test/test_c/main.c
new file mode 100644
index 0000000..6065d93
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/main.c
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+
+long fact(long val);
+
+int main(int argc, char** argv)
+{
+ int i = 1;
+ for (; i<argc; i++)
+ {
+ unsigned long val = strtol(argv[i],NULL,10);
+ unsigned long res = fact(val);
+ int k = 1000;
+ for (; k-->0;);
+ printf("%li! = %li\n", val, res);
+ }
+ return 0;
+}
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/main.gcda b/org.eclipse.linuxtools.gcov.test/test_c/main.gcda
new file mode 100644
index 0000000..bcbaaac
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/main.gcda
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/main.gcno b/org.eclipse.linuxtools.gcov.test/test_c/main.gcno
new file mode 100644
index 0000000..3581c98
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/main.gcno
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/mult.c b/org.eclipse.linuxtools.gcov.test/test_c/mult.c
new file mode 100644
index 0000000..62abaa9
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/mult.c
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+long mult(long val1, long val2)
+{
+ int k = 50;
+ long res = 0;
+ for (; k-->0;);
+ while(val2-->0)
+ {
+ res += val1;
+ }
+ return res;
+}
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/mult.gcda b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcda
new file mode 100644
index 0000000..12b1038
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcda
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/mult.gcno b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcno
new file mode 100644
index 0000000..d7b49a8
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/mult.gcno
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testProcessCovFiles.ref b/org.eclipse.linuxtools.gcov.test/test_c/testProcessCovFiles.ref
new file mode 100644
index 0000000..bdb5e51
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/testProcessCovFiles.ref
@@ -0,0 +1,30 @@
+Parse gcda and gcno files done, resolve graph algorithm executed, now display results
+- PRINT FUNCTIONS ARRAY :
+-- FUNCTION 0
+ name = fact
+ instrumentd lines = 5
+ executed lines = 5
+-- FUNCTION 1
+ name = main
+ instrumentd lines = 9
+ executed lines = 9
+-- FUNCTION 2
+ name = mult
+ instrumentd lines = 7
+ executed lines = 7
+- PRINT SRCS ARRAY :
+-- FILE 0
+ name = fact.c
+ total lines = 19
+ instrumentd lines = 5
+ executed lines = 5
+-- FILE 1
+ name = main.c
+ total lines = 28
+ instrumentd lines = 9
+ executed lines = 9
+-- FILE 2
+ name = mult.c
+ total lines = 21
+ instrumentd lines = 7
+ executed lines = 7
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testView.ref b/org.eclipse.linuxtools.gcov.test/test_c/testView.ref
new file mode 100644
index 0000000..2dc8ff6
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/testView.ref
@@ -0,0 +1,8 @@
+Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage %
++-;Summary;68;21;21;100.0
+ +-;fact.c;19;5;5;100.0
+ | +-;fact;;5;5;100.0
+ +-;main.c;28;9;9;100.0
+ | +-;main;;9;9;100.0
+ +-;mult.c;21;7;7;100.0
+ +-;mult;;7;7;100.0
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testViewFolder.ref b/org.eclipse.linuxtools.gcov.test/test_c/testViewFolder.ref
new file mode 100644
index 0000000..2f8156b
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/testViewFolder.ref
@@ -0,0 +1,9 @@
+Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage %
++-;Summary;68;21;21;100.0
+ +-;?;68;21;21;100.0
+ +-;fact.c;19;5;5;100.0
+ | +-;fact;;5;5;100.0
+ +-;main.c;28;9;9;100.0
+ | +-;main;;9;9;100.0
+ +-;mult.c;21;7;7;100.0
+ +-;mult;;7;7;100.0
diff --git a/org.eclipse.linuxtools.gcov.test/test_c/testViewFunction.ref b/org.eclipse.linuxtools.gcov.test/test_c/testViewFunction.ref
new file mode 100644
index 0000000..c24b616
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_c/testViewFunction.ref
@@ -0,0 +1,5 @@
+Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage %
++-;Summary;68;21;21;100.0
+ +-;fact;;5;5;100.0
+ +-;main;;9;9;100.0
+ +-;mult;;7;7;100.0
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/Makefile b/org.eclipse.linuxtools.gcov.test/test_cpp/Makefile
new file mode 100644
index 0000000..e3c2b86
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/Makefile
@@ -0,0 +1,8 @@
+build a.out:
+ g++ -fprofile-arcs -ftest-coverage *.cpp
+
+all: a.out
+ ./$< 1 2 3 4 5 6
+
+clean:
+ rm -f *.o a.out *.gcno *.gcda
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/a.out b/org.eclipse.linuxtools.gcov.test/test_cpp/a.out
new file mode 100755
index 0000000..794f7f9
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/a.out
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.cpp b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.cpp
new file mode 100644
index 0000000..cb1e7c8
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.cpp
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+#include "fact.hpp"
+#include "mult.hpp"
+
+namespace F
+{
+
+fact::fact() {};
+
+fact::~fact() {};
+
+long fact::f(long val)
+{
+ for (int k = 100; k-->0;);
+ if (val == 1) return 1;
+ M::mult m;
+ return m.multiply(val,f(val-1));
+}
+}
+
+
+
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcda b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcda
new file mode 100644
index 0000000..042f39b
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcda
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcno b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcno
new file mode 100644
index 0000000..be33eb2
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.gcno
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/fact.hpp b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.hpp
new file mode 100644
index 0000000..32a9296
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/fact.hpp
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+
+namespace F
+{
+
+ class fact
+ {
+ public:
+ fact();
+ ~fact();
+ long f(long val);
+ };
+
+}
+
+
+
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/main.cpp b/org.eclipse.linuxtools.gcov.test/test_cpp/main.cpp
new file mode 100644
index 0000000..d3c4e21
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/main.cpp
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+#include <iostream>
+#include <stdlib.h>
+#include "fact.hpp"
+
+
+int main(int argc, char** argv)
+{
+ int i = 1;
+ for (; i<argc; i++)
+ {
+ for (int k = 1000; k-->0;);
+ unsigned long val = strtol(argv[i],NULL,10);
+ F::fact f;
+ unsigned long res = f.f(val);
+ std::cout << val
+ << "! = "
+ << res
+ << std::endl;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcda b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcda
new file mode 100644
index 0000000..073c23e
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcda
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcno b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcno
new file mode 100644
index 0000000..4f642e7
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/main.gcno
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.cpp b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.cpp
new file mode 100644
index 0000000..bd55274
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.cpp
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+#include "mult.hpp"
+
+namespace M
+{
+mult::mult() {};
+
+mult::~mult() {};
+
+long mult::multiply(long val1, long val2)
+{
+ for (int k = 50; k-->0;);
+ long res = 0;
+ while(val2-->0)
+ {
+ res += val1;
+ }
+ return res;
+};
+}
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcda b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcda
new file mode 100644
index 0000000..e2821df
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcda
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcno b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcno
new file mode 100644
index 0000000..b5f1fcd
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.gcno
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/mult.hpp b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.hpp
new file mode 100644
index 0000000..3d3f147
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/mult.hpp
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+namespace M
+{
+ class mult
+ {
+ public:
+ mult();
+
+ ~mult();
+
+ long multiply(long val1, long val2);
+ };
+}
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testProcessCovFiles.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testProcessCovFiles.ref
new file mode 100644
index 0000000..10a2316
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testProcessCovFiles.ref
@@ -0,0 +1,148 @@
+Parse gcda and gcno files done, resolve graph algorithm executed, now display results
+- PRINT FUNCTIONS ARRAY :
+-- FUNCTION 0
+ name = _ZN1F4factC2Ev
+ instrumentd lines = 1
+ executed lines = 0
+-- FUNCTION 1
+ name = _ZN1F4factC1Ev
+ instrumentd lines = 0
+ executed lines = 1
+-- FUNCTION 2
+ name = _ZN1F4factD2Ev
+ instrumentd lines = 1
+ executed lines = 0
+-- FUNCTION 3
+ name = _ZN1F4factD1Ev
+ instrumentd lines = 0
+ executed lines = 1
+-- FUNCTION 4
+ name = _ZN1F4fact1fEl
+ instrumentd lines = 5
+ executed lines = 5
+-- FUNCTION 5
+ name = _ZStorSt12_Ios_IostateS_
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 6
+ name = _ZNSolsEPFRSoS_E
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 7
+ name = _ZNKSt9basic_iosIcSt11char_traitsIcEE7rdstateEv
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 8
+ name = _Z41__static_initialization_and_destruction_0ii
+ instrumentd lines = 2
+ executed lines = 2
+-- FUNCTION 9
+ name = _GLOBAL__I_main
+ instrumentd lines = 0
+ executed lines = 0
+-- FUNCTION 10
+ name = _ZNSt9basic_iosIcSt11char_traitsIcEE8setstateESt12_Ios_Iostate
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 11
+ name = _ZNSt11char_traitsIcE6lengthEPKc
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 12
+ name = _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+ instrumentd lines = 5
+ executed lines = 0
+-- FUNCTION 13
+ name = _ZNSolsEm
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 14
+ name = main
+ instrumentd lines = 8
+ executed lines = 8
+-- FUNCTION 15
+ name = _ZSt13__check_facetISt5ctypeIcEERKT_PS3_
+ instrumentd lines = 4
+ executed lines = 0
+-- FUNCTION 16
+ name = _ZNKSt5ctypeIcE5widenEc
+ instrumentd lines = 5
+ executed lines = 0
+-- FUNCTION 17
+ name = _ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 18
+ name = _ZSt5flushIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 19
+ name = _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
+ instrumentd lines = 2
+ executed lines = 0
+-- FUNCTION 20
+ name = _ZN1M4multC2Ev
+ instrumentd lines = 1
+ executed lines = 0
+-- FUNCTION 21
+ name = _ZN1M4multC1Ev
+ instrumentd lines = 0
+ executed lines = 1
+-- FUNCTION 22
+ name = _ZN1M4multD2Ev
+ instrumentd lines = 1
+ executed lines = 0
+-- FUNCTION 23
+ name = _ZN1M4multD1Ev
+ instrumentd lines = 0
+ executed lines = 1
+-- FUNCTION 24
+ name = _ZN1M4mult8multiplyEll
+ instrumentd lines = 6
+ executed lines = 6
+- PRINT SRCS ARRAY :
+-- FILE 0
+ name = fact.cpp
+ total lines = 27
+ instrumentd lines = 7
+ executed lines = 7
+-- FILE 1
+ name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/ios_base.h
+ total lines = 168
+ instrumentd lines = 2
+ executed lines = 0
+-- FILE 2
+ name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/ostream
+ total lines = 561
+ instrumentd lines = 13
+ executed lines = 0
+-- FILE 3
+ name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/basic_ios.h
+ total lines = 441
+ instrumentd lines = 10
+ executed lines = 0
+-- FILE 4
+ name = main.cpp
+ total lines = 31
+ instrumentd lines = 9
+ executed lines = 9
+-- FILE 5
+ name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/iostream
+ total lines = 73
+ instrumentd lines = 1
+ executed lines = 1
+-- FILE 6
+ name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/char_traits.h
+ total lines = 264
+ instrumentd lines = 2
+ executed lines = 0
+-- FILE 7
+ name = /sw/gnu_compil/gnu/Linux-RH-WS-3/.package/gcc-4.4.1/bin/../lib/gcc/i686-pc-linux-gnu/4.4.1/../../../../include/c++/4.4.1/bits/locale_facets.h
+ total lines = 871
+ instrumentd lines = 5
+ executed lines = 0
+-- FILE 8
+ name = mult.cpp
+ total lines = 28
+ instrumentd lines = 8
+ executed lines = 8
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testView.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testView.ref
new file mode 100644
index 0000000..af0eefb
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testView.ref
@@ -0,0 +1,36 @@
+Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage %
++-;Summary;2464;57;25;43.86
+ +-;basic_ios.h;441;10;0;0.0
+ | +-;std::basic_ios<char, std::char_traits<char> >::rdstate() const;;2;0;0.0
+ | +-;std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate);;2;0;0.0
+ | +-;std::basic_ios<char, std::char_traits<char> >::widen(char) const;;2;0;0.0
+ | +-;std::ctype<char> const& std::__check_facet<std::ctype<char> >(std::ctype<char> const*);;4;0;0.0
+ +-;char_traits.h;264;2;0;0.0
+ | +-;std::char_traits<char>::length(char const*);;2;0;0.0
+ +-;fact.cpp;27;7;7;100.0
+ | +-;F::fact::f(long);;5;5;100.0
+ | +-;F::fact::fact();;0;1;0.0
+ | +-;F::fact::fact();;1;0;0.0
+ | +-;F::fact::~fact();;0;1;0.0
+ | +-;F::fact::~fact();;1;0;0.0
+ +-;ios_base.h;168;2;0;0.0
+ | +-;std::operator|(std::_Ios_Iostate, std::_Ios_Iostate);;2;0;0.0
+ +-;iostream;73;1;1;100.0
+ +-;locale_facets.h;871;5;0;0.0
+ | +-;std::ctype<char>::widen(char) const;;5;0;0.0
+ +-;main.cpp;31;9;9;100.0
+ | +-;__static_initialization_and_destruction_0(int, int);;2;2;100.0
+ | +-;global constructors keyed to main;;0;0;0.0
+ | +-;main;;8;8;100.0
+ +-;mult.cpp;28;8;8;100.0
+ | +-;M::mult::mult();;0;1;0.0
+ | +-;M::mult::mult();;1;0;0.0
+ | +-;M::mult::multiply(long, long);;6;6;100.0
+ | +-;M::mult::~mult();;0;1;0.0
+ | +-;M::mult::~mult();;1;0;0.0
+ +-;ostream;561;13;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >& std::flush<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*);;5;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&));;2;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long);;2;0;0.0
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFolder.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFolder.ref
new file mode 100644
index 0000000..ef35963
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFolder.ref
@@ -0,0 +1,39 @@
+Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage %
++-;Summary;2464;57;25;43.86
+ +-;4.4.1;634;14;1;7.14
+ | +-;iostream;73;1;1;100.0
+ | +-;ostream;561;13;0;0.0
+ | +-;std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0
+ | +-;std::basic_ostream<char, std::char_traits<char> >& std::flush<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0
+ | +-;std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*);;5;0;0.0
+ | +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&));;2;0;0.0
+ | +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long);;2;0;0.0
+ +-;?;86;24;24;100.0
+ | +-;fact.cpp;27;7;7;100.0
+ | | +-;F::fact::f(long);;5;5;100.0
+ | | +-;F::fact::fact();;0;1;0.0
+ | | +-;F::fact::fact();;1;0;0.0
+ | | +-;F::fact::~fact();;0;1;0.0
+ | | +-;F::fact::~fact();;1;0;0.0
+ | +-;main.cpp;31;9;9;100.0
+ | | +-;__static_initialization_and_destruction_0(int, int);;2;2;100.0
+ | | +-;global constructors keyed to main;;0;0;0.0
+ | | +-;main;;8;8;100.0
+ | +-;mult.cpp;28;8;8;100.0
+ | +-;M::mult::mult();;0;1;0.0
+ | +-;M::mult::mult();;1;0;0.0
+ | +-;M::mult::multiply(long, long);;6;6;100.0
+ | +-;M::mult::~mult();;0;1;0.0
+ | +-;M::mult::~mult();;1;0;0.0
+ +-;bits;1744;19;0;0.0
+ +-;basic_ios.h;441;10;0;0.0
+ | +-;std::basic_ios<char, std::char_traits<char> >::rdstate() const;;2;0;0.0
+ | +-;std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate);;2;0;0.0
+ | +-;std::basic_ios<char, std::char_traits<char> >::widen(char) const;;2;0;0.0
+ | +-;std::ctype<char> const& std::__check_facet<std::ctype<char> >(std::ctype<char> const*);;4;0;0.0
+ +-;char_traits.h;264;2;0;0.0
+ | +-;std::char_traits<char>::length(char const*);;2;0;0.0
+ +-;ios_base.h;168;2;0;0.0
+ | +-;std::operator|(std::_Ios_Iostate, std::_Ios_Iostate);;2;0;0.0
+ +-;locale_facets.h;871;5;0;0.0
+ +-;std::ctype<char>::widen(char) const;;5;0;0.0
diff --git a/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFunction.ref b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFunction.ref
new file mode 100644
index 0000000..e8a0cbb
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov.test/test_cpp/testViewFunction.ref
@@ -0,0 +1,27 @@
+Hierarchy;Name;Total Lines;Instrumented Lines;Executed Lines;Coverage %
++-;Summary;2464;57;25;43.86
+ +-;F::fact::f(long);;5;5;100.0
+ +-;F::fact::fact();;0;1;0.0
+ +-;F::fact::fact();;1;0;0.0
+ +-;F::fact::~fact();;0;1;0.0
+ +-;F::fact::~fact();;1;0;0.0
+ +-;M::mult::mult();;0;1;0.0
+ +-;M::mult::mult();;1;0;0.0
+ +-;M::mult::multiply(long, long);;6;6;100.0
+ +-;M::mult::~mult();;0;1;0.0
+ +-;M::mult::~mult();;1;0;0.0
+ +-;__static_initialization_and_destruction_0(int, int);;2;2;100.0
+ +-;global constructors keyed to main;;0;0;0.0
+ +-;main;;8;8;100.0
+ +-;std::basic_ios<char, std::char_traits<char> >::rdstate() const;;2;0;0.0
+ +-;std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate);;2;0;0.0
+ +-;std::basic_ios<char, std::char_traits<char> >::widen(char) const;;2;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >& std::flush<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&);;2;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*);;5;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&));;2;0;0.0
+ +-;std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long);;2;0;0.0
+ +-;std::char_traits<char>::length(char const*);;2;0;0.0
+ +-;std::ctype<char> const& std::__check_facet<std::ctype<char> >(std::ctype<char> const*);;4;0;0.0
+ +-;std::ctype<char>::widen(char) const;;5;0;0.0
+ +-;std::operator|(std::_Ios_Iostate, std::_Ios_Iostate);;2;0;0.0
diff --git a/org.eclipse.linuxtools.gcov/.classpath b/org.eclipse.linuxtools.gcov/.classpath
new file mode 100644
index 0000000..a87b062
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry excluding="**/.svn/**" kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.gcov/.project b/org.eclipse.linuxtools.gcov/.project
new file mode 100644
index 0000000..7c48214
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.gcov</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.linuxtools.gcov/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.gcov/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..3d3c172
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu Jan 15 16:04:09 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.linuxtools.gcov/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.gcov/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..da701f4
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/META-INF/MANIFEST.MF
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.gcov;singleton:=true
+Bundle-Version: 4.1.1.qualifier
+Bundle-Activator: org.eclipse.linuxtools.gcov.Activator
+Bundle-Vendor: %bundleProvider
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.linuxtools.dataviewers,
+ org.eclipse.core.filesystem,
+ org.eclipse.core.variables,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.editors,
+ org.eclipse.linuxtools.binutils,
+ org.eclipse.cdt.core,
+ org.eclipse.cdt.ui,
+ org.eclipse.jface.text,
+ org.eclipse.debug.ui,
+ org.eclipse.linuxtools.dataviewers.charts,
+ org.eclipse.linuxtools.dataviewers.annotatedsourceeditor,
+ org.tizen.common
+Export-Package: org.eclipse.linuxtools.gcov,
+ org.eclipse.linuxtools.gcov.parser,
+ org.eclipse.linuxtools.gcov.utils,
+ org.eclipse.linuxtools.gcov.view
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Localization: plugin
+Import-Package: org.tizen.common.core.application,
+ org.tizen.common.util,
+ org.tizen.nativecommon.build
diff --git a/org.eclipse.linuxtools.gcov/NOTICE b/org.eclipse.linuxtools.gcov/NOTICE
new file mode 100644
index 0000000..d4ca105
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/NOTICE
@@ -0,0 +1,6 @@
+
+org.eclipse.linuxtools.gcov.parser
+ - CovManager.java line 272
+ if windows then use strings binary in MinGW
+
+
diff --git a/org.eclipse.linuxtools.gcov/about.html b/org.eclipse.linuxtools.gcov/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov/build.properties b/org.eclipse.linuxtools.gcov/build.properties
new file mode 100644
index 0000000..a4d0a62
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = .,\
+ META-INF/,\
+ icons/,\
+ plugin.xml,\
+ about.html,\
+ plugin.properties \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov/icons/c_file_obj.gif b/org.eclipse.linuxtools.gcov/icons/c_file_obj.gif
new file mode 100644
index 0000000..915b7f4
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/icons/c_file_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov/icons/directory_obj.gif b/org.eclipse.linuxtools.gcov/icons/directory_obj.gif
new file mode 100644
index 0000000..7937f33
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/icons/directory_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov/icons/function_obj.gif b/org.eclipse.linuxtools.gcov/icons/function_obj.gif
new file mode 100644
index 0000000..08aef8f
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/icons/function_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov/icons/src_file_obj.gif b/org.eclipse.linuxtools.gcov/icons/src_file_obj.gif
new file mode 100644
index 0000000..8fd6adb
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/icons/src_file_obj.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov/icons/toggle.gif b/org.eclipse.linuxtools.gcov/icons/toggle.gif
new file mode 100644
index 0000000..62a7d86
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/icons/toggle.gif
Binary files differ
diff --git a/org.eclipse.linuxtools.gcov/plugin.properties b/org.eclipse.linuxtools.gcov/plugin.properties
new file mode 100644
index 0000000..f29e54a
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/plugin.properties
@@ -0,0 +1,16 @@
+#******************************************************************************
+# Copyright (c) 2009 STMicroelectronics.
+# 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:
+# Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+#*******************************************************************************
+bundleProvider = Eclipse Linux Tools
+bundleName = Gcov Plug-in (Incubation)
+gcovEditor = Gcov Editor
+gcov = gcov
+gcovDescription = Gcov view displays the profiling information contained in gcda/gcno files
+gcovCategory = gcov \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov/plugin.xml b/org.eclipse.linuxtools.gcov/plugin.xml
new file mode 100644
index 0000000..a546b66
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/plugin.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.eclipse.linuxtools.gcov"
+ name="%gcovCategory">
+ </category>
+ <view
+ allowMultiple="true"
+ category="org.tizen.nativeapp.viewCategory"
+ class="org.eclipse.linuxtools.gcov.view.CovView"
+ icon="icons/toggle.gif"
+ id="org.eclipse.linuxtools.gcov.view"
+ name="%gcov"
+ restorable="false">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.eclipse.linuxtools.gcov.view.annotatedsource.STAnnotatedSourceNotFoundEditor"
+ icon="icons/src_file_obj.gif"
+ id="org.eclipse.linuxtools.gcov.view.annotatedsource.STAnnotatedSourceNotFoundEditor"
+ name="Source Not Found">
+ </editor>
+ <editor
+ extensions="gcda, gcno"
+ icon="icons/toggle.gif"
+ id="org.eclipse.linuxtools.gcov.editor"
+ launcher="org.eclipse.linuxtools.gcov.action.OpenGCAction"
+ name="%gcovEditor">
+ </editor>
+ </extension>
+
+
+</plugin>
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/Activator.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/Activator.java
new file mode 100644
index 0000000..e595b1d
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/Activator.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.gcov";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/OpenGCAction.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/OpenGCAction.java
new file mode 100644
index 0000000..bfc86b4
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/OpenGCAction.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.action;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.dialog.OpenGCDialog;
+import org.eclipse.linuxtools.gcov.view.CovView;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorLauncher;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Action performed when user clicks on a gcda/gcno file
+ *
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ */
+public class OpenGCAction implements IEditorLauncher {
+
+ public void open(IPath file) {
+ Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ String extension = file.getFileExtension();
+ File gcno;
+ File gcda;
+ if ("gcno".equals(extension)) {
+ IPath file2 = file.removeFileExtension().addFileExtension("gcda");
+ gcno = file.toFile();
+ gcda = file2.toFile();
+ } else if ("gcda".equals(extension)) {
+ IPath file2 = file.removeFileExtension().addFileExtension("gcno");
+ gcda = file.toFile();
+ gcno = file2.toFile();
+
+ } else {
+ // should never occurs
+ return;
+ }
+
+ if (gcda == null || !gcda.isFile()) {
+ String msg = "File " + gcda + " does not exist.";
+ msg += "\nPlease run your application at least once.";
+ MessageDialog.openError(shell, "gcov Error", msg);
+ return;
+ }
+ if (gcno == null || !gcno.isFile()) {
+ String msg = "File " + gcno + " does not exist.";
+ msg += "\nPlease recompile your application.";
+ MessageDialog.openError(shell, "gcov Error", msg);
+ return;
+ }
+
+
+ String s = getDefaultBinary(file);
+ OpenGCDialog d = new OpenGCDialog(shell, s, file);
+ if (d.open() != OpenGCDialog.OK) {
+ return;
+ }
+ String binaryPath = d.getBinaryFile();
+ if (d.isCompleteCoverageResultWanted()) {
+ CovView.displayCovResults(binaryPath);
+ } else {
+ CovView.displayCovDetailedResult(binaryPath, gcda.getAbsolutePath());
+ }
+ }
+
+ private String getDefaultBinary(IPath file) {
+ File gmonFile = file.toFile();
+ File parent = gmonFile.getParentFile();
+ File info = new File(parent,"AnalysisInfo.txt");
+ IProject project = null;
+ IFile ifile = null;
+ try {
+ String line;
+ String tab[];
+ if (info.exists()) {
+ BufferedReader br = new BufferedReader(new FileReader(info.toString()));
+
+ while ((line = br.readLine())!= null){
+ tab = line.split("=");
+ String name="", value="";
+ if (tab.length > 1){
+ name=tab[0];
+ value=tab[1].trim();
+ if (name.equals("Project Name ")){
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(value);
+ }
+ else if (name.equals("Program Name ")){
+ if(project != null){
+ ifile = project.getFile(value);
+ br.close();
+ if (ifile.exists()) {
+ return ifile.getLocation().toString();
+ }
+ }
+ }
+ }
+ }
+ }else{
+ IFile c = ResourcesPlugin.getWorkspace().getRoot()
+ .getFileForLocation(file);
+ if (c != null) {
+ project = c.getProject();
+ if (project != null && project.exists()) {
+ ICProject cproject = CoreModel.getDefault().create(project);
+ if (cproject != null) {
+ try {
+ IBinary[] b = cproject.getBinaryContainer()
+ .getBinaries();
+ if (b != null && b.length > 0 && b[0] != null) {
+ IResource r = b[0].getResource();
+ return r.getLocation().toOSString();
+ }
+ } catch (CModelException _) {
+ }
+ }
+ }
+ }
+ }
+ } catch (FileNotFoundException e) {
+ Status status = new Status(
+ Status.WARNING,
+ Activator.PLUGIN_ID,
+ IStatus.WARNING,
+ e.getMessage(),
+ e
+ );
+ Activator.getDefault().getLog().log(status);
+ } catch (IOException e) {
+ Status status = new Status(
+ Status.ERROR,
+ Activator.PLUGIN_ID,
+ IStatus.ERROR,
+ e.getMessage(),
+ e
+ );
+ Activator.getDefault().getLog().log(status);
+ }
+ return "";
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/SwitchContentProviderAction.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/SwitchContentProviderAction.java
new file mode 100644
index 0000000..b1ac0f2
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/action/SwitchContentProviderAction.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.action;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.gcov.Activator;
+
+
+ /**
+ * This action changes the content provider
+ */
+
+ public class SwitchContentProviderAction extends Action {
+
+ private final ColumnViewer viewer;
+ private final IContentProvider provider;
+
+ public SwitchContentProviderAction(String name, String iconPath, ColumnViewer viewer, IContentProvider provider) {
+ super(name, AS_RADIO_BUTTON);
+ this.setImageDescriptor(Activator.getImageDescriptor(iconPath));
+ this.setToolTipText(name);
+ this.viewer = viewer;
+ this.provider = provider;
+ }
+
+ @Override
+ public void run() {
+ viewer.getControl().setRedraw(false);
+ viewer.setContentProvider(provider);
+ ((TreeViewer)viewer).expandToLevel(2);
+ viewer.getControl().setRedraw(true);
+ }
+ } \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/dialog/OpenGCDialog.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/dialog/OpenGCDialog.java
new file mode 100644
index 0000000..5b69b71
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/dialog/OpenGCDialog.java
@@ -0,0 +1,303 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.dialog;
+
+import java.io.File;
+
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+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.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+
+/**
+ * This dialog box is opened when user clicks on a gcno/gcda file.
+ * it allows the user to choose the binary file who produced the gcno/gcda file.
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ *
+ */
+public class OpenGCDialog extends Dialog {
+
+ /* Inputs */
+ private Text binText;
+ private String binValue;
+
+ private Button openThisFileOnlyButton;
+ private Button openCoverageSummaryButton;
+ private boolean openCoverageSummary = true;
+
+ /* buttons */
+ private Button binBrowseWorkspaceButton;
+ private Button binBrowseFileSystemButton;
+
+ /* error label */
+ private Label errorLabel;
+
+ /* validation boolean */
+ private boolean binaryValid;
+
+ /* internal listener */
+ private final BinaryModifyListener binModifyListener = new BinaryModifyListener();
+
+ private final String defaultValue;
+ private final IPath gcFile;
+
+ /**
+ * Constructor
+ * @param parentShell
+ * @param binPath the path to a binary file.
+ */
+ public OpenGCDialog(Shell parentShell, String binPath, IPath gcFile) {
+ super(parentShell);
+ this.gcFile = gcFile;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ this.defaultValue = binPath;
+ }
+
+ /**
+ * Gets the Binary file selected by the user
+ * @return a path to a binary file
+ */
+ public String getBinaryFile() {
+ return binValue;
+ }
+
+ /**
+ * Gets whether the user wants a complete coverage result, or a result specific file to the given gcFile.
+ */
+ public boolean isCompleteCoverageResultWanted() {
+ return openCoverageSummary;
+ }
+
+
+ protected Control createContents(Composite parent) {
+ Control composite = super.createContents(parent);
+ validateBinary();
+ return composite;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ this.getShell().setText("Gcov - Open coverage results...");
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ /* first line */
+ Group c = new Group(composite, SWT.NONE);
+ c.setText("Binary File");
+ c.setToolTipText("Please enter here the binary file which produced the coverage data.");
+ GridLayout layout = new GridLayout(2,false);
+ c.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ c.setLayoutData(data);
+
+ Label binLabel = new Label(c,SWT.NONE);
+ binLabel.setText("Please enter here the binary file which produced the coverage data.");
+ data = new GridData();
+ data.horizontalSpan = 2;
+ binLabel.setLayoutData(data);
+
+ binText = new Text(c,SWT.BORDER);
+ binText.setText(this.defaultValue);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ binText.setLayoutData(data);
+ binText.addModifyListener(binModifyListener);
+
+ Composite cbBin = new Composite(c,SWT.NONE);
+ data = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ cbBin.setLayoutData(data);
+ cbBin.setLayout(new GridLayout(2, true));
+ binBrowseWorkspaceButton = new Button(cbBin, SWT.PUSH);
+ binBrowseWorkspaceButton.setText("&Workspace...");
+ binBrowseWorkspaceButton.addSelectionListener(
+ new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent sev)
+ {
+ handleBrowseWorkspace("Open Binary file...", binText);
+ }
+ }
+ );
+ binBrowseFileSystemButton = new Button(cbBin, SWT.PUSH);
+ binBrowseFileSystemButton.setText("&File System...");
+ binBrowseFileSystemButton.addSelectionListener(
+ new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent sev)
+ {
+ handleBrowse("Open Binary file...", binText);
+ }
+ }
+ );
+
+ Group covMode = new Group(composite, SWT.NONE);
+ covMode.setText("Coverage result");
+ covMode.setToolTipText("Please choose the result scope.");
+ GridData covModeData = new GridData(GridData.FILL_BOTH);
+ covMode.setLayoutData(covModeData);
+ covMode.setLayout(new GridLayout());
+ openThisFileOnlyButton = new Button(covMode, SWT.RADIO);
+ openThisFileOnlyButton.setLayoutData(new GridData());
+ openCoverageSummaryButton = new Button(covMode, SWT.RADIO);
+ openCoverageSummaryButton.setLayoutData(new GridData());
+ String cFile = gcFile.removeFileExtension().lastSegment() + ".c";
+
+ openThisFileOnlyButton.setText("Show coverage details for \"" + cFile + "\" only.");
+ openCoverageSummaryButton.setText("Show coverage for the whole selected binary file");
+
+ openCoverageSummaryButton.setSelection(true);
+
+ SelectionAdapter sa = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent sev)
+ {
+ openCoverageSummary = openCoverageSummaryButton.getSelection();
+ }
+ };
+ openCoverageSummaryButton.addSelectionListener(sa);
+ openThisFileOnlyButton.addSelectionListener(sa);
+
+
+ /* 2sd line */
+ errorLabel = new Label(composite,SWT.NONE);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 3;
+ errorLabel.setLayoutData(data);
+ errorLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
+
+ c.layout();
+
+ return composite;
+ }
+
+ private void validateBinary() {
+ binValue = binText.getText();
+ IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
+ try {
+ binValue = mgr.performStringSubstitution(binValue, false);
+ } catch (CoreException _) {
+ // do nothing: never occurs
+ }
+
+ File f = new File(binValue);
+ if (f.exists()) {
+ IBinaryObject binary = STSymbolManager.sharedInstance.getBinaryObject(new Path(binValue));
+ if (binary == null) {
+ MessageDialog.openError(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ "Invalid binary file",
+ binText.getText() + " is not a valid binary file.");
+ return;
+ }
+ binaryValid = true;
+ getButton(IDialogConstants.OK_ID).setEnabled(binaryValid);
+ errorLabel.setText("");
+ } else {
+ binaryValid = false;
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ if (!binValue.equals("")) {
+ errorLabel.setText("\"" + binText.getText() + "\" doesn't exist");
+ } else {
+ errorLabel.setText("Please enter a binary file");
+ }
+ return;
+ }
+ }
+
+ private class BinaryModifyListener implements ModifyListener
+ {
+ public void modifyText(ModifyEvent e) {
+ validateBinary();
+ }
+
+ }
+
+ protected void handleBrowseWorkspace(String msg, Text text) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ dialog.setTitle(msg);
+ dialog.setMessage(msg);
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+ dialog.setAllowMultiple(false);
+ IContainer c = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(this.gcFile);
+ if (c != null) dialog.setInitialSelection(c.getProject());
+ dialog.setValidator(new ISelectionStatusValidator() {
+ public IStatus validate(Object[] selection)
+ {
+ if (selection.length != 1) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ }
+ if (!(selection[0] instanceof IFile)) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ }
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ }
+ });
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ IResource resource = (IResource) dialog.getFirstResult();
+ text.setText("${resource_loc:" + resource.getFullPath() + "}");
+ }
+ }
+
+
+ protected void handleBrowse(String msg, Text text)
+ {
+ FileDialog dialog = new FileDialog(this.getShell(),SWT.OPEN);
+ dialog.setText(msg);
+ String t = text.getText();
+ IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
+ try {
+ t = mgr.performStringSubstitution(t, false);
+ } catch (CoreException _) {
+ // do nothing: never occurs
+ }
+ File f = new File(t);
+ t = f.getParent();
+ if (t == null || t.length() == 0) {
+ t = this.gcFile.removeLastSegments(1).toOSString();
+ }
+ dialog.setFilterPath(t);
+ String s = dialog.open();
+ if (s != null) text.setText(s);
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/AbstractTreeElement.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/AbstractTreeElement.java
new file mode 100644
index 0000000..0fcce34
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/AbstractTreeElement.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.model;
+
+import java.util.LinkedList;
+
+public abstract class AbstractTreeElement implements TreeElement{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4911602250295116203L;
+ private final TreeElement parent;
+ private final LinkedList<TreeElement> children = new LinkedList<TreeElement>();
+ private final String name;
+ private final int totalLines;
+ private final int executedLines;
+ private final int instrumentedLines;
+
+ public AbstractTreeElement(TreeElement parent, String name, int totalLines,
+ int executedLines, int instrumentedLines) {
+ this.parent = parent;
+ this.name = name;
+ this.totalLines = totalLines;
+ this.executedLines = executedLines;
+ this.instrumentedLines = instrumentedLines;
+ }
+
+ public TreeElement getParent() {
+ return parent;
+ }
+
+ public boolean hasChildren() {
+ return (children.size()>0);
+ }
+
+ public LinkedList<? extends TreeElement> getChildren() {
+ return children;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public TreeElement getRoot() {
+ if (parent == null) return this;
+ return parent.getRoot();
+ }
+
+ public int getExecutedLines() {
+ return executedLines;
+ }
+
+ public int getInstrumentedLines() {
+ return instrumentedLines;
+ }
+
+ public float getCoveragePercentage() {
+ if (instrumentedLines !=0 )
+ return (100.f*executedLines)/(instrumentedLines);
+ else return 0;
+ }
+
+ public void addChild(TreeElement child){
+ children.add(child);
+ }
+
+ public int getTotalLines() {
+ return totalLines;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFileTreeElement.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFileTreeElement.java
new file mode 100644
index 0000000..5bfa929
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFileTreeElement.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.model;
+
+
+public class CovFileTreeElement extends AbstractTreeElement {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5017234616535899796L;
+
+ public CovFileTreeElement(TreeElement parent,
+ String name, int totalLines, int executedLines, int instrumentedLines) {
+ super(parent, name, totalLines, executedLines, instrumentedLines);
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFolderTreeElement.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFolderTreeElement.java
new file mode 100644
index 0000000..8bfafdf
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFolderTreeElement.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.model;
+
+public class CovFolderTreeElement extends AbstractTreeElement {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 583359546284716138L;
+
+ public CovFolderTreeElement(TreeElement parent,
+ String name, int totalLines, int executedLines, int instrumentedLines) {
+ super(parent, name, totalLines, executedLines, instrumentedLines);
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFunctionTreeElement.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFunctionTreeElement.java
new file mode 100644
index 0000000..3f5e32e
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovFunctionTreeElement.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.model;
+
+import java.util.LinkedList;
+
+
+public class CovFunctionTreeElement extends AbstractTreeElement {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2025221943523670378L;
+ private final String sourceFilePath;
+ private final long firstLnNmbr;
+
+ public CovFunctionTreeElement(TreeElement parent, String name, String sourceFilePath,
+ long firstLnNmbr, int executedLines, int instrumentedLines) {
+ super(parent, name, 0, executedLines, instrumentedLines);
+ this.sourceFilePath = sourceFilePath;
+ this.firstLnNmbr = firstLnNmbr;
+ }
+
+
+ /* no children for functions*/
+
+ public boolean hasChildren() {
+ return false;
+ }
+
+ public LinkedList<? extends TreeElement> getChildren() {
+ return null;
+ }
+
+ public void addChild(TreeElement child){
+ }
+
+
+ /* specific methods for functions*/
+
+ public String getSourceFilePath() {
+ return sourceFilePath;
+ }
+
+ public long getFirstLnNmbr() {
+ return firstLnNmbr;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovRootTreeElement.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovRootTreeElement.java
new file mode 100644
index 0000000..57d879e
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/CovRootTreeElement.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.model;
+
+import java.io.Serializable;
+
+public class CovRootTreeElement extends AbstractTreeElement implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 877070271548608926L;
+
+ public CovRootTreeElement(String name, int totalLines, int executedLines,
+ int instrumentedLines) {
+ super(null, name, totalLines, executedLines, instrumentedLines);
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/TreeElement.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/TreeElement.java
new file mode 100644
index 0000000..d489010
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/model/TreeElement.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.model;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+
+public interface TreeElement extends Serializable{
+ TreeElement getParent();
+ LinkedList<? extends TreeElement> getChildren();
+ boolean hasChildren();
+ TreeElement getRoot();
+
+ String getName();
+ int getExecutedLines();
+ int getInstrumentedLines();
+ int getTotalLines();
+ float getCoveragePercentage();
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Arc.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Arc.java
new file mode 100644
index 0000000..848462b
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Arc.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class Arc implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4104429137191407662L;
+
+ private static final int VCOV_ARC_ON_TREE = (1 << 0);
+ private static final int VCOV_ARC_FAKE = (1 << 1);
+ private static final int VCOV_ARC_FALLTHROUGH = (1 << 2);
+
+ private final Block srcBlock;
+ private final Block dstnatnBlock;
+ private final long flag;
+ private final boolean fake;
+ private final boolean onTree;
+ private final boolean fallthrough;
+
+ private long count = 0;
+ private boolean countValid = false;
+ private boolean isCallNonReturn = false; // Arc is for a function that abnormally returns
+ private boolean isNonLoclaReturn = false; // Arc is for catch/setjump
+ private boolean isUnconditionnal = false; // Is an unconditional branch.
+
+ /**
+ * Constructor
+ */
+ public Arc(int srcBlockIndice, int dstnatnBlockIndice, long flag, List<Block> otherArcParams) {
+ this.flag = flag;
+ this.dstnatnBlock = otherArcParams.get(dstnatnBlockIndice);
+ this.srcBlock = otherArcParams.get(srcBlockIndice);
+ this.count = 0;
+ this.countValid = false;
+ if ((flag & VCOV_ARC_ON_TREE) != 0) {
+ onTree = true;
+ fake = false;
+ fallthrough = false;
+ } else if ((flag & VCOV_ARC_FAKE) != 0) {
+ onTree = false;
+ fake = true;
+ fallthrough = true;
+ } else if ((flag & VCOV_ARC_FALLTHROUGH) != 0) {
+ onTree = false;
+ fake = false;
+ fallthrough = true;
+ } else {
+ onTree = false;
+ fake = false;
+ fallthrough = false;
+ }
+ }
+
+ public Block getDstnatnBlock() {
+ return dstnatnBlock;
+ }
+
+ public long getFlag() {
+ return flag;
+ }
+
+ public boolean isFake() {
+ return fake;
+ }
+
+ public boolean isOnTree() {
+ return onTree;
+ }
+
+ public boolean isFallthrough() {
+ return fallthrough;
+ }
+
+ public boolean isUnconditionnal() {
+ return isUnconditionnal;
+ }
+
+ public boolean isNonLoclaReturn() {
+ return isNonLoclaReturn;
+ }
+
+ public boolean isCallNonReturn() {
+ return isCallNonReturn;
+ }
+
+ public void setCallNonReturn(boolean isCallNonReturn) {
+ this.isCallNonReturn = isCallNonReturn;
+ }
+
+ public void setNonLoclaReturn(boolean isNonLoclaReturn) {
+ this.isNonLoclaReturn = isNonLoclaReturn;
+ }
+
+ public void setUnconditionnal(boolean isUnconditionnal) {
+ this.isUnconditionnal = isUnconditionnal;
+ }
+
+ public Block getSrcBlock() {
+ return srcBlock;
+ }
+
+ public void setCount(long count) {
+ this.count = count;
+ }
+
+ public void setCountValid(boolean countValid) {
+ this.countValid = countValid;
+ }
+
+ public long getCount() {
+ return count;
+ }
+
+ public boolean isCountValid() {
+ return countValid;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Block.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Block.java
new file mode 100644
index 0000000..495ebfe
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Block.java
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class Block implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7665287885679756014L;
+ private final ArrayList<Arc> entryArcs = new ArrayList<Arc>();
+ private final ArrayList<Arc> exitArcs = new ArrayList<Arc>();
+ private final long flag;
+ private long numSuccs = 0;
+ private long numPreds = 0;
+ private long count = 0;
+ private boolean isCallSite = false;// Does the call
+ private boolean isCallReturn = false; // Is the return
+ private boolean isNonLocalReturn = false;
+ private boolean validChain = false;
+ private boolean invalidChain = false;
+ private boolean countValid = false;
+ private final BlkLine blkline = new BlkLine();
+
+ /**
+ * Constructor
+ */
+ public Block(long flag) {
+ this.flag = flag;
+ }
+
+
+ /* getters & setters */
+ public long getFlag() {
+ return flag;
+ }
+
+ public ArrayList<Arc> getEntryArcs() {
+ return entryArcs;
+ }
+
+ public ArrayList<Arc> getExitArcs() {
+ return exitArcs;
+ }
+
+ public boolean isCallSite() {
+ return isCallSite;
+ }
+
+ public boolean isCallReturn() {
+ return isCallReturn;
+ }
+
+ public boolean isNonLocalReturn() {
+ return isNonLocalReturn;
+ }
+
+ public void addEntryArcs(Arc arcEntry) {
+ this.entryArcs.add(arcEntry);
+ }
+
+ public void addExitArcs(Arc arcExit) {
+ this.exitArcs.add(arcExit);
+ }
+
+ public void setCallSite(boolean isCallSite) {
+ this.isCallSite = isCallSite;
+ }
+
+ public void setCallReturn(boolean isCallReturn) {
+ this.isCallReturn = isCallReturn;
+ }
+
+ public void setNonLocalReturn(boolean isNonLocalReturn) {
+ this.isNonLocalReturn = isNonLocalReturn;
+ }
+
+ public void decNumSuccs() {
+ this.numSuccs--;
+ }
+
+ public void decNumPreds() {
+ this.numPreds--;
+ }
+
+ public void incNumPreds() {
+ this.numPreds++;
+ }
+
+ public void incNumSuccs() {
+ this.numSuccs++;
+ }
+
+ public boolean isValidChain() {
+ return validChain;
+ }
+
+ public void setValidChain(boolean validChain) {
+ this.validChain = validChain;
+ }
+
+ public boolean isInvalidChain() {
+ return invalidChain;
+ }
+
+ public void setInvalidChain(boolean invalidChain) {
+ this.invalidChain = invalidChain;
+ }
+
+ public long getCount() {
+ return count;
+ }
+
+ public void setCount(long count) {
+ this.count = count;
+ }
+
+ public void setCountValid(boolean countValid) {
+ this.countValid = countValid;
+ }
+
+ public boolean isCountValid() {
+ return countValid;
+ }
+
+ public long getNumSuccs() {
+ return numSuccs;
+ }
+
+ public long getNumPreds() {
+ return numPreds;
+ }
+
+ public void setNumSuccs(long numSuccs) {
+ this.numSuccs = numSuccs;
+ }
+
+ public void setNumPreds(long numPreds) {
+ this.numPreds = numPreds;
+ }
+
+ public long[] getEncoding() {
+ return blkline.encoding;
+ }
+
+ public void setEncoding(long[] lineNos) {
+ this.blkline.encoding = lineNos;
+ }
+
+ public int getLineNum() {
+ return blkline.num;
+ }
+
+ public void setNumLine(int numline) {
+ this.blkline.num = numline;
+ }
+
+ class BlkLine implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2757557929188979686L;
+ public long[] encoding;
+ public int num;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CovManager.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CovManager.java
new file mode 100644
index 0000000..0379e3c
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CovManager.java
@@ -0,0 +1,372 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.BufferedInputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.model.CovFileTreeElement;
+import org.eclipse.linuxtools.gcov.model.CovFolderTreeElement;
+import org.eclipse.linuxtools.gcov.model.CovFunctionTreeElement;
+import org.eclipse.linuxtools.gcov.model.CovRootTreeElement;
+import org.tizen.common.util.OSChecker;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+
+/**
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ *
+ */
+public class CovManager implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5582066617970911413L;
+ // input
+ private final String binaryPath;
+ // results
+ private final ArrayList<Folder> allFolders = new ArrayList<Folder>();
+ private final ArrayList<SourceFile> allSrcs = new ArrayList<SourceFile>();
+ private final ArrayList<GcnoFunction> allFnctns = new ArrayList<GcnoFunction>();
+ private final HashMap<String, SourceFile> sourceMap = new HashMap<String, SourceFile>();
+ private long nbrPgmRuns = 0;
+ // for view
+ private CovRootTreeElement rootNode;
+
+ /**
+ * Constructor
+ * @param binaryPath
+ */
+ public CovManager(String binaryPath) {
+ this.binaryPath = binaryPath;
+ }
+
+
+ /**
+ * parse coverage files, execute resolve graph algorithm, process counts for functions,
+ * lines and folders.
+ * @param List of coverage files paths
+ * @throws CoreException, IOException, InterruptedException
+ */
+
+ public void processCovFiles(List<String> covFilesPaths) throws CoreException, IOException, InterruptedException {
+ GcdaRecordsParser daRcrd = null;
+ DataInput traceFile;
+ for (String gcdaPath: covFilesPaths) {
+ String gcnoPath = gcdaPath.replace(".gcda", ".gcno");
+ // parse GCNO file
+ traceFile = OpenTraceFileStream(gcnoPath);
+ GcnoRecordsParser noRcrd = new GcnoRecordsParser(sourceMap, allSrcs);
+ noRcrd.parseData(traceFile);
+
+ // add new functions parsed to AllSrcs array
+ for (GcnoFunction f: noRcrd.getFnctns()) {
+ allFnctns.add(f);
+ }
+
+ //close the input stream
+ if(traceFile.getClass() == DataInputStream.class)
+ ((DataInputStream)traceFile).close();
+
+ // parse GCDA file
+ traceFile = OpenTraceFileStream(gcdaPath);
+ if (noRcrd.getFnctns().isEmpty()){
+ String message = gcnoPath + " doesn't contain any function:\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+ daRcrd = new GcdaRecordsParser(noRcrd.getFnctns());
+ daRcrd.parseGcdaRecord(traceFile);
+
+ //close the input stream
+ if(traceFile.getClass() == DataInputStream.class)
+ ((DataInputStream)traceFile).close();
+ }
+
+ // to fill the view title
+ if (daRcrd != null)
+ nbrPgmRuns = daRcrd.getObjSmryNbrPgmRuns();
+ /* process counts from data parsed */
+
+ // solve graph for each function
+ for (GcnoFunction gf : allFnctns) {
+ gf.solveGraphFnctn();
+ }
+
+ // allocate lines
+ for (SourceFile sourceFile: allSrcs) {
+ sourceFile.createLines();
+ }
+
+ // add line counts
+ for (GcnoFunction gf : allFnctns) {
+ gf.addLineCounts(allSrcs);
+ }
+
+ // accumulate lines
+ for (SourceFile sf: allSrcs) {
+ sf.accumulateLineCounts();
+ }
+
+ /* compute counts by folder*/
+
+ // make the folders list
+ for (SourceFile sf : allSrcs) {
+ File srcFile = new File (sf.getName());
+ String folderName = srcFile.getParent();
+ if (folderName == null) folderName = "?";
+ Folder folder = null;
+ for (Folder f: allFolders) {
+ if (f.getPath().equals(folderName))
+ folder = f;
+ }
+ if (folder == null){
+ folder = new Folder(folderName);
+ allFolders.add(folder);
+ }
+ folder.addSrcFiles(sf);
+ }
+
+ // assign sourcesList for each folder
+ for (Folder f : allFolders) {
+ f.accumulateSourcesCounts();
+ }
+ }
+
+
+ /**
+ * fill the model by count results
+ * @throws CoreException, IOException, InterruptedException
+ */
+
+ public void fillGcovView() {
+ // process counts for summary level
+ int summaryTotal = 0, summaryInstrumented = 0, summaryExecuted = 0;
+ for (Folder f : allFolders) {
+ summaryTotal+=f.getNumLines();
+ summaryInstrumented+=f.getLinesInstrumented();
+ summaryExecuted+=f.getLinesExecuted();
+ }
+
+ // fill rootNode model: the entry of the contentProvider
+ rootNode = new CovRootTreeElement("Summary", summaryTotal,summaryExecuted,
+ summaryInstrumented);
+ IBinaryObject binaryObject = STSymbolManager.sharedInstance.getBinaryObject(new Path(binaryPath));
+
+ for (Folder fldr : allFolders) {
+ String folderLocation = fldr.getPath();
+ CovFolderTreeElement fldrTreeElem = new CovFolderTreeElement(
+ rootNode, folderLocation, fldr.getNumLines(), fldr.getLinesExecuted(),
+ fldr.getLinesInstrumented());
+ rootNode.addChild(fldrTreeElem);
+
+ for (SourceFile src : fldr.getSrcFiles()) {
+ CovFileTreeElement srcTreeElem = new CovFileTreeElement(
+ fldrTreeElem, src.getName(), src.getNumLines(), src
+ .getLinesExecuted(), src.getLinesInstrumented());
+ fldrTreeElem.addChild(srcTreeElem);
+
+ for (GcnoFunction fnctn : src.getFnctns()) {
+ String name = fnctn.getName();
+ name = STSymbolManager.sharedInstance.demangle(binaryObject, name);
+ srcTreeElem.addChild(new CovFunctionTreeElement(
+ srcTreeElem, name, fnctn.getSrcFile(), fnctn
+ .getFirstLineNmbr(), fnctn.getCvrge()
+ .getLinesExecuted(), fnctn.getCvrge()
+ .getLinesInstrumented()));
+ }
+ }
+ }
+ }
+
+ // transform String path to stream
+ private DataInput OpenTraceFileStream(String filePath) throws FileNotFoundException{
+
+ FileInputStream fis = new FileInputStream(filePath);
+ InputStream inputStream = new BufferedInputStream(fis);
+
+ return new DataInputStream(inputStream);
+ }
+
+
+ public ArrayList<SourceFile> getAllSrcs() {
+ return allSrcs;
+ }
+
+ public ArrayList<GcnoFunction> getAllFnctns() {
+ return allFnctns;
+ }
+
+ public CovRootTreeElement getRootNode() {
+ return rootNode;
+ }
+
+ public String getBinaryPath() {
+ return binaryPath;
+ }
+
+ public SourceFile getSourceFile(String sourcePath){
+ return sourceMap.get(sourcePath);
+ }
+
+ public long getNbrPgmRuns() {
+ return nbrPgmRuns;
+ }
+
+ /**
+ * Retrieve a list containing gcda paths from a binary file
+ * @return
+ * @throws CoreException
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public List<String> getGCDALocations() throws CoreException, IOException, InterruptedException
+ {
+ IBinaryObject binaryObject = STSymbolManager.sharedInstance.getBinaryObject(new Path(binaryPath));
+ String binaryPath = binaryObject.getPath().toOSString();
+ List<String> l = new LinkedList<String>();
+ String cpu = binaryObject.getCPU();
+ Process p;
+ if ("sh".equals(cpu)) {
+ String stringsTool = "sh4strings";
+ p = getStringsProcess(stringsTool, binaryPath);
+ if ( p == null) p = getStringsProcess("sh4-linux-strings", binaryPath);
+ } else if ("stxp70".equals(cpu)) {
+ String stringsTool = "stxp70v3-strings";
+ p = getStringsProcess(stringsTool, binaryPath);
+ } else if ("st200".equals(cpu)){
+ String stringsTool = cpu + "strings";
+ p = getStringsProcess(stringsTool, binaryPath);
+ } else {
+ String stringsTool;
+ if (OSChecker.isWindows()) {
+ stringsTool = SmartBuildInterface.getMingwBinPath() + "/strings";
+ } else {
+ stringsTool = "strings";
+ }
+ p = getStringsProcess(stringsTool, binaryPath);
+ }
+ if (p == null) {
+ Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
+ "An error occured during analysis: unable to retrieve gcov data", new IOException());
+ Activator.getDefault().getLog().log(status);
+ return l;
+ }
+ ThreadConsumer t = new ThreadConsumer(p, l);
+ t.start();
+ p.waitFor();
+ t.join();
+ return l;
+ }
+
+
+ private Process getStringsProcess(String stringsTool, String binaryPath) {
+ try {
+ Process p = Runtime.getRuntime().exec(new String[] {stringsTool, binaryPath });
+ return p;
+ } catch (Exception _) {
+ return null;
+ }
+ }
+
+
+
+ private final class ThreadConsumer extends Thread
+ {
+ private final Process p;
+ private final List<String> list;
+ ThreadConsumer(Process p, List<String> files)
+ {
+ super();
+ this.p = p;
+ this.list = files;
+ }
+
+ public void run()
+ {
+ try {
+ populateGCDAFiles(p.getInputStream());
+ } catch (Exception _) {
+ }
+ }
+
+ private void populateGCDAFiles(InputStream s) throws IOException
+ {
+ InputStreamReader isr = new InputStreamReader(s);
+ LineNumberReader lnr = new LineNumberReader(isr);
+ String line = null;
+ while ((line =lnr.readLine()) != null) {
+ if (line.endsWith(".gcda"))
+ {
+ // absolute .gcda filepaths retrieved using the "strings" tool may
+ // be prefixed by random printable characters so strip leading
+ // characters until the filepath starts with "X:/", "X:\", "/" or "\"
+ // FIXME: need a more robust mechanism to locate .gcda files [Bugzilla 329710]
+ while ((line.length() > 6) && !line.matches("^([A-Za-z]:)?[/\\\\].*")) {
+ line = line.substring(1);
+ }
+ IPath p = new Path(line);
+ String filename = p.toString();
+ if (!list.contains(filename)) list.add(filename);
+ }
+ }
+ }
+ }
+
+ public void dumpProcessCovFilesResult(PrintStream ps) throws FileNotFoundException {
+ ps.println("Parse gcda and gcno files done, resolve graph algorithm executed, now display results");
+ ps.println("- PRINT FUNCTIONS ARRAY : ");
+ for (int i = 0; i < allFnctns.size(); i++) {
+ ps.println("-- FUNCTION " +i);
+ ps.println(" name = " + allFnctns.get(i).getName());
+ ps.println(" instrumentd lines = " + allFnctns.get(i).getCvrge().getLinesInstrumented());
+ ps.println(" executed lines = "+ allFnctns.get(i).getCvrge().getLinesExecuted());
+ }
+ ps.println("- PRINT SRCS ARRAY : ");
+ for (int i = 0; i < allSrcs.size(); i++) {
+ ps.println("-- FILE " + i);
+ ps.println(" name = " + allSrcs.get(i).getName());
+ ps.println(" total lines = " + allSrcs.get(i).getNumLines());
+ ps.println(" instrumentd lines = "+ allSrcs.get(i).getLinesInstrumented());
+ ps.println(" executed lines = "+ allSrcs.get(i).getLinesExecuted());
+ }
+ }
+
+
+ /**
+ * @return the sourceMap
+ */
+ public HashMap<String, SourceFile> getSourceMap() {
+ return sourceMap;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CoverageInfo.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CoverageInfo.java
new file mode 100644
index 0000000..1595635
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/CoverageInfo.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.Serializable;
+
+public class CoverageInfo implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6067335353999481231L;
+
+ private int linesInstrumented = 0;
+ private int linesExecuted = 0;
+
+ /**
+ * Constructor
+ */
+ public CoverageInfo() {
+
+ }
+
+
+ /*getters & setters */
+
+ public int getLinesInstrumented() {
+ return linesInstrumented;
+ }
+
+ public int getLinesExecuted() {
+ return linesExecuted;
+ }
+
+ public void incLinesInstrumented(){
+ this.linesInstrumented++;
+ }
+
+ public void incLinesExecuted(){
+ this.linesExecuted++;
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Folder.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Folder.java
new file mode 100644
index 0000000..482ae81
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Folder.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class Folder implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5155033391199109661L;
+ private final String path;
+ private final ArrayList<SourceFile> srcFiles = new ArrayList<SourceFile>();
+ private int numLines = 0;
+ private int linesInstrumented = 0;
+ private int linesExecuted = 0;
+
+ /**
+ * Constructor
+ */
+ public Folder(String path) {
+ this.path = path;
+ }
+
+
+ public void accumulateSourcesCounts(){
+ for (int i = 0; i < srcFiles.size(); i++) {
+ numLines += (srcFiles.get(i)).getNumLines();
+ linesInstrumented += (srcFiles.get(i)).getLinesInstrumented();
+ linesExecuted += (srcFiles.get(i)).getLinesExecuted();
+ }
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public ArrayList<SourceFile> getSrcFiles() {
+ return srcFiles;
+ }
+
+ public void addSrcFiles(SourceFile srcFile) {
+ this.srcFiles.add(srcFile);
+ }
+
+ public int getNumLines() {
+ return numLines;
+ }
+ public int getLinesExecuted() {
+ return linesExecuted;
+ }
+ public int getLinesInstrumented() {
+ return linesInstrumented;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcdaRecordsParser.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcdaRecordsParser.java
new file mode 100644
index 0000000..a82d724
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcdaRecordsParser.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.utils.BEDataInputStream;
+import org.eclipse.linuxtools.gcov.utils.LEDataInputStream;
+import org.eclipse.linuxtools.gcov.utils.MasksGenerator;
+
+
+
+public class GcdaRecordsParser {
+
+
+ private static final int GCOV_DATA_MAGIC = 0x67636461; // en ASCII: 67=g 63=c 64=d 61=a
+ private static final int GCOV_TAG_FUNCTION = 0x01000000;
+ private static final int GCOV_COUNTER_ARCS = 0x01a10000;
+ private static final int GCOV_TAG_OBJECT_SYMMARY = 0xa1000000;
+ private static final int GCOV_TAG_PROGRAM_SUMMARY = 0xa3000000;
+
+ private final ArrayList<GcnoFunction> fnctns;
+ private long objSmryNbrPgmRuns = 0;
+ private long pgmSmryChksm = 0;
+ private long objSmryChksm = 0;
+ private long objSmryArcCnts = 0;
+ private long objSmrytotalCnts = 0;
+ private long objSmryRunMax = 0;
+ private long objSmrySumMax = 0;
+
+
+ public GcdaRecordsParser(ArrayList<GcnoFunction> fnctns) {
+ this.fnctns = fnctns;
+ }
+
+ public void parseGcdaRecord(DataInput stream) throws IOException, CoreException {
+ // header data
+ int magic = 0;
+
+ // data & flags to process tests
+ GcnoFunction currentFnctn = null;
+
+ //read magic
+ magic = stream.readInt();
+ //read version
+ //version = stream.readInt();
+ stream.readInt();
+ //read stamp
+ //stamp = stream.readInt();
+ stream.readInt();
+
+ if (magic == GCOV_DATA_MAGIC){
+ stream = new BEDataInputStream((DataInputStream) stream);
+ }else{
+ magic = (magic >> 16) | (magic << 16);
+ magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
+ if (magic == GCOV_DATA_MAGIC){
+ stream = new LEDataInputStream((DataInputStream) stream);
+ }else{
+ String message = magic + " :desn't correspond to a correct data file header\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+ }
+
+ while (true) {
+ try {
+ // parse header
+ int tag = stream.readInt();
+ long length = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ // parse gcda data
+ switch ((int) tag) {
+ case GCOV_TAG_FUNCTION: {
+ long fnctnId = stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK;
+ if (!fnctns.isEmpty()) {
+ boolean fnctnFound = false;
+ for (GcnoFunction f: fnctns) {
+ if (f.getIdent() == fnctnId) {
+ fnctnFound = true;
+ currentFnctn = f;
+ long fnctnChksm = stream.readInt()& MasksGenerator.UNSIGNED_INT_MASK;
+ if (f.getCheksum() != fnctnChksm){
+ String message = "Checksums don't correspond for " +
+ currentFnctn.getName() + " (Id: " + fnctnId + ")\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+ break;
+ }
+ }
+
+ if (fnctnFound == false){
+ currentFnctn = null;
+ String message = "Function with Id: " + fnctnId +
+ " not found in function list\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ }
+ break;
+ }
+
+ case GCOV_COUNTER_ARCS: {
+ if (currentFnctn == null){
+ String message = "Missing function or duplicate counter tag\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ if (length != 2 * (currentFnctn.getNumCounts())){
+ String message = "GCDA content is inconsistent\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ ArrayList<Block> fnctnBlcks = currentFnctn.getFunctionBlocks();
+ if (fnctnBlcks.isEmpty()){
+ String message = "Function block list is empty\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+
+ for (int i = 0; i < fnctnBlcks.size(); i++) {
+ Block b = fnctnBlcks.get(i);
+ int nonFakeExit = 0;
+
+ ArrayList<Arc> arcsExit = b.getExitArcs();
+ for (Arc extArc: arcsExit) {
+ if (extArc.isFake() == false)
+ nonFakeExit++;
+ if (extArc.isOnTree() == false) {
+ long arcsCnts = stream.readLong();
+ extArc.setCount(arcsCnts);
+ extArc.setCountValid(true);
+ b.decNumSuccs();
+ extArc.getDstnatnBlock().decNumPreds();
+ }
+ }
+
+ // If there is only one non-fake exit, it is an
+ // unconditional branch.
+ if (nonFakeExit == 1) {
+ for (Arc extArc: arcsExit) {
+ if (extArc.isFake() == false) {
+ extArc.setUnconditionnal(true);
+
+ // If this block is instrumenting a call, it might be
+ // an artificial block. It is not artificial if it has
+ // a non-fallthrough exit, or the destination of this
+ // arc has more than one entry. Mark the destination
+ // block as a return site, if none of those conditions hold.
+
+ if (b.isCallSite() == true
+ && extArc.isFallthrough() == true
+ && extArc.getDstnatnBlock()
+ .getEntryArcs().get(0)
+ .equals(extArc)
+ && extArc.getDstnatnBlock()
+ .getEntryArcs().size() == 1)
+ extArc.getDstnatnBlock()
+ .setCallReturn(true);
+ }
+ }
+ }
+ }
+
+ // counters arcs process data reset
+ currentFnctn = null;
+ break;
+ }
+
+ case GCOV_TAG_OBJECT_SYMMARY: {
+ objSmryChksm = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ objSmryArcCnts = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ objSmryNbrPgmRuns = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ objSmrytotalCnts = stream.readLong();
+ objSmryRunMax = stream.readLong();
+ objSmrySumMax = stream.readLong();
+ break;
+ }
+
+ // program summary tag
+ case GCOV_TAG_PROGRAM_SUMMARY: {
+ //long[] pgmSmryskips = new long[(int) length];
+ pgmSmryChksm = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ for (int i = 0; i < length - 1; i++) {
+ //pgmSmryskips[i] = (stream.readInt() & MasksGenerator.UNSIGNED_INT_MASK);
+ stream.readInt();
+ }
+ break;
+ }
+
+ default: {
+ //System.out.println("wrong gcda tag");
+ break;
+ }
+ }
+ }
+ catch (EOFException _) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * @return the objSmryNbrPgmRuns
+ */
+ public long getObjSmryNbrPgmRuns() {
+ return objSmryNbrPgmRuns;
+ }
+
+ /**
+ * @return the objSmryChksm
+ */
+ public long getObjSmryChksm() {
+ return objSmryChksm;
+ }
+
+ /**
+ * @return the objSmryArcCnts
+ */
+ public long getObjSmryArcCnts() {
+ return objSmryArcCnts;
+ }
+
+ /**
+ * @return the objSmrytotalCnts
+ */
+ public long getObjSmrytotalCnts() {
+ return objSmrytotalCnts;
+ }
+
+ /**
+ * @return the objSmryRunMax
+ */
+ public long getObjSmryRunMax() {
+ return objSmryRunMax;
+ }
+
+ /**
+ * @return the objSmrySumMax
+ */
+ public long getObjSmrySumMax() {
+ return objSmrySumMax;
+ }
+
+ /**
+ * @return the pgmSmryChksm
+ */
+ public long getPgmSmryChksm() {
+ return pgmSmryChksm;
+ }
+
+
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoFunction.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoFunction.java
new file mode 100644
index 0000000..2549883
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoFunction.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class GcnoFunction implements Serializable, Comparable<GcnoFunction> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4159055012321132651L;
+
+ private final long ident;
+ private final long cheksum;
+ private final long firstLineNmbr;
+ private final String name;
+ private final String srcFile;
+ private ArrayList<Block> functionBlocks = new ArrayList<Block>();
+ private int numCounts = 0, blocksExecuted = 0, numBlocks = 0;;
+ private final CoverageInfo cvrge = new CoverageInfo();
+
+ public GcnoFunction(long fnctnIdent, long fnctnChksm, String fnctnName, String fnctnSrcFle, long fnctnFrstLnNmbr) {
+ this.ident = fnctnIdent;
+ this.cheksum = fnctnChksm;
+ this.name = fnctnName;
+ this.srcFile = fnctnSrcFle;
+ this.firstLineNmbr = fnctnFrstLnNmbr;
+ }
+
+ @Override
+ public int compareTo(GcnoFunction o) {
+ if (getFirstLineNmbr()>o.getFirstLineNmbr()) return 1;
+ else if (getFirstLineNmbr()<o.getFirstLineNmbr()) return -1;
+ return 0;
+ }
+
+
+ public void addLineCounts(ArrayList<SourceFile> srcs) {
+ for (int i = 0; i != numBlocks; i++) {
+ Block blk = functionBlocks.get(i);
+ SourceFile fileSrc = null;
+ if ((blk.getCount() != 0) && (i != 0) && (i + 1 != numBlocks))
+ blocksExecuted++;
+
+ long[] enc = blk.getEncoding();
+ for (int j = 0, k = 0; j != blk.getLineNum(); j++, k++) {
+ if (enc[k] == 0) {
+ int srcn = (int) enc[++k];
+ for (SourceFile sf : srcs) {
+ if (sf.getIndex() == srcn) {
+ fileSrc = sf;
+ break;
+ }
+ }
+ j++;
+ } else if ((fileSrc != null) && enc[k] < fileSrc.getLines().size()) {
+ Line line = fileSrc.getLines().get((int) enc[k]);
+ if (line.isExists() == false)
+ cvrge.incLinesInstrumented();
+ if ((line.getCount() == 0) && (blk.getCount() != 0))
+ cvrge.incLinesExecuted();
+ line.setExists(true);
+ line.setCount(line.getCount()+ blk.getCount());
+ }
+ }
+ }
+ }
+
+ public void solveGraphFnctn() {
+ ArrayList<Block> fnctnBlcks = this.functionBlocks;
+ ArrayList<Block> validBlocks = new ArrayList<Block>();
+ ArrayList<Block> invalidBlocks = new ArrayList<Block>();
+
+
+ // Function should contain at least one block
+ if (fnctnBlcks.size() >= 2){
+ if (fnctnBlcks.get(0).getNumPreds() == 0)
+ fnctnBlcks.get(0).setNumPreds(50000);
+ if (fnctnBlcks.get(fnctnBlcks.size() - 1).getNumSuccs() == 0)
+ fnctnBlcks.get(fnctnBlcks.size() - 1).setNumSuccs(50000);
+ }
+
+
+ for (int i = 0; i < fnctnBlcks.size(); i++) {
+ Block b = fnctnBlcks.get(i);
+ b.setInvalidChain(true);
+ invalidBlocks.add(b);
+ }
+
+ while (validBlocks.isEmpty() == false
+ || invalidBlocks.isEmpty() == false) {
+
+ if (invalidBlocks.isEmpty() == false) {
+ for (int i = invalidBlocks.size() - 1; i >= 0; i--) {
+ Block invb = invalidBlocks.get(i);
+ long total = 0;
+ invalidBlocks.remove(i);
+ invb.setInvalidChain(false);
+
+ if (invb.getNumSuccs() == 0) {
+ ArrayList<Arc> extArcs = invb.getExitArcs();
+ for (Arc arc : extArcs)
+ total += arc.getCount();
+ } else if (invb.getNumPreds() == 0) {
+ ArrayList<Arc> entrArcs = invb.getEntryArcs();
+ for (Arc arc : entrArcs)
+ total += arc.getCount();
+ } else
+ continue;
+
+ invb.setCount(total);
+ invb.setCountValid(true);
+ invb.setValidChain(true);
+ validBlocks.add(invb);
+ }
+ }/*else
+ System.out.println("NO, invalid blocks = 0");
+ */
+ while (validBlocks.isEmpty() == false) {
+ int last = validBlocks.size() - 1;
+ Block vb = validBlocks.get(last);
+ Arc invarc = null;
+ int total = 0;
+ validBlocks.remove(last);
+
+ vb.setValidChain(false);
+
+ if (vb.getNumSuccs() == 1) {
+ Block blcksdst;
+ total = (int) vb.getCount();
+
+ for (Arc extAr : vb.getExitArcs()) {
+ total -= extAr.getCount();
+ if (extAr.isCountValid() == false)
+ invarc = extAr;
+ }
+ blcksdst = invarc.getDstnatnBlock();
+ invarc.setCountValid(true);
+ invarc.setCount(total);
+ vb.decNumSuccs();
+ blcksdst.decNumPreds();
+
+ if (blcksdst.isCountValid() == true) {
+ if (blcksdst.getNumPreds() == 1
+ && blcksdst.isValidChain() == false) {
+ blcksdst.setValidChain(true);
+ validBlocks.add(blcksdst);
+ }
+ } else {
+ if (blcksdst.getNumPreds() == 0
+ && blcksdst.isInvalidChain() == false) {
+ blcksdst.setInvalidChain(true);
+ invalidBlocks.add(blcksdst);
+ }
+ }
+ }
+
+ if (vb.getNumPreds() == 1) {
+ Block blcksrc;
+ total = (int) vb.getCount();
+ invarc = null;
+
+ for (Arc entrAr: vb.getEntryArcs()) {
+ total -= entrAr.getCount();
+ if (entrAr.isCountValid() == false)
+ invarc = entrAr;
+ }
+
+ blcksrc = invarc.getSrcBlock();
+ invarc.setCountValid(true);
+ invarc.setCount(total);
+ vb.decNumPreds();
+ blcksrc.decNumSuccs();
+
+ if (blcksrc.isCountValid() == true) {
+ if (blcksrc.getNumSuccs() == 1
+ && blcksrc.isInvalidChain() == false) {
+ blcksrc.setValidChain(true);
+ validBlocks.add(blcksrc);
+ }
+ } else if (blcksrc.getNumSuccs() == 0
+ && blcksrc.isInvalidChain() == false) {
+ blcksrc.setInvalidChain(true);
+ invalidBlocks.add(blcksrc);
+ }
+ }
+ }
+ }
+ }
+
+ /* getters & setters */
+
+ public long getIdent() {
+ return ident;
+ }
+
+ public long getCheksum() {
+ return cheksum;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSrcFile() {
+ return srcFile;
+ }
+
+ public long getFirstLineNmbr() {
+ return firstLineNmbr;
+ }
+
+ public ArrayList<Block> getFunctionBlocks() {
+ return functionBlocks;
+ }
+
+ public Block getFunctionBlock(int i) {
+ return functionBlocks.get(i);
+ }
+
+ public void setFunctionBlocks(ArrayList<Block> functionBlocks) {
+ this.functionBlocks = functionBlocks;
+ }
+
+ public void incNumCounts() {
+ this.numCounts++;
+ }
+
+ public int getNumCounts() {
+ return numCounts;
+ }
+
+ public int getNumBlocks() {
+ return numBlocks;
+ }
+
+ public void setNumBlocks(int numBlocks) {
+ this.numBlocks = numBlocks;
+ }
+
+ public CoverageInfo getCvrge() {
+ return cvrge;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoRecordsParser.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoRecordsParser.java
new file mode 100644
index 0000000..c21e16f
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/GcnoRecordsParser.java
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.utils.BEDataInputStream;
+import org.eclipse.linuxtools.gcov.utils.GcovStringReader;
+import org.eclipse.linuxtools.gcov.utils.LEDataInputStream;
+import org.eclipse.linuxtools.gcov.utils.MasksGenerator;
+
+
+public class GcnoRecordsParser {
+
+ private static final int GCOV_NOTE_MAGIC = 0x67636e6f; // en ASCII: 67=g 63=c 6e=n 6f=o
+ private static final int GCOV_TAG_FUNCTION = 0x01000000;
+ private static final int GCOV_TAG_BLOCKS = 0x01410000;
+ private static final int GCOV_TAG_ARCS = 0x01430000;
+ private static final int GCOV_TAG_LINES = 0x01450000;
+
+ private GcnoFunction fnctn = null;
+ private final ArrayList<GcnoFunction> fnctns = new ArrayList<GcnoFunction>();
+ private final ArrayList<SourceFile> currentAllSrcs;
+ private final HashMap<String, SourceFile> sourceMap;
+
+ public GcnoRecordsParser(HashMap<String, SourceFile> sourceMap, ArrayList<SourceFile> AllSrcs){
+ this.sourceMap = sourceMap;
+ this.currentAllSrcs = AllSrcs;
+ }
+
+ private SourceFile findOrAdd (String fileName, ArrayList<SourceFile> srcs)
+ {
+ SourceFile newsrc = sourceMap.get(fileName);
+ if (newsrc == null) {
+ newsrc = new SourceFile(fileName, srcs.size()+1);
+ srcs.add(newsrc);
+ sourceMap.put(fileName, newsrc);
+ }
+ return newsrc; //return the new added element
+ }
+
+
+ public void parseData(DataInput stream) throws IOException, CoreException{
+ // header data
+ int magic = 0;
+ // blocks data
+ ArrayList<Block> blocks = null;
+ // source file data
+ SourceFile source = null;
+ // flag
+ boolean parseFirstFnctn = false;
+
+ magic = stream.readInt();
+ //version = stream.readInt();
+ stream.readInt();
+ //stamp = stream.readInt();
+ stream.readInt();
+
+ if (magic == GCOV_NOTE_MAGIC){
+ stream = new BEDataInputStream((DataInputStream) stream);
+ }else{
+ magic = (magic >> 16) | (magic << 16);
+ magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
+ if (magic == GCOV_NOTE_MAGIC){
+ stream = new LEDataInputStream((DataInputStream) stream);
+ }else{
+ String message = magic + " :desn't correspond to a correct note file header\n";
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ throw new CoreException(status);
+ }
+ }
+
+ /*------------------------------------------------------------------------------
+ System.out.println("Gcno LE, Magic "+magic+" version "+version+" stamp "+stamp);
+ */
+
+ while (true){
+ try{
+ int tag;
+ // parse header
+ while (true){
+ tag=stream.readInt();
+ if (tag == GCOV_TAG_FUNCTION || tag == GCOV_TAG_BLOCKS ||
+ tag == GCOV_TAG_ARCS || tag == GCOV_TAG_LINES)
+ break;
+ }
+ int length=stream.readInt();
+
+ // parse gcno data
+ if ((int)tag == GCOV_TAG_FUNCTION){
+ // before parse new function, add current function to functions list
+ if (parseFirstFnctn == true) fnctns.add(fnctn);
+
+ long fnctnIdent = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+ long fnctnChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+ String fnctnName = GcovStringReader.readString(stream);
+ String fnctnSrcFle = GcovStringReader.readString(stream);
+ long fnctnFrstLnNmbr= (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+
+ fnctn = new GcnoFunction(fnctnIdent, fnctnChksm, fnctnName, fnctnSrcFle, fnctnFrstLnNmbr);
+ SourceFile srcFle2 = findOrAdd (fnctn.getSrcFile(),currentAllSrcs);
+ if (fnctn.getFirstLineNmbr() >= srcFle2.getNumLines()){
+ srcFle2.setNumLines((int)fnctn.getFirstLineNmbr()+1);
+ }
+ srcFle2.addFnctn(fnctn);
+ parseFirstFnctn = true;
+ continue;
+ }
+
+ else if ((int)tag == GCOV_TAG_BLOCKS){
+ blocks = new ArrayList<Block>();
+ for (int i = 0; i < length; i++) {
+ long BlckFlag = stream.readInt()& MasksGenerator.UNSIGNED_INT_MASK;
+ Block blck = new Block(BlckFlag);
+ blocks.add(blck);
+ }
+ fnctn.setNumBlocks(length);
+ continue;
+ }
+ else if (tag == GCOV_TAG_ARCS){
+ int srcBlockIndice = stream.readInt();
+ int nmbrArcs = (length-1)/2;
+ ArrayList<Arc> arcs = new ArrayList<Arc>(nmbrArcs);
+
+ for (int i = 0; i < nmbrArcs; i++) {
+ int dstnatnBlockIndice = stream.readInt();
+ long flag = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+ Arc arc = new Arc(srcBlockIndice, dstnatnBlockIndice, flag, blocks);
+ arcs.add(arc);
+ }
+
+ // each arc, register it as exit of the src block
+ Block srcBlk = blocks.get(srcBlockIndice);
+ for (Arc a : arcs) {
+ srcBlk.addExitArcs(a);
+ srcBlk.incNumSuccs();
+ }
+
+ // each arc, register it as entry of its dstntn block
+ for (Arc a : arcs) {
+ Block dstntnBlk = a.getDstnatnBlock();
+ dstntnBlk.addEntryArcs(a);
+ dstntnBlk.incNumPreds();
+ }
+
+ for (Arc a : arcs) {
+ if (a.isFake() == true) {
+ if (a.getSrcBlock() != null ) {
+ // Exceptional exit from this function, the
+ // source block must be a call.
+ srcBlk = blocks.get((int)srcBlockIndice);
+ srcBlk.setCallSite(true);
+ a.setCallNonReturn(true);
+ } else {
+ a.setNonLoclaReturn(true);
+ Block dstntnBlk = a.getDstnatnBlock();
+ dstntnBlk.setNonLocalReturn(true);
+ }
+ }
+
+ if (a.isOnTree() == false)
+ fnctn.incNumCounts();
+ //nbrCounts++;
+ }
+
+ fnctn.setFunctionBlocks(blocks);
+ continue;
+ }
+
+
+ else if (tag == GCOV_TAG_LINES) {
+ int numBlock = stream.readInt();
+ long[] lineNos = new long[length-1];
+ int ix = 0;
+ do {
+ long lineNumber = stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK;
+ if (lineNumber != 0){
+ if (ix == 0){
+ lineNos[ix++] = 0;
+ lineNos[ix++] = source.getIndex();
+ }
+ lineNos[ix++]=lineNumber;
+ if (lineNumber >= source.getNumLines()){
+ source.setNumLines((int)lineNumber+1);
+ }
+ } else {
+ String fileName = GcovStringReader.readString(stream);
+ if (fileName == "NULL string")
+ break;
+
+ source = findOrAdd (fileName, currentAllSrcs);
+ lineNos[ix++]=0;
+ lineNos[ix++]=source.getIndex();
+ }
+ } while (true);
+
+ fnctn.getFunctionBlocks().get(((int)numBlock))
+ .setEncoding(lineNos);
+
+ fnctn.getFunctionBlocks().get(((int)numBlock))
+ .setNumLine(ix);
+
+ continue;
+ }
+ }
+ catch (EOFException e) {
+
+ fnctn.setFunctionBlocks(blocks);
+ fnctns.add(fnctn);
+
+ break;
+
+ }
+ }//while
+ }
+
+ /* Getters */
+ public ArrayList<GcnoFunction> getFnctns() {
+ return fnctns;
+ }
+
+ public ArrayList<SourceFile> getcurrentAllSrcs() {
+ return currentAllSrcs;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Line.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Line.java
new file mode 100644
index 0000000..e2b0c4a
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/Line.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.Serializable;
+
+
+public class Line implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8804878976767948267L;
+ private boolean exists = false;
+ private long count = 0;
+
+ /**
+ * Constructor
+ */
+ public Line() {
+ }
+
+
+ /*Getters & setters*/
+
+ public boolean isExists() {
+ return exists;
+ }
+
+ public void setExists(boolean exists) {
+ this.exists = exists;
+ }
+
+ public void setCount(long count) {
+ this.count = count;
+ }
+
+ public long getCount() {
+ return count;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/SourceFile.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/SourceFile.java
new file mode 100644
index 0000000..3ba9d68
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/parser/SourceFile.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.parser;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+public class SourceFile implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -9182882194956475711L;
+ private final String name;
+ private final int index;
+ private final ArrayList<Line> lines = new ArrayList<Line>();
+ private final TreeSet<GcnoFunction> fnctns = new TreeSet<GcnoFunction>();
+ private int numLines = 1;
+ private final CoverageInfo cvrge = new CoverageInfo();
+ private long maxCount = -1;
+
+ /**
+ * Constructor
+ */
+ public SourceFile(String name, int index) {
+ this.name = name;
+ this.index = index;
+ }
+
+
+ public void accumulateLineCounts() {
+ for (Line line : lines) {
+ if (line.isExists()) {
+ cvrge.incLinesInstrumented();
+ if (line.getCount() != 0)
+ cvrge.incLinesExecuted();
+ }
+ }
+ }
+
+ public long getmaxLineCount() {
+ if (maxCount < 0) {
+ for (Line line : lines) {
+ if (line.getCount() > maxCount)
+ maxCount = line.getCount();
+ }
+ }
+ return maxCount;
+ }
+
+ /* getters & setters */
+
+
+
+ public int getLinesExecuted() {
+ return cvrge.getLinesExecuted();
+ }
+
+ public int getLinesInstrumented() {
+ return cvrge.getLinesInstrumented();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ArrayList<Line> getLines() {
+ return lines;
+ }
+
+ public SortedSet<GcnoFunction> getFnctns() {
+ return fnctns;
+ }
+
+ public void addFnctn(GcnoFunction fnctn) {
+ this.fnctns.add(fnctn);
+ }
+
+ public int getNumLines() {
+ return numLines;
+ }
+
+ public void setNumLines(int numLines) {
+ this.numLines = numLines;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void createLines() {
+ int n = getNumLines();
+ lines.ensureCapacity(n);
+ for (int j = 0; j<n ; j++) {
+ lines.add(new Line());
+ }
+ }
+
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/BEDataInputStream.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/BEDataInputStream.java
new file mode 100644
index 0000000..9765c94
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/BEDataInputStream.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.utils;
+
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.IOException;
+/**
+ *
+ */
+public class BEDataInputStream implements DataInput {
+
+ private final DataInputStream in;
+ private final byte[] buffer = new byte[8];
+
+ /**
+ * Constructor
+ * @param in
+ */
+ public BEDataInputStream(DataInputStream in) {
+ this.in = in;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readShort()
+ */
+ public final short readShort() throws IOException
+ {
+ return in.readShort();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUnsignedShort()
+ */
+ public final int readUnsignedShort() throws IOException
+ {
+ return in.readUnsignedShort();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readChar()
+ */
+ public final char readChar() throws IOException
+ {
+ return in.readChar();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readInt()
+ */
+ public final int readInt() throws IOException
+ {
+ return in.readInt();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readLong()
+ */
+ public final long readLong() throws IOException
+ {
+ in.readFully(buffer, 0, 8);
+ return (((long)buffer[7] << 32) +
+ ((long)(buffer[6] & 255) << 40) +
+ ((long)(buffer[5] & 255) << 48) +
+ ((long)(buffer[4] & 255) << 56) +
+ ((long)(buffer[3] & 255) << 0) +
+ ((buffer[2] & 255) << 8) +
+ ((buffer[1] & 255) << 16) +
+ ((buffer[0] & 255) << 24));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFloat()
+ */
+ public final float readFloat() throws IOException
+ {
+ return Float.intBitsToFloat(readInt());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readDouble()
+ */
+ public final double readDouble() throws IOException
+ {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readBoolean()
+ */
+ public boolean readBoolean() throws IOException {
+ return in.readBoolean();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readByte()
+ */
+ public byte readByte() throws IOException {
+ return in.readByte();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFully(byte[])
+ */
+ public void readFully(byte[] b) throws IOException {
+ in.readFully(b);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFully(byte[], int, int)
+ */
+ public void readFully(byte[] b, int off, int len) throws IOException {
+ in.readFully(b,off,len);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readLine()
+ */
+ @Deprecated
+ public String readLine() throws IOException {
+ return in.readLine();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUTF()
+ */
+ public String readUTF() throws IOException {
+ return in.readUTF();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUnsignedByte()
+ */
+ public int readUnsignedByte() throws IOException {
+ return in.readUnsignedByte();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#skipBytes(int)
+ */
+ public int skipBytes(int n) throws IOException {
+ return in.skipBytes(n);
+ }
+
+ /**
+ * Close this stream.
+ */
+ public void close() throws IOException {
+ in.close();
+ }
+
+ public final long readUnsignedInt() throws IOException
+ {
+ in.readFully(buffer, 0, 4);
+ return
+ ((
+ (buffer[0]) << 24 |
+ (buffer[1]&0xff) << 16 |
+ (buffer[2]&0xff) << 8 |
+ (buffer[3]&0xff)
+ )
+ & MasksGenerator.UNSIGNED_INT_MASK );
+ }
+
+
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/GcovStringReader.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/GcovStringReader.java
new file mode 100644
index 0000000..e6b13a6
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/GcovStringReader.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.utils;
+
+import java.io.DataInput;
+import java.io.IOException;
+
+public class GcovStringReader {
+
+
+ public static String readString(DataInput stream) throws IOException {
+ String res = "NULL string";
+ long length = stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK;
+ if (length != 0) {
+ int ln = ((int) length) << 2;
+ byte[] name = new byte[ln];
+ stream.readFully(name);
+ StringBuffer sb = new StringBuffer();
+ for(int j=0; j < ln; j++){
+ if(name[j]!=0){
+ char c = (char) name[j];
+ sb.append(c);
+ }
+ }
+ res = sb.toString();
+ }
+ return res;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/LEDataInputStream.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/LEDataInputStream.java
new file mode 100644
index 0000000..51648e5
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/LEDataInputStream.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.utils;
+
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.IOException;
+/**
+ * Little-endian implementation of DataInputStream
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ *
+ */
+public class LEDataInputStream implements DataInput {
+
+ private final DataInputStream in;
+ private final byte[] buffer = new byte[8];
+
+ /**
+ * Constructor
+ * @param in
+ */
+ public LEDataInputStream(DataInputStream in) {
+ this.in = in;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readShort()
+ */
+ public final short readShort() throws IOException
+ {
+ in.readFully(buffer, 0, 2);
+ return (short)(
+ (buffer[1]&0xff) << 8 |
+ (buffer[0]&0xff));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUnsignedShort()
+ */
+ public final int readUnsignedShort() throws IOException
+ {
+ in.readFully(buffer, 0, 2);
+ return (
+ (buffer[1]&0xff) << 8 |
+ (buffer[0]&0xff));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readChar()
+ */
+ public final char readChar() throws IOException
+ {
+ in.readFully(buffer, 0, 2);
+ return (char) (
+ (buffer[1]&0xff) << 8 |
+ (buffer[0]&0xff));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readInt()
+ */
+ public final int readInt() throws IOException
+ {
+ in.readFully(buffer, 0, 4);
+ return
+ (buffer[3]) << 24 |
+ (buffer[2]&0xff) << 16 |
+ (buffer[1]&0xff) << 8 |
+ (buffer[0]&0xff);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readLong()
+ */
+ public final long readLong() throws IOException
+ {
+ in.readFully(buffer, 0, 8);
+ return
+ (long)(buffer[7]) << 56 | /* long cast needed or shift done modulo 32 */
+ (long)(buffer[6]&0xff) << 48 |
+ (long)(buffer[5]&0xff) << 40 |
+ (long)(buffer[4]&0xff) << 32 |
+ (long)(buffer[3]&0xff) << 24 |
+ (long)(buffer[2]&0xff) << 16 |
+ (long)(buffer[1]&0xff) << 8 |
+ (long)(buffer[0]&0xff);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFloat()
+ */
+ public final float readFloat() throws IOException
+ {
+ return Float.intBitsToFloat(readInt());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readDouble()
+ */
+ public final double readDouble() throws IOException
+ {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readBoolean()
+ */
+ public boolean readBoolean() throws IOException {
+ return in.readBoolean();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readByte()
+ */
+ public byte readByte() throws IOException {
+ return in.readByte();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFully(byte[])
+ */
+ public void readFully(byte[] b) throws IOException {
+ in.readFully(b);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readFully(byte[], int, int)
+ */
+ public void readFully(byte[] b, int off, int len) throws IOException {
+ in.readFully(b,off,len);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readLine()
+ */
+ @Deprecated
+ public String readLine() throws IOException {
+ return in.readLine();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUTF()
+ */
+ public String readUTF() throws IOException {
+ return in.readUTF();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#readUnsignedByte()
+ */
+ public int readUnsignedByte() throws IOException {
+ return in.readUnsignedByte();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.DataInput#skipBytes(int)
+ */
+ public int skipBytes(int n) throws IOException {
+ return in.skipBytes(n);
+ }
+
+ /**
+ * Close this stream.
+ */
+ public void close() throws IOException {
+ in.close();
+ }
+
+ public final long readUnsignedInt() throws IOException
+ {
+ in.readFully(buffer, 0, 4);
+ return
+ ((
+ (buffer[3]) << 24 |
+ (buffer[2]&0xff) << 16 |
+ (buffer[1]&0xff) << 8 |
+ (buffer[0]&0xff)
+ )
+ & MasksGenerator.UNSIGNED_INT_MASK );
+ }
+
+
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/MasksGenerator.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/MasksGenerator.java
new file mode 100644
index 0000000..4b8adf5
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/MasksGenerator.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.utils;
+
+public class MasksGenerator {
+ public static final long UNSIGNED_INT_MASK = 0xffffffffL;
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java
new file mode 100644
index 0000000..c47cf07
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/utils/STGcovProgramChecker.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.WeakHashMap;
+
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.binutils.utils.STNMFactory;
+import org.eclipse.linuxtools.binutils.utils.STNMSymbolsHandler;
+import org.eclipse.linuxtools.binutils.utils.STSymbolManager;
+
+public class STGcovProgramChecker implements STNMSymbolsHandler {
+
+ private boolean gcovFound = false;
+ private long timestamp;
+ private final static WeakHashMap<File, STGcovProgramChecker> map = new WeakHashMap<File, STGcovProgramChecker>();
+
+ /** Private Constructor */
+ private STGcovProgramChecker(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ private static STGcovProgramChecker getProgramChecker(IBinaryObject object) throws IOException {
+ File program = object.getPath().toFile();
+ STGcovProgramChecker pg = map.get(program);
+ if (pg == null) {
+ pg = new STGcovProgramChecker(program.lastModified());
+ STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg);
+ map.put(program, pg);
+ } else {
+ long fileTime = program.lastModified();
+ if (fileTime > pg.timestamp) {
+ pg.timestamp = fileTime;
+ pg.gcovFound = false;
+ STNMFactory.getNM(object.getCPU(), object.getPath().toOSString(), pg);
+ }
+ }
+ return pg;
+ }
+
+ public static boolean isGCovCompatible(String s) throws IOException {
+ IBinaryObject object = STSymbolManager.sharedInstance.getBinaryObject(new Path(s));
+ if (object == null) return false;
+ return isGCovCompatible(object);
+ }
+
+ public static boolean isGCovCompatible(IBinaryObject object) throws IOException {
+ STGcovProgramChecker pg = getProgramChecker(object);
+ return pg.gcovFound;
+ }
+
+ @Override
+ public void foundBssSymbol(String symbol, String address) {
+ }
+
+ @Override
+ public void foundDataSymbol(String symbol, String address) {
+ }
+
+ @Override
+ public void foundTextSymbol(String symbol, String address) {
+ if ("gcov_read_words".equals(symbol) || "_gcov_read_words".equals(symbol))
+ {
+ gcovFound = true;
+ }
+ }
+
+ @Override
+ public void foundUndefSymbol(String symbol) {
+ }
+
+
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFileContentProvider.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFileContentProvider.java
new file mode 100644
index 0000000..1f011bc
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFileContentProvider.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import java.util.LinkedList;
+
+import org.eclipse.linuxtools.gcov.model.CovFolderTreeElement;
+import org.eclipse.linuxtools.gcov.model.CovRootTreeElement;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+
+
+
+public class CovFileContentProvider extends CovFolderContentProvider {
+
+ public static final CovFileContentProvider sharedInstance = new CovFileContentProvider();
+
+ /**
+ * Constructor
+ */
+ protected CovFileContentProvider() {
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof CovRootTreeElement) {
+ CovRootTreeElement root = (CovRootTreeElement) parentElement;
+ LinkedList<? extends TreeElement> ret = getElementChildrenList(root);
+ return ret.toArray();
+ }
+ return super.getChildren(parentElement);
+ }
+
+ protected LinkedList<? extends TreeElement> getElementChildrenList(CovRootTreeElement root) {
+ LinkedList<TreeElement> ret = new LinkedList<TreeElement>();
+ LinkedList<? extends TreeElement> list = root.getChildren();
+ for (TreeElement folderlist : list) {
+ LinkedList<? extends TreeElement> partialList = folderlist.getChildren();
+ ret.addAll(partialList);
+ }
+ return ret;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ Object o = super.getParent(element);
+ if (o instanceof CovFolderTreeElement) {
+ o = super.getParent(o);
+ }
+ return o;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFolderContentProvider.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFolderContentProvider.java
new file mode 100644
index 0000000..f3fbfc1
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFolderContentProvider.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+
+import java.util.LinkedList;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+
+
+public class CovFolderContentProvider implements ITreeContentProvider {
+
+ /** Shared instance: this class is implemented as a Singleton */
+ public static final CovFolderContentProvider sharedInstance = new CovFolderContentProvider();
+
+
+ protected CovFolderContentProvider(){
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ TreeElement elem = (TreeElement) parentElement;
+ LinkedList<? extends TreeElement> list = elem.getChildren();
+ if (list != null)
+ return list.toArray();
+ else return null;
+ }
+
+ public Object getParent(Object element) {
+ TreeElement elem = (TreeElement) element;
+ return elem.getParent();
+ }
+
+ public boolean hasChildren(Object element) {
+ TreeElement elem = (TreeElement) element;
+ return elem.hasChildren();
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement == null) return new Object[0];
+ CovManager cvrgMnger = (CovManager)inputElement;
+ return new Object[] {
+ cvrgMnger.getRootNode()
+ };
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFunctionContentProvider.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFunctionContentProvider.java
new file mode 100644
index 0000000..8093b2a
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovFunctionContentProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import java.util.LinkedList;
+
+import org.eclipse.linuxtools.gcov.model.CovFileTreeElement;
+import org.eclipse.linuxtools.gcov.model.CovRootTreeElement;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+
+
+
+
+public class CovFunctionContentProvider extends CovFileContentProvider {
+
+ public static final CovFunctionContentProvider sharedInstance = new CovFunctionContentProvider();
+
+ /**
+ * Constructor
+ */
+ protected CovFunctionContentProvider() {
+ }
+
+ protected LinkedList<? extends TreeElement> getElementChildrenList(CovRootTreeElement root) {
+ LinkedList<? extends TreeElement> list = super.getElementChildrenList(root);
+ LinkedList<TreeElement> ret = new LinkedList<TreeElement>();
+ for (TreeElement histTreeElem : list) {
+ LinkedList<? extends TreeElement> partialList = histTreeElem.getChildren();
+ ret.addAll(partialList);
+ }
+ return ret;
+ }
+
+
+ @Override
+ public Object getParent(Object element) {
+ Object o = super.getParent(element);
+ if (o instanceof CovFileTreeElement) {
+ o = super.getParent(o);
+ }
+ return o;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovView.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovView.java
new file mode 100644
index 0000000..3346af8
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovView.java
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.STDataViewersImages;
+import org.eclipse.linuxtools.dataviewers.actions.STExportToCSVAction;
+import org.eclipse.linuxtools.dataviewers.charts.actions.ChartAction;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.action.SwitchContentProviderAction;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+import org.eclipse.linuxtools.gcov.parser.SourceFile;
+import org.eclipse.linuxtools.gcov.view.annotatedsource.OpenSourceFileAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.common.TizenHelpContextIds;
+
+
+/**
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ *
+ */
+public class CovView extends AbstractSTDataView {
+
+ private String defaultCSVPath = "gcov.csv";
+
+ private Label label;
+
+ private Action folderAction;
+ private Action fileAction;
+ private Action functionAction;
+ private Composite parent;
+ static CovView cvrgeView;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView#createAbstractSTViewer
+ * (org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected AbstractSTViewer createAbstractSTViewer(Composite parent) {
+ return new CovViewer(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataViewer#contributeToToolbar(org.eclipse.jface.action.IToolBarManager)
+ */
+ @Override
+ protected void contributeToToolbar(IToolBarManager manager) {
+ super.contributeToToolbar(manager);
+ manager.add(new Separator());
+ manager.add(new Separator());
+ manager.add(folderAction);
+ manager.add(fileAction);
+ manager.add(functionAction);
+ manager.add(new Separator());
+ manager.add(new ChartAction(getViewSite().getShell(), getSTViewer()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataViewer#createActions()
+ */
+ @Override
+ protected void createActions() {
+ STDataViewersImages.getImageDescriptor(""); // workaround a bug
+ super.createActions();
+ folderAction = new SwitchContentProviderAction(
+ "Sort coverage per folder",
+ "icons/directory_obj.gif",
+ getSTViewer().getViewer(),
+ CovFolderContentProvider.sharedInstance);
+
+ fileAction = new SwitchContentProviderAction(
+ "Sort coverage per file",
+ "icons/c_file_obj.gif",
+ getSTViewer().getViewer(),
+ CovFileContentProvider.sharedInstance);
+ fileAction.setChecked(true);
+
+ functionAction = new SwitchContentProviderAction(
+ "Sort coverage per function",
+ "icons/function_obj.gif",
+ getSTViewer().getViewer(),
+ CovFunctionContentProvider.sharedInstance);
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, TizenHelpContextIds.HELP_NATIVE_CODECOVERAGE_CONTEXT);
+ STDataViewersImages.getImageDescriptor(""); // workaround a bug
+ super.createPartControl(parent);
+ GridLayout l = (GridLayout) parent.getLayout();
+ l.horizontalSpacing = 0;
+ l.verticalSpacing = 0;
+ l.marginHeight = 0;
+ l.marginWidth = 0;
+ }
+
+ @Override
+ protected void createTitle(Composite parent) {
+ label = new Label(parent, SWT.WRAP);
+ GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 1, 1);
+ label.setLayoutData(data);
+ }
+
+ public static void setCovViewTitle(CovView view, String title,
+ String binaryPath) {
+ view.label.setText(" \n program runs = " + title
+ + " \n program file : " + binaryPath + "\n ");
+ view.label.getParent().layout(true);
+ }
+
+
+ public static void displayCovDetailedResult(String binaryPath, String gcdaFile) {
+ try {
+ // parse and process coverage data
+ CovManager cvrgeMnger = new CovManager(binaryPath);
+ List<String> gcdaPaths = new LinkedList<String>();
+ gcdaPaths.add(gcdaFile);
+ cvrgeMnger.processCovFiles(gcdaPaths);
+ // generate model for view
+ cvrgeMnger.fillGcovView();
+
+ for (SourceFile sf : cvrgeMnger.getSourceMap().values()) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile binary = root.getFileForLocation(new Path(binaryPath));
+ IProject project = null;
+ if (binary != null) project = binary.getProject();
+ OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project,
+ binary, sf, 0);
+ }
+ } catch (Exception _) {
+ final String message = "An error has occured when parsing "
+ + "the coverage data files :\n" + _.getMessage();
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, message, _);
+
+ Activator.getDefault().getLog().log(status);
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openError(s, "Gcov Parsing Error", message);
+ }
+ });
+ return;
+ }
+ }
+
+ public static CovView displayCovResults(String binaryPath) {
+ try {
+ // parse and process coverage data
+ CovManager cvrgeMnger = new CovManager(binaryPath);
+ List<String> gcdaPaths = cvrgeMnger.getGCDALocations();
+ cvrgeMnger.processCovFiles(gcdaPaths);
+ // generate model for view
+ cvrgeMnger.fillGcovView();
+ //load an Eclipse view
+ CovView cvrgeView = displayCovResults(cvrgeMnger);
+ return cvrgeView;
+ } catch (Exception _) {
+ final String message = "An error has occured when parsing "
+ + "the coverage data files :\n" + _.getMessage();
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, message, _);
+
+ Activator.getDefault().getLog().log(status);
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openError(s, "Gcov Parsing Error", message);
+ }
+ });
+ }
+ return null;
+ }
+
+ /**
+ * Used by Test engine and OpenSerAction
+ * @param cvrgeMnger
+ */
+ public static CovView displayCovResults(final CovManager cvrgeMnger) throws PartInitException {
+ //load an Eclipse view
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if( window == null){
+ window = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
+ }
+ final IWorkbenchPage page = window.getActivePage();
+
+ final Shell shell = window.getShell();
+ if (shell != null) {
+ shell.getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ cvrgeView = (CovView) page.showView("org.eclipse.linuxtools.gcov.view");
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //view title
+ CovView.setCovViewTitle(cvrgeView, Integer
+ .toString((int) cvrgeMnger.getNbrPgmRuns()), cvrgeMnger
+ .getBinaryPath());
+
+ // load the controller
+ cvrgeView.setInput(cvrgeMnger);
+ CovViewer stviewer = (CovViewer) cvrgeView.getSTViewer();
+ stviewer.getViewer().expandToLevel(2);
+ }
+ });
+ }
+
+
+ return cvrgeView;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractview.AbstractSTDataView#createExportToCSVAction()
+ */
+ @Override
+ protected IAction createExportToCSVAction() {
+ IAction action = new STExportToCSVAction(this.getSTViewer()) {
+ @Override
+ public void run() {
+ Object o = getSTViewer().getInput();
+ if (o instanceof CovManager) {
+ getExporter().setFilePath(getDefaultCSVPath());
+ }
+ super.run();
+ }
+
+ };
+ return action;
+ }
+
+ /**
+ * @return the defaultCSVPath
+ */
+ public String getDefaultCSVPath() {
+ return defaultCSVPath;
+ }
+
+ /**
+ * @param defaultCSVPath the defaultCSVPath to set
+ */
+ public void setDefaultCSVPath(String defaultCSVPath) {
+ this.defaultCSVPath = defaultCSVPath;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovViewer.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovViewer.java
new file mode 100644
index 0000000..5ec9694
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/CovViewer.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTTreeViewer;
+import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
+import org.eclipse.linuxtools.gcov.model.CovFileTreeElement;
+import org.eclipse.linuxtools.gcov.model.CovFunctionTreeElement;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+import org.eclipse.linuxtools.gcov.parser.SourceFile;
+import org.eclipse.linuxtools.gcov.view.annotatedsource.OpenSourceFileAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+
+
+public class CovViewer extends AbstractSTTreeViewer {
+
+ private ISTDataViewersField[] fields;
+
+ /**
+ * Constructor
+ * @param parent
+ */
+ public CovViewer(Composite parent) {
+ super(parent, SWT.BORDER | SWT.H_SCROLL| SWT.V_SCROLL | SWT.MULTI |
+ SWT.FULL_SELECTION);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#createContentProvider()
+ */
+ @Override
+ protected IContentProvider createContentProvider() {
+ return CovFileContentProvider.sharedInstance;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getAllFields()
+ */
+ @Override
+ public ISTDataViewersField[] getAllFields() {
+ if (fields == null) {
+ fields = new ISTDataViewersField[] {
+ new FieldName(),
+ new FieldTotalLines(),
+ new FieldInstrumentedLines(),
+ new FieldExecutedLines(),
+ new FieldCoveragePercentage() };
+ }
+ return fields;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#getDialogSettings()
+ */
+ public IDialogSettings getDialogSettings() {
+ return org.eclipse.linuxtools.gcov.Activator.getDefault().getDialogSettings();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer#handleOpenEvent(org.eclipse.jface.viewers.OpenEvent)
+ */
+ protected void handleOpenEvent(OpenEvent event) {
+
+ IStructuredSelection selection = (IStructuredSelection) event
+ .getSelection();
+ TreeElement element = (TreeElement) selection.getFirstElement();
+
+ if (element != null) {
+ if (element.getParent() != null) {
+ String sourceLoc = "";
+ long lineNumber = 0;
+
+ if (element.getClass() == CovFileTreeElement.class)
+ sourceLoc = element.getName();
+
+ else if (element.getClass() == CovFunctionTreeElement.class) {
+ sourceLoc = ((CovFunctionTreeElement) element).getSourceFilePath();
+ lineNumber =((CovFunctionTreeElement)element).getFirstLnNmbr();
+ }
+ CovManager cvm = (CovManager) this.getInput();
+ SourceFile sourceFile = cvm.getSourceFile(sourceLoc);
+ if (sourceFile != null) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ String binaryLoc = cvm.getBinaryPath();
+ IPath binaryPath = new Path(binaryLoc);
+ IFile binary = root.getFileForLocation(binaryPath);
+ IProject project = null;
+ if (binary != null) project = binary.getProject();
+
+ OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project,
+ binary, sourceFile, (int)lineNumber);
+ }
+ }
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldCoveragePercentage.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldCoveragePercentage.java
new file mode 100644
index 0000000..fa92b6e
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldCoveragePercentage.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractPercentageDrawerField;
+import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
+import org.eclipse.linuxtools.gcov.model.CovRootTreeElement;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+
+
+
+public class FieldCoveragePercentage extends AbstractPercentageDrawerField implements IChartField {
+
+ public final static NumberFormat nf = new DecimalFormat("##0.0#");
+
+
+ public String getColumnHeaderText() {
+ return "Coverage %";
+ }
+
+ @Override
+ public String getValue(Object obj) {
+ float f = getPercentage(obj);
+ if (f < 0)
+ f = 0.0f;
+ return nf.format(f);
+ }
+
+
+ /**
+ * Gets the percentage value to display
+ * @param obj
+ * @return the percentage value to display, as a float
+ */
+ public float getPercentage(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ return e.getCoveragePercentage();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractPercentageDrawerField#getNumberFormat()
+ */
+ @Override
+ public NumberFormat getNumberFormat() {
+ return nf;
+ }
+
+ @Override
+ public boolean isSettedNumberFormat() {
+ return true;
+ }
+
+ public String getToolTipText(Object element) {
+ TreeElement e = (TreeElement) element;
+ String s =" Coverage % = "+Integer.toString((int)e.getCoveragePercentage());
+ return s ;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object obj1, Object obj2) {
+ TreeElement e1 = (TreeElement) obj1;
+ TreeElement e2 = (TreeElement) obj2;
+ float f1 = e1.getCoveragePercentage();
+ float f2 = e2.getCoveragePercentage();
+ return Float.compare(f1, f2);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
+ */
+ public Number getNumber(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ float f = getPercentage(obj);
+ /* FIXED: In code coverage, the graphical representation of coverage% is always zero for summary.
+ if (e.getClass() == CovRootTreeElement.class)
+ return 0;
+ else {
+ */
+ if (f < 0)
+ f = 0.0f;
+ return f;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldExecutedLines.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldExecutedLines.java
new file mode 100644
index 0000000..718a117
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldExecutedLines.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+
+
+public class FieldExecutedLines extends AbstractSTDataViewersField implements IChartField{
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ public String getColumnHeaderText() {
+ return "Executed Lines";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ public String getValue(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ return Integer.toString(e.getExecutedLines());
+ }
+
+ @Override
+ public String getToolTipText(Object element) {
+ TreeElement e = (TreeElement) element;
+ String s = "Executed lines number = "
+ + Integer.toString(e.getExecutedLines());
+ return s;
+ }
+
+ public int compare(Object obj1, Object obj2) {
+ TreeElement e1 = (TreeElement) obj1;
+ TreeElement e2 = (TreeElement) obj2;
+ String s1 = Integer.toString(e1.getExecutedLines());
+ String s2 = Integer.toString(e2.getExecutedLines());
+ if (s1 == null) {
+ if (s2 == null)
+ return 0;
+ return -1;
+ }
+ if (s2 == null)
+ return 1;
+ return s1.compareTo(s2);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
+ */
+ public Number getNumber(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ return e.getExecutedLines();
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldInstrumentedLines.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldInstrumentedLines.java
new file mode 100644
index 0000000..3d478dd
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldInstrumentedLines.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField;
+import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+
+
+
+public class FieldInstrumentedLines extends AbstractSTDataViewersField implements IChartField{
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ public String getColumnHeaderText() {
+ return "Instrumented Lines";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ public String getValue(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ return Integer.toString(e.getInstrumentedLines());
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
+ TreeElement e = (TreeElement) element;
+ String s = "Instrumented lines number = "+Integer.toString(e.getInstrumentedLines());
+ return s;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object obj1, Object obj2) {
+ TreeElement e1 = (TreeElement) obj1;
+ TreeElement e2 = (TreeElement) obj2;
+ String s1 = Integer.toString(e1.getInstrumentedLines());
+ String s2 = Integer.toString(e2.getInstrumentedLines());
+ if (s1 == null) {
+ if (s2 == null) return 0;
+ return -1;
+ }
+ if (s2 == null) return 1;
+ return s1.compareTo(s2);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.charts.provider.IChartField#getNumber(java.lang.Object)
+ */
+ public Number getNumber(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ return e.getInstrumentedLines();
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldName.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldName.java
new file mode 100644
index 0000000..7193628
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldName.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+
+
+public class FieldName extends AbstractSTDataViewersField {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ @Override
+ public String getColumnHeaderText() {
+ return "Name";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ @Override
+ public String getValue(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ String nm = e.getName();
+ nm = nm.substring(nm.lastIndexOf('/')+1);
+ nm = nm.substring(nm.lastIndexOf('\\')+1);
+ return nm;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
+ TreeElement elem = (TreeElement) element;
+ String s = elem.getName();
+ return s;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int compare(Object obj1, Object obj2) {
+ String s1 = getValue(obj1);
+ String s2 = getValue(obj2);
+ if (s1 == null) {
+ if (s2 == null)
+ return 0;
+ return -1;
+ }
+ if (s2 == null)
+ return 1;
+ return s1.compareTo(s2);
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldTotalLines.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldTotalLines.java
new file mode 100644
index 0000000..993679b
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/FieldTotalLines.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view;
+
+
+import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField;
+import org.eclipse.linuxtools.gcov.model.CovFileTreeElement;
+import org.eclipse.linuxtools.gcov.model.CovFunctionTreeElement;
+import org.eclipse.linuxtools.gcov.model.TreeElement;
+
+
+
+public class FieldTotalLines extends AbstractSTDataViewersField {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getColumnHeaderText()
+ */
+ @Override
+ public String getColumnHeaderText() {
+ return "Total Lines";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#getValue(java.lang.Object)
+ */
+ @Override
+ public String getValue(Object obj) {
+ TreeElement e = (TreeElement) obj;
+ if (e.getClass() != CovFunctionTreeElement.class)
+ return Integer.toString(e.getTotalLines());
+ else
+ return "";
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTDataViewersField#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText(Object element) {
+ TreeElement e = (TreeElement) element;
+ if (e.getClass() != CovFunctionTreeElement.class)
+ return "Total lines number = "+Integer.toString(e.getTotalLines());
+ else
+ return "";
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField#compare(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int compare(Object obj1, Object obj2) {
+ TreeElement e1 = (TreeElement) obj1;
+ TreeElement e2 = (TreeElement) obj2;
+
+ if (e1.getClass() == CovFileTreeElement.class) {
+ String s1 = Integer.toString(((CovFileTreeElement)e1).getTotalLines());
+ String s2 = Integer.toString(((CovFileTreeElement)e2).getTotalLines());
+ if (s1 == null) {
+ if (s2 == null)
+ return 0;
+ return -1;
+ }
+ if (s2 == null)
+ return 1;
+ return s1.compareTo(s2);
+ }
+ else return 0;
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/CoverageAnnotationColumn.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/CoverageAnnotationColumn.java
new file mode 100644
index 0000000..8e098b5
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/CoverageAnnotationColumn.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view.annotatedsource;
+
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.ISTAnnotationColumn;
+import org.eclipse.linuxtools.gcov.parser.Line;
+import org.eclipse.linuxtools.gcov.parser.SourceFile;
+
+
+public class CoverageAnnotationColumn implements ISTAnnotationColumn {
+
+
+ private final ArrayList<Line> lines;
+
+ public CoverageAnnotationColumn(SourceFile sourceFile) {
+ lines = sourceFile.getLines();
+ }
+
+ @Override
+ public String getAnnotation(int index) {
+ try {
+ Line l = lines.get(index+1);
+ if (!l.isExists()) {
+ return "";
+ } else {
+ return Long.toString(l.getCount());
+ }
+ } catch (IndexOutOfBoundsException _) {
+ return "";
+ }
+ }
+
+ @Override
+ public String getLongDescription(int line) {
+ return null;
+ }
+
+ @Override
+ public String getTitle() {
+ return "Coverage";
+ }
+
+
+ @Override
+ public String getHeaderTooltip() {
+ return "Coverage";
+ }
+
+ @Override
+ public String getTooltip(int index) {
+ try {
+ Line l = lines.get(index+1);
+ if (!l.isExists()) {
+ return "non executable line";
+ } else {
+ long count = l.getCount();
+ if (count == 0) return "line never executed";
+ if (count == 1) return "line executed 1 time";
+ return "line executed "
+ + Long.toString(count)
+ + " times";
+ }
+ } catch (IndexOutOfBoundsException _) {
+ return "non executable line";
+ }
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/OpenSourceFileAction.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/OpenSourceFileAction.java
new file mode 100644
index 0000000..4852144
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/OpenSourceFileAction.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view.annotatedsource;
+
+import java.net.URI;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.linuxtools.binutils.link2source.STLink2SourceSupport;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.AbstractSTAnnotatedSourceEditorInput;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.actions.AbstractOpenSourceFileAction;
+import org.eclipse.linuxtools.gcov.Activator;
+import org.eclipse.linuxtools.gcov.parser.SourceFile;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IURIEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+public class OpenSourceFileAction {
+
+ /**
+ * Shared instance of this class
+ */
+ public static final OpenSourceFileAction sharedInstance = new OpenSourceFileAction();
+
+ private OpenSourceFileAction() {
+ }
+
+
+ // FIXME: move this method in binutils plugin.
+ private IFileStore getFileStore(IProject project, IPath path) {
+ IEditorInput input = STLink2SourceSupport.sharedInstance.getEditorInput(path, project);
+ if (input instanceof IURIEditorInput) {
+ IURIEditorInput editorInput = (IURIEditorInput) input;
+ URI uri = editorInput.getURI();
+ try {
+ IFileStore fs = EFS.getStore(uri);
+ return fs;
+ } catch (CoreException _) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+
+ private AbstractSTAnnotatedSourceEditorInput getInput(SourceFile sourceFile,
+ IFileStore fs) {
+ AbstractSTAnnotatedSourceEditorInput input = new STAnnotatedSourceEditorInput(
+ fs, sourceFile);
+ IWorkbenchPage p = CUIPlugin.getActivePage();
+ IEditorPart editorPart = p.findEditor(input);
+ if (editorPart != null)
+ p.closeEditor(editorPart, false);
+ return input;
+ }
+
+ public void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, int lineNumber) {
+ if (sourceFile == null) return;
+ String pathName = sourceFile.getName();
+ if (pathName == null) return;
+ IPath path = new Path(pathName);
+ openAnnotatedSourceFile(project, binary, sourceFile, path, lineNumber);
+ }
+
+ public void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, IPath realLocation, int lineNumber) {
+ IWorkbenchPage page = CUIPlugin.getActivePage();
+ if (page != null) {
+ IFileStore fs = getFileStore(project, realLocation);
+ if (fs == null && !realLocation.isAbsolute() && binary != null) {
+ IPath p = binary.getProjectRelativePath().removeLastSegments(1);
+ fs = getFileStore(project, p.append(realLocation));
+ }
+ if (fs == null) {
+ try {
+ page.openEditor(new STAnnotatedSourceNotFoundEditorInput(project,sourceFile,
+ realLocation, lineNumber),
+ STAnnotatedSourceNotFoundEditor.ID, true);
+ } catch (PartInitException e) {
+ Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, "Error when opening annotated source view",
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+ } else {
+ IEditorInput input = getInput(sourceFile, fs);
+ try {
+ IEditorPart editor = page.openEditor(input,
+ AbstractOpenSourceFileAction.EDITOR_ID, true);
+ if (lineNumber > 0 && editor instanceof ITextEditor) {
+ IDocumentProvider provider = ((ITextEditor) editor).getDocumentProvider();
+ IDocument document = provider.getDocument(editor.getEditorInput());
+ try {
+ int start = document.getLineOffset(lineNumber - 1);
+ ((ITextEditor) editor).selectAndReveal(start, 0);
+ } catch (BadLocationException _) {
+ // ignore
+ }
+ IWorkbenchPage p = editor.getSite().getPage();
+ p.activate(editor);
+ }
+ } catch (PartInitException e) {
+ Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, "Error when opening annotated source view",
+ e);
+ Activator.getDefault().getLog().log(s);
+ }
+ }
+ }
+ }
+
+
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceEditorInput.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceEditorInput.java
new file mode 100644
index 0000000..a74bc69
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceEditorInput.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view.annotatedsource;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.AbstractSTAnnotatedSourceEditorInput;
+import org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.ISTAnnotationColumn;
+import org.eclipse.linuxtools.gcov.parser.Line;
+import org.eclipse.linuxtools.gcov.parser.SourceFile;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+
+
+public class STAnnotatedSourceEditorInput extends
+AbstractSTAnnotatedSourceEditorInput {
+
+ private final SourceFile sourceFile;
+ private final int lineCount;
+ private final ArrayList<ISTAnnotationColumn> columns = new ArrayList<ISTAnnotationColumn>();
+
+ public static final Color GREEN = new Color(PlatformUI.getWorkbench().getDisplay(), 0 ,128, 0);
+
+ // FIXME: dispose colors ?
+ private static final Color[] greenColors = new Color[129];
+
+
+ public STAnnotatedSourceEditorInput(IFileStore fileStore, SourceFile sourceFile){
+ super(fileStore);
+ this.sourceFile = sourceFile;
+ lineCount = sourceFile.getLines().size();
+ this.columns.add(new CoverageAnnotationColumn(sourceFile));
+ }
+
+ @Override
+ public Color getColor(int ln) {
+ final int index = ln + 1;
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ if (index < lineCount){
+ ArrayList<Line> lines = sourceFile.getLines();
+ Line line = lines.get(index);
+ if (line.isExists()) {
+ long count = line.getCount();
+ if (count == 0) return display.getSystemColor(SWT.COLOR_RED);;
+ if (count == sourceFile.getmaxLineCount()) return GREEN;
+ int colorIndex = 128 - (int) ((128*count)/sourceFile.getmaxLineCount());
+ if (greenColors[colorIndex] == null) {
+ greenColors[colorIndex] = new Color(display, colorIndex,127+colorIndex,colorIndex);
+ }
+ return greenColors[colorIndex];
+ }
+ }
+ return display.getSystemColor(SWT.COLOR_WHITE);
+ }
+
+ @Override
+ public ArrayList<ISTAnnotationColumn> getColumns() {
+ return columns;
+ }
+
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java
new file mode 100644
index 0000000..b73a617
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditor.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.gcov.view.annotatedsource;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor;
+import org.eclipse.linuxtools.gcov.parser.SourceFile;
+import org.eclipse.ui.IEditorInput;
+
+
+/**
+ * @author Xavier Raynaud <xavier.raynaud@st.com>
+ *
+ */
+public class STAnnotatedSourceNotFoundEditor extends
+ STCSourceNotFoundEditor {
+
+ public static final String ID = "org.eclipse.linuxtools.gcov.view.annotatedsource.STAnnotatedSourceNotFoundEditor";
+
+ public STAnnotatedSourceNotFoundEditor() {
+
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor#openSourceFileAtLocation(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, int)
+ */
+ protected void openSourceFileAtLocation(IProject project, IPath sourceLoc,
+ int lineNumber) {
+ IEditorInput input = this.getEditorInput();
+ if (input instanceof STAnnotatedSourceNotFoundEditorInput) {
+ STAnnotatedSourceNotFoundEditorInput editorInput = (STAnnotatedSourceNotFoundEditorInput) input;
+ SourceFile sf = editorInput.getSourceFile();
+ OpenSourceFileAction.sharedInstance.openAnnotatedSourceFile(project, null, sf, sourceLoc, lineNumber);
+ } else {
+ super.openSourceFileAtLocation(project, sourceLoc, lineNumber);
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditorInput.java b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditorInput.java
new file mode 100644
index 0000000..fb34914
--- /dev/null
+++ b/org.eclipse.linuxtools.gcov/src/org/eclipse/linuxtools/gcov/view/annotatedsource/STAnnotatedSourceNotFoundEditorInput.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2009 STMicroelectronics.
+ * 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:
+ * Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.gcov.view.annotatedsource;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditorInput;
+import org.eclipse.linuxtools.gcov.parser.SourceFile;
+
+
+public class STAnnotatedSourceNotFoundEditorInput extends STCSourceNotFoundEditorInput {
+
+ private final SourceFile sourceFile;
+
+ public STAnnotatedSourceNotFoundEditorInput(IProject project,
+ SourceFile sourceFile,
+ IPath sourcePath, int lineNumber) {
+ super(project, sourcePath, lineNumber);
+ this.sourceFile = sourceFile;
+ }
+
+ /**
+ * @return the sourceFile
+ */
+ public SourceFile getSourceFile() {
+ return sourceFile;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((sourceFile == null) ? 0 : sourceFile.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final STAnnotatedSourceNotFoundEditorInput other = (STAnnotatedSourceNotFoundEditorInput) obj;
+ if (sourceFile == null) {
+ if (other.sourceFile != null)
+ return false;
+ } else if (!sourceFile.equals(other.sourceFile))
+ return false;
+ return true;
+ }
+
+}
diff --git a/org.tizen.codecoverage.feature/.project b/org.tizen.codecoverage.feature/.project
new file mode 100644
index 0000000..750ec27
--- /dev/null
+++ b/org.tizen.codecoverage.feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.tizen.codecoverage.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.tizen.codecoverage.feature/build.properties b/org.tizen.codecoverage.feature/build.properties
new file mode 100644
index 0000000..b3a611b
--- /dev/null
+++ b/org.tizen.codecoverage.feature/build.properties
@@ -0,0 +1,2 @@
+bin.includes = feature.xml,\
+ feature.properties
diff --git a/org.tizen.codecoverage.feature/feature.properties b/org.tizen.codecoverage.feature/feature.properties
new file mode 100644
index 0000000..5714bd6
--- /dev/null
+++ b/org.tizen.codecoverage.feature/feature.properties
@@ -0,0 +1,41 @@
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=Tizen Code Coverage
+
+# "providerName" property - name of the company that provides the feature
+providerName=Tizen
+
+# "updateSiteName" property - label for the update site
+updateSiteName=Tizen Code Coverage Updates
+
+# "description" property - description of the feature
+description=Tool for checking the code coverage for native applications.
+
+# "copyright" property
+copyrightURL=https://developer.tizen.org
+copyright=Copyright (c)
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Tizen SDK\n\
+\n\
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.\n\
+ \n\
+The licenses governing the Open Source Software are available at: http://developer.tizen.org/download/tizen_sdk_opensource_license.html\n\
+ \n\
+Except for the Open Source Software contained in Tizen SDK, all other software portions contained in Tizen SDK are governed by the terms and conditions of the Tizen Software Development Kit License Agreement, available at: http://developer.tizen.org/download/samsung_sdk_license.html\n\
+ \n\
+You may access and download Tizen SDK Open Source Software at: http://developer.tizen.org/download/tizenopensdk.tar.gz\n\
+ \n\
+BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS AND THE TIZEN SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT. IF YOU DO NOT AGREE WITH THE OPEN SOURCE SOFTWARE LICENSE TERMS OR THE TIZEN SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT, YOU MAY NOT DOWNLOAD OR USE TIZEN SDK.\n
+########### end of license property ##########################################
diff --git a/org.tizen.codecoverage.feature/feature.xml b/org.tizen.codecoverage.feature/feature.xml
new file mode 100644
index 0000000..3af6918
--- /dev/null
+++ b/org.tizen.codecoverage.feature/feature.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.tizen.codecoverage.feature"
+ label="%featureName"
+ version="1.0.0.qualifier"
+ provider-name="%providerName"
+ plugin="org.tizen.codecoverage"
+ license-feature="org.tizen.base.feature">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="">
+ %license
+ </license>
+
+ <plugin
+ id="org.eclipse.linuxtools.binutils"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.dataviewers"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.dataviewers.annotatedsourceeditor"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.dataviewers.charts"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.gcov"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.birt.chart.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.birt.chart.engine"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.birt.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.emf.ecore"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.emf.ecore.xmi"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.birt.core.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.mozilla.javascript"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.emf.common"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.birt.data"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.birt.data.aggregation"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.datatools.connectivity.oda.consumer"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.datatools.connectivity.oda.profile"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.datatools.connectivity.oda"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.datatools.connectivity"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.tizen.codecoverage"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.tizen.nativecommon"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.tizen.nativeappcommon"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.tizen.nativecpp"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/org.tizen.codecoverage.update/.project b/org.tizen.codecoverage.update/.project
new file mode 100644
index 0000000..e071335
--- /dev/null
+++ b/org.tizen.codecoverage.update/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.tizen.codecoverage.update</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.UpdateSiteBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.UpdateSiteNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.tizen.codecoverage/.classpath b/org.tizen.codecoverage/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/org.tizen.codecoverage/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.codecoverage/.project b/org.tizen.codecoverage/.project
new file mode 100644
index 0000000..ee5a68f
--- /dev/null
+++ b/org.tizen.codecoverage/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.tizen.codecoverage</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs b/org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..8e500c1
--- /dev/null
+++ b/org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,72 @@
+#Fri Dec 02 17:57:57 KST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/org.tizen.codecoverage/32_TIZEN_SDK_icon.png b/org.tizen.codecoverage/32_TIZEN_SDK_icon.png
new file mode 100644
index 0000000..e511542
--- /dev/null
+++ b/org.tizen.codecoverage/32_TIZEN_SDK_icon.png
Binary files differ
diff --git a/org.tizen.codecoverage/META-INF/MANIFEST.MF b/org.tizen.codecoverage/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..d12708f
--- /dev/null
+++ b/org.tizen.codecoverage/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.tizen.codecoverage;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.tizen.codecoverage.Activator
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.cdt.core,
+ org.eclipse.cdt.debug.core,
+ org.eclipse.debug.core,
+ org.eclipse.linuxtools.gcov,
+ org.tizen.common
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Import-Package: org.tizen.common.connection,
+ org.tizen.nativecpp.editors.manifest,
+ org.eclipse.cdt.managedbuilder.core,
+ org.tizen.sdblib
+Export-Package: org.tizen.codecoverage.helper
diff --git a/org.tizen.codecoverage/NOTICE b/org.tizen.codecoverage/NOTICE
new file mode 100644
index 0000000..87d9729
--- /dev/null
+++ b/org.tizen.codecoverage/NOTICE
@@ -0,0 +1,2 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
diff --git a/org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties b/org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..e035427
--- /dev/null
+++ b/org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,2 @@
+Bundle-Vendor = The Linux Foundation
+Bundle-Name = Tizen Native Development Tools Code Coverage
diff --git a/org.tizen.codecoverage/about.ini b/org.tizen.codecoverage/about.ini
new file mode 100644
index 0000000..fc8fa16
--- /dev/null
+++ b/org.tizen.codecoverage/about.ini
@@ -0,0 +1,32 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=32_TIZEN_SDK_icon.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (translated)
+# needed for primary features only
+
+# Property "welcomePage" contains path to welcome page (special XML-based format)
+# welcomePage=$nl$/welcome.xml
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
+
+# Property "tipsAndTricksHref" contains the Help topic href to a tips and tricks page
+# optional
+# tipsAndTricksHref=/org.tizen.doc.user/tips/tizen_tips.htm
+
diff --git a/org.tizen.codecoverage/about.mappings b/org.tizen.codecoverage/about.mappings
new file mode 100644
index 0000000..1acdd7b
--- /dev/null
+++ b/org.tizen.codecoverage/about.mappings
@@ -0,0 +1,6 @@
+# about.mappings
+# contains fill-ins for about.properties and bundle.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+0=Tizen Native Development Tools Code Coverage
+1=date-time
diff --git a/org.tizen.codecoverage/about.properties b/org.tizen.codecoverage/about.properties
new file mode 100644
index 0000000..5c2e80a
--- /dev/null
+++ b/org.tizen.codecoverage/about.properties
@@ -0,0 +1,12 @@
+# about.properties
+# contains externalized strings for about.ini
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# fill-ins are supplied by about.mappings
+# This file should be translated.
+
+blurb={0}\n\
+\n\
+Version : {featureVersion}\n\
+Build id : {1}\n\
+\n\
+Visit https://developer.tizen.org \n \ No newline at end of file
diff --git a/org.tizen.codecoverage/build.properties b/org.tizen.codecoverage/build.properties
new file mode 100644
index 0000000..b644643
--- /dev/null
+++ b/org.tizen.codecoverage/build.properties
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ OSGI-INF/,\
+ 32_TIZEN_SDK_icon.png,\
+ about.ini,\
+ about.mappings,\
+ about.properties
diff --git a/org.tizen.codecoverage/icons/toolbar_icon.gif b/org.tizen.codecoverage/icons/toolbar_icon.gif
new file mode 100644
index 0000000..62a7d86
--- /dev/null
+++ b/org.tizen.codecoverage/icons/toolbar_icon.gif
Binary files differ
diff --git a/org.tizen.codecoverage/plugin.xml b/org.tizen.codecoverage/plugin.xml
new file mode 100644
index 0000000..475aa6d
--- /dev/null
+++ b/org.tizen.codecoverage/plugin.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+<extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.tizen.nativeapp.perspective">
+ <actionSet
+ id="org.tizen.gcov.actionSet">
+ </actionSet>
+ </perspectiveExtension>
+</extension>
+<extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ description="GcovActionSet"
+ id="org.tizen.gcov.actionSet"
+ label="GcovActionSet"
+ visible="false">
+ <action
+ class="org.tizen.codecoverage.actions.GcovAction"
+ icon="icons/toolbar_icon.gif"
+ id="org.tizen.gcov.actions.gcovAction"
+ label="GcovAction"
+ style="push"
+ toolbarPath="tizen/CodeCoverage"
+ tooltip="Code Coverage">
+ </action>
+ </actionSet>
+</extension>
+</plugin>
diff --git a/org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java b/org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java
new file mode 100644
index 0000000..d0eb6c8
--- /dev/null
+++ b/org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java
@@ -0,0 +1,70 @@
+/*
+ * Code Coverage
+ *
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JeongHwan kim <jeonghwan0613.kim@samsung.com>
+ * JuYoung Kim <j0.kim@samsung.com>
+ *
+ * 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:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.codecoverage;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.score.gcov"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java b/org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java
new file mode 100644
index 0000000..2469d46
--- /dev/null
+++ b/org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java
@@ -0,0 +1,112 @@
+/*
+ * Code Coverage
+ *
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JeongHwan kim <jeonghwan0613.kim@samsung.com>
+ * JuYoung Kim <j0.kim@samsung.com>
+ *
+ * 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:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.codecoverage.actions;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.linuxtools.gcov.view.CovView;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.codecoverage.helper.GcovHelper;
+
+
+/**
+ * Our sample action implements workbench action delegate. The action proxy will
+ * be created by the workbench and shown in the UI. When the user tries to use
+ * the action, this delegate will be created and execution will be delegated to
+ * it.
+ *
+ * @see IWorkbenchWindowActionDelegate
+ */
+public class GcovAction implements IWorkbenchWindowActionDelegate {
+ // private IWorkbenchWindow window;
+
+ private IProject project;
+ /**
+ * The constructor.
+ */
+ public GcovAction() {
+ project = null;
+ }
+
+ /**
+ * The action has been activated. The argument of the method represents the
+ * 'real' action sitting in the workbench UI.
+ *
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ GcovHelper.run(project);
+ }
+
+ /**
+ * Selection in the workbench has been changed. We can change the state of
+ * the 'real' action here if we want, but this can only happen after the
+ * delegate has been created.
+ *
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ Object obj = null;
+
+ if (selection instanceof TreeSelection) {
+ TreeSelection _selection = (TreeSelection) selection;
+
+ if (_selection != null) {
+ obj = _selection.getFirstElement();
+ }
+ }
+
+ if (obj != null) {
+ if (obj instanceof IResource) {
+ project = ((IResource) obj).getProject();
+ } else if (obj instanceof ICElement) {
+ IResource resource = ((ICElement) obj).getResource();
+ project = ((IResource) resource).getProject();
+ }
+ }
+ }
+
+ /**
+ * We can use this method to dispose of any system resources we previously
+ * allocated.
+ *
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+
+ /**
+ * We will cache window object in order to be able to provide parent shell
+ * for the message dialog.
+ *
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+}
diff --git a/org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java b/org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java
new file mode 100644
index 0000000..ff487f4
--- /dev/null
+++ b/org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java
@@ -0,0 +1,176 @@
+/*
+ * Code Coverage
+ *
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JeongHwan kim <jeonghwan0613.kim@samsung.com>
+ * JuYoung Kim <j0.kim@samsung.com>
+ *
+ * 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:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.codecoverage.helper;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.gcov.parser.CovManager;
+import org.eclipse.linuxtools.gcov.view.CovView;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.nativecpp.editors.manifest.PackageModel;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SyncService;
+import org.tizen.sdblib.SyncService.SyncResult;
+
+public class GcovHelper {
+ final static String DATA_DIR = "/data/";
+
+ static public void run(IProject project) {
+ // null check project
+ if (project == null || !project.exists()) {
+ final String message = "Please select a project.";
+ Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openInformation(s, "Project not found", message);
+ return;
+ }
+
+ IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+ if (currentDevice == null) {
+// final String message = "Target device is not running";
+// Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+// MessageDialog.openError(s, "Gcov Error", message);
+ return;
+ }
+
+ String binary = GcovHelper.getBinary(project);
+ if (binary == null) {
+ final String message = "Gcov failed. Binary file not found.\n"
+ + "Please check Build Settings";
+ Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openError(s, "Gcov Error", message);
+ return;
+ }
+
+ try {
+ GcovHelper.downloadGcdaFile(binary);
+ } catch (Exception e) {
+ final String message = "Gcov failed. Coverage data file not found.";
+ Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openError(s, "Gcov Error", message);
+ return;
+ }
+ CovView.displayCovResults(binary);
+ }
+
+ private static String getBinary(IResource binary, String target) {
+ if (binary.getLocation().toOSString().contains( target ) && binary.getLocation().lastSegment().contains(binary.getProject().getName())) {
+ return binary.getLocation().toOSString();
+ }
+ return null;
+ }
+ // FIXME searching a selected binary is not complete
+ // This part is affected IDE launch part
+ // TODO Fix this method
+ public static String getBinary(IProject project) {
+ String binary = null;
+ ICProject cproject = CoreModel.getDefault().create(project);
+ if (cproject == null) {
+ return binary;
+ }
+ IBinary[] bins = null;
+ try {
+ bins = cproject.getBinaryContainer().getBinaries();
+ } catch (CModelException e) {
+ e.printStackTrace();
+ }
+
+ IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+ if (currentDevice.isEmulator()) {
+ for( IBinary bin : bins ) {
+ binary = getBinary( bin.getResource(), "Emulator" );
+ break;
+ }
+ } else {
+ for( IBinary bin : bins ) {
+ binary = getBinary( bin.getResource(), "Device" );
+ break;
+ }
+ }
+ return binary;
+ }
+
+ static IProject getProject(IPath file) {
+ IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file);
+ return c.getProject();
+ }
+
+ public static void downloadGcdaFile(String binaryPath) throws Exception {
+ CovManager cvrgeMnger = null;
+ List<String> gcdaPaths = null;
+ cvrgeMnger = new CovManager(binaryPath);
+ try {
+ gcdaPaths = cvrgeMnger.getGCDALocations();
+ } catch (Exception e) {
+ final String message = "Gcov failed. Binary not found.";
+ Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openError(s, "Gcov Error", message);
+ return;
+ }
+ // download gcda file
+ IPath file = new Path(binaryPath);
+ IProject project = getProject(file);
+ String targetPath = getGcdaPath(project);
+
+ @SuppressWarnings("restriction")
+ IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+ @SuppressWarnings("restriction")
+ SyncService syncService = currentDevice.getSyncService();
+
+ for (String gcdaPath: gcdaPaths) {
+ int start = gcdaPath.lastIndexOf('/') + 1;
+ int end = gcdaPath.length();
+ String gcdaFile = gcdaPath.substring(start, end);
+ String srcFile = targetPath + gcdaFile;
+ String dstFile = gcdaPath;
+ @SuppressWarnings("restriction")
+ SyncResult syncSuccess = syncService.pullFile(srcFile, dstFile, SyncService.getNullProgressMonitor());
+ if (syncSuccess.getCode() != SyncService.RESULT_OK) {
+ Exception e = new Exception();
+ throw e;
+ }
+ }
+ }
+
+ static public String getGcdaPath(IProject project) {
+ String installPath = getPackageInstallPath(project);
+ String gcdaPath = installPath + DATA_DIR;
+ return gcdaPath;
+ }
+
+ static String getPackageInstallPath(IProject project) {
+ PackageModel packageModel = PackageModel.newInstance(project);
+ String installPath = packageModel.getAppInstallPath();
+ return installPath;
+ }
+}
diff --git a/package/build.linux b/package/build.linux
new file mode 100755
index 0000000..db14e30
--- /dev/null
+++ b/package/build.linux
@@ -0,0 +1,72 @@
+#!/bin/bash -xe
+
+__copy_necessary_binaries()
+{
+ echo "add necessary files."
+ ## ex)
+ ## ide_root_path_name=ide
+ ## cp -rf ~~~~/file.file ${INSTALL_DIR}/${ide_root_path_name}/
+}
+
+__set_parameter()
+{
+ echo "TARGET_OS : ${TARGET_OS}"
+ build_script_path=${ROOTDIR}/pde-build
+}
+
+# clean
+clean()
+{
+ echo "=========================================CLEAN============================================"
+ __set_parameter
+ ${build_script_path}/clean.sh ${package_name}
+}
+
+# build
+build()
+{
+ echo "=========================================BUILD============================================"
+ pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+ for pkgname_and_platform in ${pkgname_and_platform_list}
+ do
+ pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+ package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+ platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+
+ if [ "x${TARGET_OS}" = "x${platform}" ]
+ then
+ __set_parameter
+ ${build_script_path}/build.sh ${package_name}
+ else
+ echo ""
+ fi
+ done
+}
+
+# install
+install()
+{
+ pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+ for pkgname_and_platform in ${pkgname_and_platform_list}
+ do
+ echo "=========================================INSTALL============================================"
+ pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+ package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+ platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+
+ if [ "x${TARGET_OS}" = "x${platform}" ]
+ then
+ __set_parameter
+ INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${TARGET_OS}/data
+ mkdir -p ${INSTALL_DIR}
+ __copy_necessary_binaries
+ ${build_script_path}/install.sh ${package_name}
+ else
+ echo ""
+ fi
+ done
+}
+
+[ "$1" = "clean" ] && clean
+[ "$1" = "build" ] && build
+[ "$1" = "install" ] && install
diff --git a/package/changelog b/package/changelog
new file mode 100644
index 0000000..c508596
--- /dev/null
+++ b/package/changelog
@@ -0,0 +1,15 @@
+* 1.0.19
+- Modified Provider
+== kh5325.kim <kh5325.kim@samsung.com> 2013-02-14
+* 1.0.18
+- In code coverage, the chart view cannot be expanded if is saved as XML source
+== gune.kim <gune.kim@samsung.com> 2012-12-03
+* 1.0.17
+- Merged latest changes
+== gune.kim <gune.kim@samsung.com> 2012-11-27
+* 1.0.16
+- Merged latest changes
+== gune.kim <gune.kim@samsung.com> 2012-11-26
+* 1.0.15
+- macos support
+== gune.kim <gune.kim@samsung.com> 2012-11-05 13:04
diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest
new file mode 100644
index 0000000..32f21aa
--- /dev/null
+++ b/package/pkginfo.manifest
@@ -0,0 +1,38 @@
+Version:1.0.19
+Source:codecoverage-eplugin
+Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung.com>, hyunsik non <hyunsik.noh@samsung.com>, taeyoung son <taeyoung2.son@samsung.com>, gune Kim <gune.kim@samsung.com>, ho namkoong <ho.namkoong@samsung.com>, hyeongseok heo <hyeong-seok.heo@samsung.com>, gyeongseok seo <gyeongseok.seo@samsung.com>, jihoon song <jihoon80.song@samsung.com>, changhyun lee <changhyun1.lee@samsung.com>, bonyong lee <bonyong.lee@samsung.com>
+
+Package:codecoverage-eplugin
+OS:ubuntu-32
+Build-host-os:ubuntu-32
+Build-dependency:common-eplugin[ubuntu-32], pde-build [ubuntu-32], nativeappcommon-eplugin [ubuntu-32], nativecpp-eplugin [ubuntu-32]
+Install-dependency:common-eplugin[ubuntu-32], nativeappcommon-eplugin [ubuntu-32], nativecpp-eplugin [ubuntu-32], base-ide-product[ubuntu-32]
+Description:codecoverage-eplugin
+
+Package:codecoverage-eplugin
+OS:windows-32
+Build-host-os:ubuntu-32
+Build-dependency:common-eplugin[windows-32], pde-build [windows-32], nativeappcommon-eplugin [windows-32], nativecpp-eplugin [windows-32]
+Install-dependency:common-eplugin[windows-32], nativeappcommon-eplugin [windows-32], nativecpp-eplugin [windows-32], base-ide-product[windows-32]
+Description:codecoverage-eplugin
+
+Package:codecoverage-eplugin
+OS:ubuntu-64
+Build-host-os:ubuntu-64
+Build-dependency:common-eplugin[ubuntu-64], pde-build [ubuntu-64], nativeappcommon-eplugin[ubuntu-64], nativecpp-eplugin[ubuntu-64]
+Install-dependency:common-eplugin[ubuntu-64], nativeappcommon-eplugin[ubuntu-64], nativecpp-eplugin[ubuntu-64], base-ide-product[ubuntu-64]
+Description:codecoverage-eplugin
+
+Package:codecoverage-eplugin
+OS:windows-64
+Build-host-os:ubuntu-64
+Build-dependency:common-eplugin[windows-64], pde-build [windows-64], nativeappcommon-eplugin[windows-64], nativecpp-eplugin [windows-64]
+Install-dependency:common-eplugin[windows-64], nativeappcommon-eplugin[windows-64], nativecpp-eplugin[windows-64], base-ide-product[windows-64]
+Description:codecoverage-eplugin
+
+Package:codecoverage-eplugin
+OS:macos-64
+Build-host-os:ubuntu-64
+Build-dependency:common-eplugin[macos-64], pde-build [macos-64], nativeappcommon-eplugin[macos-64], nativecpp-eplugin [macos-64]
+Install-dependency:common-eplugin[macos-64], nativeappcommon-eplugin[macos-64], nativecpp-eplugin[macos-64], base-ide-product[macos-64]
+Description:codecoverage-eplugin